SRL Archive - RS3 Help

How to get the GE price of certain item?


boscolamhk

2014-12-29 06:19:22

What is the script for getting the GE price of certain item? The following script is extracted from iOak v1.1 from @KeepBotting;


function getPrice(theItem:string):integer;
var
thePage, thePrice:string;
t:TTimeMarker;
begin
t.start();
thePage := getPage('http://runescape.wikia.com/wiki/Exchange:' + theItem);
thePrice := between('GEPrice">', '</span>', thePage);
thePrice := replace(thePrice, ',', '', [rfReplaceAll]);
result := strToIntDef(thePrice, 0);
t.pause();
theItem := replace(theItem, '_', ' ', [rfReplaceAll]);
writeDebug('Grabbed the price of ' + theItem + ' (' + thePrice + ') in ' + toStr(t.getTime()) + ' ms.');
end;

Is there a tutorial telling me what is happening in the above script? (I dunno what it is doing….)
And another silly question…how to tag an user here?


[ATTACH=CONFIG]24691[/ATTACH]

bonsai

2014-12-29 07:36:42

This is from Ross' tanner which is probably from something else….

function getPrice(itemString: string): integer;
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
priceString := between('GEPrice">', '</span>', wikiaPage);
result := strToIntDef(ExtractFromStr(priceString, numbers), - 1);
writeLn(itemString + ' price: ' + toStr(result));
end;

boscolamhk

2014-12-29 08:25:18

From: bonsai
This is from Ross' tanner which is probably from something else….

function getPrice(itemString: string): integer;
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
priceString := between('GEPrice">', '</span>', wikiaPage);
result := strToIntDef(ExtractFromStr(priceString, numbers), - 1);
writeLn(itemString + ' price: ' + toStr(result));
end;


So how to use this function? For example, if I want to get the price of copper ore, should I just include the above function into my script and use:


getPrice(copper_ore)

like this?

Turpinator

2014-12-29 08:53:29

copper_ore_price := getPrice('copper ore');

but… you might have to do this…
copper_ore_price := getPrice('copper%20ore');
or maybe this…
copper_ore_price := getPrice('copper_ore');

You want to know what is happening? each line tells you whats going on.
It grabs the entire webpage from rs wikia. gets whatever is between 'geprice>' and '<span'
removes the commas, then turns that string of numbers into an integer.

boscolamhk

2014-12-29 08:56:37

From: Turpinator
copper_ore_price := getPrice('copper ore');

but… you might have to do this…
copper_ore_price := getPrice('copper%20ore');
or maybe this…
copper_ore_price := getPrice('copper_ore');

You want to know what is happening? each line tells you whats going on.
It grabs the entire webpage from rs wikia. gets whatever is between 'geprice>' and '<span'
removes the commas, then turns that string of numbers into an integer.


Oh…Thank you so much! I understand now. :o

SlipperyPickle

2014-12-29 09:25:02

Nice, was wondering the same thing this morning :D

KeepBotting

2014-12-29 17:34:53

From: bonsai
This is from Ross' tanner which is probably from something else….
I think the original was by The Mayor, unsure though. If anyone knows, tell me and I'll update my script with credits accordingly

From: Turpinator

copper_ore_price := getPrice('copper_ore');

That one. It pulls from the RS Wikia which always uses underscores

Turpinator

2014-12-29 19:48:28

From: KeepBotting
I think the original was by The Mayor, unsure though. If anyone knows, tell me and I'll update my script with credits accordingly


That one. It pulls from the RS Wikia which always uses underscores


Buut… it needs to be 'Copper_ore'

(writing one that fixes idiot's incorrect formatting)

Here we go…
function getGEPrice(itemName: string): integer;
var
wikiaPage, priceString: string;
i, num: integer;
begin
num := ord(itemName[1]);
if inRange(num, 97, 122) then
itemName[1] := chr(num - 32);
for i := 2 to length(itemName) do
begin
num := ord(itemName[i]);
if inRange(num, 65, 90) then
itemName[i] := chr(num + 32);
end;

itemName := replace(itemName, ' ', '_', [rfReplaceAll]);
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemName);
priceString := between('GEPrice">', '</span>', wikiaPage);
result := strToIntDef(ExtractFromStr(priceString, numbers), -1);
itemName := replace(itemName, '_', ' ', [rfReplaceAll]);
writeLn(itemName + ' price: ' + toStr(result));
end;

i renamed it cause its more descriptive. rename it as you so desire.
so this works with…
getGEPrice('Copper_ore');
getGEPrice('coPPer_oRe');
getGEPrice('COPPER_ORE');
getGEPrice('coPPer oRe');
etc, etc...

The Mayor

2014-12-30 19:15:17

Yea the original was: https://villavu.com/forum/showthread.php?t=107485

boscolamhk

2014-12-30 21:38:22

Thanks for the original! :)
so poowerful that it can also get high/low alch price!