PDA

View Full Version : getItemPrice



The Mayor
01-07-2014, 07:26 AM
Just a little something that someone may find useful. It gets the Grand Exchange, Low alchemy, or High Alchemy price of any item.



const
EXCHANGE_PRICE = 1;
LOW_ALCH = 2;
HIGH_ALCH = 3;

function getItemPrice(itemString: string; priceType: integer): integer;
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
case priceType of
1: priceString := between('GEPrice">', '</span>', wikiaPage);
2: priceString := between('<b>Low Alchemy:</b> ', '</li>', wikiaPage);
3: priceString := between('<b>High Alchemy:</b> ', '</li>', wikiaPage);
end;
result := strToIntDef(ExtractFromStr(priceString, numbers), -1);
end;

begin
clearDebug;
writeLn('Fire orb GE price: ' + toStr(getItemPrice('Fire_orb', EXCHANGE_PRICE)));
writeLn('Fire orb Low Alch price: ' +toStr(getItemPrice('Fire_orb', LOW_ALCH)));
writeLn('Fire orb High Alch price: ' +toStr(getItemPrice('Fire_orb', HIGH_ALCH)));

writeLn('Purple Phat GE price: ' + toStr(getItemPrice('Purple_partyhat', EXCHANGE_PRICE)));
end.





Fire orb GE price: 3194
Fire orb Low Alch price: 120
Fire orb High Alch price: 180
Purple Phat GE price: 1175384160
Successfully executed.

Spartan 117
01-08-2014, 06:58 AM
thanks for this piece! I can see this being really useful for progress reports