Results 1 to 5 of 5

Thread: Parsing a webpage.

  1. #1
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Parsing a webpage.

    The webpage I'm (currently) trying to parse is this one:

    http://hiscore.runescape.com/index_l...?player=zezima

    I want to add a Stats feature to my IRC Bot, and I need to be able to delete parts of it. I can handle assigning the stats, but currently I don't know how to exactly delete parts of it.

    Any help? I'm at a loss as to how to do this :/.

    ~Sandstorm

  2. #2
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    function HSGet(C: ChatMsg; Username, Skill: string; Options : TStringArray) : TStringArray;

    var
      I, II, III, L : Integer;
      S : String;
      arrS : TStringArray;
      arrarrS : Array of TStringArray;

    begin
      Result := ['N/A', 'N/A', 'N/A']
      try
        S := GetPage('http://hiscore.runescape.com/index_lite.ws?player=' + Replace(UserName, ' ', '_'))
      except
        Exit;
      end;
      arrS := Explode(#10, S);

      SetArrayLength(arrarrS, 29);
      for I := 0 to 28 do
        arrarrS[I] := Explode(',', ArrS[I]);
      case LowerCase(Skill) of
        'overall'     : I := 0;
        'attack', 'att' : I := 1;
        'defence', 'def' : I := 2;
        'strength', 'str' : I := 3;
        'hitpoints', 'hp' : I := 4;
        'ranged', 'range' : I := 5;
        'prayer', 'pray' : I := 6;
        'magic', 'mage' : I := 7;
        'cooking', 'cook' : I := 8;
        'woodcutting', 'wc' : I := 9;
        'fletching', 'fletch' : I := 10;
        'fishing', 'fish' : I := 11;
        'firemaking', 'fm' : I := 12;
        'crafting', 'craft' : I := 13;
        'smithing', 'smith' : I := 14;
        'mining', 'mine' : I := 15;
        'herblore', 'herb', 'herby' : I := 16;
        'agility'     : I := 17;
        'thieving', 'thief' : I := 18;
        'slayer'      : I := 19;
        'farming', 'farm' : I := 20;
        'runecraft', 'rc', 'runecrafting' : I := 21;
        'hunter'      : I := 22;
        'construction', 'con': I := 23;
        'summoning'   : I := 24;

        'duel_tournament'       : I := 25;
        'bounty_hunters', 'bh' : I := 26;
        'bounty_hunters_rougue', 'bhr' : I := 27;
        'fist_of_guthix', 'fog' : I := 28;
        else
          Exit;
      end;

      for III := 0 to High(Options) do
      begin
        case LowerCase(Options[III]) of
          'rank' : II := 0;
          'level', 'lvl', 'score' : II := 1;
          'xp' : II := 2;
          else II := -1;
        end;
        if II <> -1 then
        begin
          L := Length(Result);
          SetArrayLength(Result, L + 1);
          Result[L] := arrarrS[I][II];
          if Result[L] = '-1' then
            Result[L] := 'N/A';
        end;
      end;
    end;

    Helpful?

    If you need any explanation, just let me know.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  3. #3
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks a lot, that works .

    Do you mind if I use it directly with my script? Credits will be given of course.

    Edit:

    How would I implement an "all" command into there? Such as, !all returns all the skills? Hmm...

    ~Sandstorm
    Last edited by Sandstorm; 04-09-2009 at 05:15 AM.

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    I would us a for loop when grabbing the indexs of the array.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  5. #5
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright, got it, thanks.

    ~Sandstorm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •