PDA

View Full Version : Price Grabber



One Kid
01-24-2016, 12:16 AM
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


2453236
1164



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

KeepBotting
01-24-2016, 12:48 AM
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: 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:

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

Hoodz
01-24-2016, 12:58 AM
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

KeepBotting
01-24-2016, 01:02 AM
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

One Kid
01-24-2016, 02:44 AM
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: 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:

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.