Floor66
2008-11-29 13:27:24
Welcome!
I wanted to make this for my own ButterFly Jar buyer, to calculate earnings.
You can use this for _ANY_ item!
I wanted to make this for my own ButterFly Jar buyer, to calculate earnings.
You can use this for _ANY_ item!
program New;
{.include SRL/SRL.scar}
{*******************************************************************************
Function GetGEPrice(MidMinMax : String; id : Integer): Integer;
By: Floor66
Description: Gets the Mid/Min/Max price out of G.E with the specified item ID
*******************************************************************************}
Function GetGEPrice(MidMinMax : String; id : Integer): Integer;
Var S, I : String;
Begin
S := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj='+ IntToStr(id)); //Get the page
If S = '' Then
Begin
WriteLn('GetGEPrice: Failed to open webpage!');
Exit;
End;
Case MidMinMax Of // Mid, min or max price, take out of the page source
'Mid', 'mid': I := Between('<b>Market price:</b> ', '</span>', S);
'Min', 'min': I := Between('<b>Minimum price:</b> ', '</span>', S);
'Max', 'max': I := Between('<b>Maximum price:</b> ', '</span>', S);
End;
Delete(I, High(I), 1); // Removes the LINE-BREAK that is actually after it:
// <b>Market price:</b> 123 (broken here)
// </span>
I := Replace(I, 'k', '00');
I := Replace(I, 'm', '00000');
I := Replace(I, '.', '');
I := Replace(I, ',', '');
I := Trim(I);
Result := StrToInt(I);
End;
{*******************************************************************************
Function GetGEName(id : Integer): Integer;
By: Floor66
Description: Gets the item name out of G.E with the specified item ID
*******************************************************************************}
Function GetGEName(id : Integer): String;
Var S, N : String;
Begin
S := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj='+ IntToStr(id)); //Get the page
If S = '' Then
Begin
WriteLn('GetGEName: Failed to open webpage!');
Exit;
End;
N := Between('<img id="item_image" src="http://itemdb-rs.runescape.com/2466_obj_big.gif?id='+ IntToStr(id) +'" alt="', '">', S);
Result := N;
End;
Begin
SetUpSRL;
WriteLn(IntToStr(GetGEPrice('Mid', 11696)));
WriteLn(GetGEName(391));
End.