SRL Archive - OSR Help

Looking up prices....


Wyn

2011-11-21 23:11:18

Looking up prices from the ge off the website.

If the value is over 1k it error's.

Help? Here's my tester….

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;

begin
GetPrice;
if SteelBarPrice or CannonballPrice < 0 then
//PRICE FAILS IF OVER 1K
writeln('Failed to get bar')
else
writeln('worked');
Writeln('ball '+inttostr(CannonballPrice)+'gp.');
Writeln('bar '+inttostr(SteelBarPrice)+'gp.');
end.

Flight

2011-11-21 23:16:19

TomTuff helped me with these.


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 GetPrice(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;

Wyn

2011-11-21 23:34:08

From: Flight
TomTuff helped me with these.


Ah thanks that worked.

{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.

Wyn

2011-11-22 08:47:20

Well awesome….There using tables now for GE.

<h6>Pricing Information:</h6>
<table>
<tbody>
<tr>
<th scope="row">Current guide price:</th>
<td>1,003</td>
</tr>
<tr>
<th scope="row">Today's Change:</th>
<td class="positive">+20</td>
</tr>
</tbody>
<tr>
<th scope="row">30 Day Change:</th>
<td class="positive">+70.5%</td>
</tr>
<tr>
<th scope="row">90 Day Change:</th>
<td class="positive">+37.9%</td>
</tr>
<tr>
<th scope="row">180 Day Change:</th>
<td class="positive">+49.7%</td>
</tr>
</table>

Home

2011-11-22 09:09:20

Fixed it for you. :)



{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('<td>', '</td>', GetPage('http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=' + IntToStr(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.


~Home

Wyn

2011-11-23 15:46:43

From: Home
Fixed it for you. :)



code was here


~Home


Lol thanks. I already fixed it before hand; just complaining about Jagex being retarded :frusty:.