
Originally Posted by
Flight
TomTuff helped me with these.
Ah thanks that worked.
Simba Code:
{worked
ball 416gp.
bar 1003gp.
Successfully executed.}
program new;
const
SteelBarID = 'http://services.runescape.com/m=itemdb_rs/Steel_bar/viewitem.ws?obj=2353';
CannonballID = 'http://services.runescape.com/m=itemdb_rs/Cannonball/viewitem.ws?obj=2';
var
site : string;
SteelBarPrice, CannonballPrice : integer;
procedure GetPrice;
begin
site := getpage(CannonballID);
site := trim(Between('<b>Current guide price:</b> ','<br>', site));
CannonballPrice := StrToIntDef(site, -1);
site := getpage(SteelBarID);
site := trim(Between('<b>Current guide price:</b> ','<br>', site));
SteelBarPrice := StrToIntDef(site, -1);
end;
Function CashStringToInt(S: string): Integer; //Thanks TomTuff!
Var
i, ii: Integer;
Numbs: TStringArray;
Temp: string;
begin
Temp := '';
Numbs := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'k', 'm', 'b'];
for i := 1 to High(S) do
for ii := 0 to High(Numbs) do
if S[i] = Numbs[ii] then
case ii of
0..9: Temp := Temp + Numbs[ii];
10..12:
begin
Result := StrToInt(Temp);
case ii of
10: Result := Result * 100; //Since price is given to 1 decimal,
11: Result := Result * 100000; //instead of multiplying by the entire
12: Result := Result * 100000000; //factor, you must multiply by factor/10
end;
end;
end;
if (Result = 0) then
Result := StrToInt(Temp);
end;
Function GetPrice1(ItemID: Integer): Integer;
begin
Result := CashStringToInt(Between('<b>Current guide price:</b>', '<br><br>', GetPage('http://services.runescape.com/m=itemdb_rs/Shark/viewitem.ws?obj=' + ToStr(ItemID))));
end;
begin
cleardebug;
CannonballPrice := GetPrice1(2);
SteelBarPrice := GetPrice1(2353);
if SteelBarPrice or CannonballPrice < 0 then
writeln('Failed to get bar')
else
writeln('worked');
Writeln('ball '+inttostr(CannonballPrice)+'gp.');
Writeln('bar '+inttostr(SteelBarPrice)+'gp.');
end.