Results 1 to 6 of 6

Thread: [Tutorial] How to grab item prices from rswiki and the offical runescape website.

  1. #1
    Join Date
    Aug 2013
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default [Tutorial] How to grab item prices from rswiki and the offical runescape website.

    How to grab item prices from rswiki and the offical runescape website.
    ____________________________

    This tutorial was last updated on January 24th, 2016.

    What will you learn?


    Currently, there are two main methods to grabbing the prices : the unofficial rswiki and the official runescape grand exchange website. Thus, In this guide you will learn both methods to price-
    grab any item available on the Grand Exchange in RS3.

    Requirements


    Here are the requirements you will need for this guide:

    • An item you can buy from the Grand Exchange
    • A Simba Script
    • An internet connection :P

    Method 1: Price-grabbing from the unofficial rswiki


    In order to price-grab an item from the rswiki, we will be using the following function:
    Simba Code:
    function getPrice(theItem:string):integer; //credits goes to The Mayor
    var
      thePage, thePrice:string;
    begin
      thePage := getPage('http://runescape.wikia.com/wiki/Exchange:' + theItem);
      thePrice := between('GEPrice">', '</span>', thePage);
      thePrice := replace(thePrice, ',', '', [rfReplaceAll]);
      result := strToIntDef(thePrice, 0);
    end;
    Now, let's put this into practice by finding the price of big bones with the following script.
    Simba Code:
    program rsWiki; //credits goes to The Mayor
    {$DEFINE SMART}
    {$i srl-6/srl.simba}

    var
      bigBonesPrice: integer;

    function getPrice(theItem:string):integer;
    var
      thePage, thePrice:string;
    begin
      thePage := getPage('http://runescape.wikia.com/wiki/Exchange:' + theItem);
      thePrice := between('GEPrice">', '</span>', thePage);
      thePrice := replace(thePrice, ',', '', [rfReplaceAll]);
      result := strToIntDef(thePrice, 0);
    end;

    begin
      clearDebug();
      bigBonesPrice := getPrice('Big_bones');
      writeLn(bigBonesPrice);
    end.
    If you were to run this, you would get the following in the debug screen.
    Simba Code:
    375
    Successfully executed.

    Finally, let's check if that's the same price as on the rswiki.
    Success!

    Method 2: Price-grabbing from the official rswiki


    In order to price-grab an item from the official Grand Exchange webpage, we will be using the following built-in SRL-6 function.
    Simba Code:
    grandExchange.getPrice();
    Once again, let's put it into practice by finding the price of big bones using the following script:
    Simba Code:
    program rsExchange;
    {$DEFINE SMART}
    {$i srl-6/srl.simba}

    var
      bigBonesPrice: integer;

    begin
      clearDebug();
      bigBonesPrice := grandexchange.getPrice(532);
      writeLn(bigBonesPrice);
    end.
    If you run the script, you would get this:
    Simba Code:
    SRL: Logfile = C:\Simba\Includes\SRL-6/logs/SRL log (24-01-16 at 04.09.25 PM).txt
    -- TRSGrandExchange.getPrice(532): 375
    375
    Successfully executed.
    Finally, let's check if that's the same on the official grand exchange website.
    Success!

    Conclusion


    I hope you have learned something from this little guide. If you have any questions, comments, concerns, or even complements, please let me know.

    -General Patrick

    Credits



  2. #2
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Looks nice, although you might want to change this line:

    theItem := replace(theItem, '_', ' ', [rfReplaceAll]);

    As currently it serves no purpose at the bottom of the function. I'm picking you would want it to be something like:

    Simba Code:
    function getPrice(theItem:string):integer;
    var
      thePage: string;
    begin
      theItem := replace(theItem, ' ', '_', [rfReplaceAll]);  // Replace _ with space
      thePage := getPage('http://runescape.wikia.com/wiki/Exchange:' + theItem);
      result := strToIntDef(replace(between('GEPrice">', '</span>', thePage), ',', '', [rfReplaceAll]), 0);
    end;

    begin
      clearDebug();
      writeLn(getPrice('Big bones')); //So you don't have to have underscores in name
    end.

  3. #3
    Join Date
    Aug 2013
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default

    Quote Originally Posted by The Simba Noob View Post
    Looks nice, although you might want to change this line:

    theItem := replace(theItem, '_', ' ', [rfReplaceAll]);

    As currently it serves no purpose at the bottom of the function. I'm picking you would want it to be something like:

    Simba Code:
    function getPrice(theItem:string):integer;
    var
      thePage: string;
    begin
      theItem := replace(theItem, ' ', '_', [rfReplaceAll]);  // Replace _ with space
      thePage := getPage('http://runescape.wikia.com/wiki/Exchange:' + theItem);
      result := strToIntDef(replace(between('GEPrice">', '</span>', thePage), ',', '', [rfReplaceAll]), 0);
    end;

    begin
      clearDebug();
      writeLn(getPrice('Big bones')); //So you don't have to have underscores in name
    end.
    Haha, yeah thanks for the little edit. I added you to the credits!

  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 The Simba Noob View Post
    Looks nice, although you might want to change this line:

    theItem := replace(theItem, '_', ' ', [rfReplaceAll]);

    As currently it serves no purpose at the bottom of the function.
    That was originally used for debugging, because after the function ran, I would output the name of the item and the amount we ended up with
    The theItem variable was useless by that point so I figured why not just run another replace() on it so we can have pretty debug
    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
    Aug 2013
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    That was originally used for debugging, because after the function ran, I would output the name of the item and the amount we ended up with
    The theItem variable was useless by that point so I figured why not just run another replace() on it so we can have pretty debug
    I was deciding between if i wanted to included showing the fancy debug part into the script, but since my goal was to show the simplest way to grab prices and that one line only shows up for about a second, I ultimately decided not to include it. @The Simba Noob found was an overlooked line on my part and corrected me on my mistake.

  6. #6
    Join Date
    Oct 2016
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Does anyone know if this still works?

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
  •