Ross
2014-08-17 09:04:53
I'm trying to pull prices from the RS wiki, but when I pull the price string to convert it to an integer it tries to take the comma with it. Any ideas on how I can make this not happen?
2014-08-17 09:04:53
2014-08-17 09:19:13
From: therossity
I'm trying to pull prices from the RS wiki, but when I pull the price string to convert it to an integer it tries to take the comma with it. Any ideas on how I can make this not happen?
mystring := replace(mystring, ',', '', [rfReplaceAll]);
2014-08-17 09:23:56
From: bonsai
Something like this should take your commas out.mystring := replace(mystring, ',', '', [rfReplaceAll]);
2014-08-17 17:04:17
From: therossity
Genius, worked great. Thank you!
function getGEPrice(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);
end;
getGEPrice('Iron_ore');
2014-08-17 17:09:35
From: The Mayor
Or you could just extract numbers only:
function getGEPrice(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);
end;
getGEPrice('Iron_ore');