Da 0wner
2009-03-04 23:57:37
function ConvertPrice(s : string) : integer;
begin
if pos('m', s) > 0 then
begin
delete(s, pos('.', s), 1);
delete(s, pos('m', s), 1);
result := StrToInt(s + replicate('0', 7 - length(s)));
exit;
end;
if pos('k', s) > 0 then
begin
delete(s, pos('.', s), 1);
delete(s, pos('k', s), 1);
result := StrToInt(s + replicate('0', 6 - length(s)));
exit;
end;
end;
function GetGEItemObjID(ItemName : string) : integer;
begin
if Length(ItemName) < 1 then exit;
result := StrToInt(GetNumbers(Between('td><a href="./viewitem.ws?obj=', '">',
GetPage('http://itemdb-rs.runescape.com/results.ws?query=' + ItemName +
'&price=all&members='))));
end;
function GetGEItemPrice(Item : string; MinMidMax : string) : integer;
var
s : string;
begin
Item := IntToStr(GetGEItemObjID(Item));
s := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj=' + Item);
case MinMidMax of
'min', 'minimum', 'low', 'lowest' :
begin
result := ConvertPrice(between('<b>Minimum price:</b> ', ' ', s));
end;
'mid', 'middle', 'market' :
begin
result := ConvertPrice(between('<b>Market price:</b> ', ' ', s));
end;
'max', 'maximum', 'high', 'highest' :
begin
result := ConvertPrice(between('<b>Maximum price:</b> ', ' ', s));
end;
end;
end;
This has to access like 2 webpages so it is kind of slow.
Only way to do it when using item names instead of IDs. I could make it grab the price right off the search page but I didn't feel like it. If people use this I may.
Usage:
Writeln('Bandos Boots Object ID is ' + IntToStr(GetGEItemObjID('bandos boots')));That would write the object ID of Bandos Boots.Also note you have to put the whole name so that it will work correctly as it grabs the first result of the search page.
To get the items price you can do this
BandosBootsPrices[0] := GetGeItemPrice('bandos boots', 'min');
BandosBootsPrices[1] := GetGeItemPrice('bandos boots', 'mid');
BandosBootsPrices[2] := GetGeItemPrice('bandos boots', 'max');
That would get the minimum, market, and maximum prices of bandos boots and store it in an array. It is pretty slow since it accesses 2 webpages with each GetGEItemPrice call. I can make it faster by making GetGEItemPrice return an array with the minimum, market, and maximum prices. If you want that just say so. Enjoy!Edit: Oh and one more thing.
I use a function in there that I made called "ConvertPrice to convert the prices like '870.0k' into '870000'. You can use that in your own but it only works with prices that are setup like RS. So you can't have it convert 870k into 870000 it must have the leading decimal and zero. Same with m.