Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program RSWorldParser;
- type
- world = record
- num, pla: Integer;
- pre, url, fla, loc, act: string;
- loo, qui, pvp, mem: Boolean;
- end;
- var
- worldList: array of world;
- str: string;
- tsa, tsb: TStringArray;
- w: Integer;
- dlgSave: TSaveDialog;
- function Explode(str, del: string): TStringArray;
- var
- i, l: Integer;
- begin
- i := 0;
- l := -1;
- repeat
- Inc(l);
- SetLength(Result, l + 1);
- i := Pos(del, str);
- if i <= 0 then
- Break;
- Result[l] := Copy(str, 1, i - 1);
- Delete(str, 1, i + Length(del));
- until false
- Result[l] := Copy(str, 1, Length(str));
- end;
- begin
- dlgSave := TSaveDialog.Create(nil);
- dlgSave.Filter := 'ini files|*.ini';
- if not dlgSave.Execute then
- TerminateScript;
- str := GetPage('http://www.runescape.com/slu.ws?order=WMPLA');
- Delete(str, 1, Pos('"Sort descending"', str));
- Delete(str, 1, Pos('<tr', str) + 3);
- tsa := Explode(str, '<tr');
- SetLength(worldList, High(tsa) + 1);
- for w := 0 to High(tsa) do
- with worldList[w] do
- begin
- tsb := Explode(tsa[w], '<td');
- if High(tsb) <= 7 then
- begin
- Writeln('Skipping world ' + IntToStr(w + 1) + ' because explosion didn''t return enough values');
- Continue;
- end;
- pla := StrToIntDef(Copy(tsb[2], 1, Pos(' Players', tsb[2]) - 1), 2000);
- fla := Between('"', '"', tsb[3]);
- loc := fla;
- case Uppercase(loc) of
- 'US': loc := 'United States';
- 'UK': loc := 'UK';
- 'NL': loc := 'Netherlands';
- 'CA': Loc := 'Canada';
- 'AU': Loc := 'Australia';
- 'SE': Loc := 'Sweden';
- 'FI': Loc := 'Finland';
- end;
- url := 'http://' + Between('>', '<', tsb[3]) + '/a2,m0,j0,o0';
- pre := Between('http://', '.runescape', url);
- num := StrToIntDef(Copy(pre, 6, Length(pre) - 5), -1);
- act := Copy(tsb[4], 1, Pos('<', tsb[4]) - 1);
- if act = '-' then
- act := '';
- loo := Between('title="', '"', tsb[5]) = 'Y';
- qui := Between('title="', '"', tsb[6]) = 'Y';
- pvp := Between('title="', '"', tsb[7]) = 'Y';
- mem := Between('>', '<', tsb[8]) = 'Members';
- end;
- WriteINI('Worlds', 'Count', IntToStr(High(worldList) + 1), dlgSave.FileName);
- WriteINI('Worlds', 'High', IntToStr(worldList[High(worldList)].num), dlgSave.FileName);
- for w := 0 to High(worldList) do
- with worldList[w] do
- begin
- if mem then
- str := 'Members'
- else
- str := 'Free';
- WriteINI('World' + IntToStr(num), 'Prefix', pre, dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'URL', url, dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'Activity', act, dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'Type', str, dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'Flag', fla + 'Flag', dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'Location', loc, dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'Lootshare', BoolToStr(loo), dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'Quickchat', BoolToStr(qui), dlgSave.FileName);
- WriteINI('World' + IntToStr(num), 'PvP', BoolToStr(pvp), dlgSave.FileName);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement