Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program GE_Price_Downloader;
- type
- item = record
- name: string;
- id, minP, curP, maxP: Integer;
- end;
- var
- items: array of item;
- c, p: Integer;
- n, e: TStringArray;
- s: string;
- // http://itemdb-rs.runescape.com/viewitem.ws?obj=10392
- // http://itemdb-rs.runescape.com/results.ws?query=&sup=Initial Letter&cat=A
- procedure Writelm(input: array of Variant);
- var
- i: Integer;
- s: string;
- begin
- for i := 0 to High(input) do
- s := s + input[i];
- Writeln(s);
- end;
- function ExplodeM(str, del: string): TStringArray;
- var
- i: Integer;
- begin
- repeat
- SetLength(Result, High(Result) + 2);
- i := Pos(del, str);
- if i < 1 then
- Break;
- Result[High(Result)] := Copy(str, 1, i - 1);
- Delete(str, 1, i + Length(del) - 1);
- until False;
- Result[High(Result)] := str;
- end;
- function ConvertPrice(input: string): Integer;
- var
- f: Extended;
- begin
- input := Replace(Lowercase(Trim(input)), ',', '');
- if (Pos('m', input) > 0) then
- f := StrToFloatDef(Copy(input, 1, Pos('m', input) - 1), 0) * 1000000
- else if (Pos('k', input) > 0) then
- f := StrToFloatDef(Copy(input, 1, Pos('k', input) - 1), 0) * 1000
- else
- f := StrToFloatDef(Input, 0);
- Result := Round(f);
- end;
- begin
- SetLength(n, 1);
- // for c := 0 to 26 do
- // n[c] := Chr(Ord('a') + c);
- n[0] := 'other';
- for c := 0 to High(n) do
- begin
- s := GetPage('http://itemdb-rs.runescape.com/results.ws?query=&sup=Initial Letter&cat=' + n[c]);
- for p := 1 to StrToIntDef(Between('page=', '&', Copy(s, Pos('Next >', s), 200)), 1) do
- begin
- s := GetPage('http://itemdb-rs.runescape.com/results.ws?query=&sup=Initial Letter&cat=' + n[c] + '&page=' + IntToStr(p));
- Delete(s, 1, Pos('tbody>' + #10 + '<tr', s) + 10);
- e := ExplodeM(s, '</tr>' + #10 + '<tr');
- e[High(e)] := Copy(e[High(e)], 1, Pos('</tr>', e[High(e)]));
- Writelm([n[c], ':', p]);
- end;
- end;
- SetLength(items, High(e) + 1);
- for c := 0 to High(e) do
- begin
- with items[c] do
- begin
- name := Between('alt="', '"', e[c]);
- id := StrToIntDef(Between('obj=', '"', e[c]), -1);
- if (id < 0) then
- begin
- Writelm([c, ': ', name, ' :: ', id, ' :: ', minP, '; ', curP, '; ', maxP, ';']);
- Continue;
- end;
- s := GetPage('http://itemdb-rs.runescape.com/viewitem.ws?obj=' + IntToStr(id));
- minP := ConvertPrice(Between('<b>Minimum price:</b> ', #10 + '</span>', s));
- curP := ConvertPrice(Between('<b>Market price:</b> ', #10 + '</span>', s));
- maxP := ConvertPrice(Between('<b>Maximum price:</b> ', #10 + '</span>', s));
- Writelm([c, ': ', name, ' :: ', id, ' :: ', minP, '; ', curP, '; ', maxP, ';']);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement