Results 1 to 5 of 5

Thread: Price Grabber

  1. #1
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default Price Grabber

    Simba Code:
    function GetItemPrice(Item:String):String;
    var
      a, b:String;
    begin
      Item := replace(Item, ' ', '_',[rfReplaceAll]);

      a := GetPage('2007.runescape.wikia.com/wiki/Exchange:'+Item);
      b:= between('GEPrice">','<', a);
      Result := replace(b, ',', '', [rfReplaceAll]);

    end;
    begin
      WriteLn(GetItemPrice('Abyssal_whip'));
      WriteLn(GetItemPrice('Magic_logs'));



    end.

    OUTPUT
    Code:
    2453236
    1164
    The items are case sensitive and do require an underscore when needed. Look them up before hand and find what works.

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Very cool function, couple things I notice:

    1. Seems that you've declared a variable c of type integer but not used it, consequently the function outputs a string which won't be much use for running numbers based on an item's price the alternative is strToInt()'ing all of your calls to this function.

    You can fix this by wrapping a strToIntDef() around your result

    2. The assignation of values to a and b can be shortened:
    Simba Code:
    ab := between('GEPrice">', '<', getPage('2007.runescape.wikia.com/wiki/Exchange:' + item));

    potentially all three operations can be done in a single line but that gets hard to read:

    Simba Code:
    result := replace(between('GEPrice">', '<', getPage('2007.runescape.wikia.com/wiki/Exchange:' + item)), ',', '', [rfReplaceAll]);

    This is quite cool though, I don't think I've seen one of these for OSRS before!

    E: If you really wanted to you could make the script sanitize the user input, i.e. replace all space characters (" ") with underscores ("_") so users could call your function with Bronze dagger as the input rather than Bronze_dagger
    Last edited by KeepBotting; 01-24-2016 at 12:54 AM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  3. #3
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    This is quite cool though, I don't think I've seen one of these for OSRS before![/FONT]
    https://villavu.com/forum/showthread.php?t=112737

    I made one for osbuddy almost a year ago, its not that well written though

  4. #4
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    https://villavu.com/forum/showthread.php?t=112737

    I made one for osbuddy almost a year ago, its not that well written though
    :O sweet, support for IDs even
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  5. #5
    Join Date
    Mar 2012
    Posts
    107
    Mentioned
    2 Post(s)
    Quoted
    49 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    Very cool function, couple things I notice:

    1. Seems that you've declared a variable c of type integer but not used it, consequently the function outputs a string which won't be much use for running numbers based on an item's price the alternative is strToInt()'ing all of your calls to this function.

    You can fix this by wrapping a strToIntDef() around your result

    2. The assignation of values to a and b can be shortened:
    Simba Code:
    ab := between('GEPrice">', '<', getPage('2007.runescape.wikia.com/wiki/Exchange:' + item));

    potentially all three operations can be done in a single line but that gets hard to read:

    Simba Code:
    result := replace(between('GEPrice">', '<', getPage('2007.runescape.wikia.com/wiki/Exchange:' + item)), ',', '', [rfReplaceAll]);

    This is quite cool though, I don't think I've seen one of these for OSRS before!

    E: If you really wanted to you could make the script sanitize the user input, i.e. replace all space characters (" ") with underscores ("_") so users could call your function with Bronze dagger as the input rather than Bronze_dagger
    What I'm actually thinking of doing is just getting all the right strings for items that are commonly used. Yeah it was just something I whipped up really quick, very easy actually. As you pointed out, I accidentally left an unused integer variable in there, I'll update the OP accordingly.

    I'll have it sanitize the input for spaces as well. Thanks for the feedback.

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
  •