Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program RSWorldParser;
- type
- world = record
- num, pla: Integer;
- pre, 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) - 1);
- 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('<a href="?order=MWPLA">', 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], 2, Pos(' Players', tsb[2]) - 2), 2000);
- fla := Between('"', '"', tsb[3]);
- case Uppercase(fla) of
- 'US': loc := 'United States';
- 'UK': loc := 'UK';
- 'NL': loc := 'Netherlands';
- 'CA': Loc := 'Canada';
- 'AU': Loc := 'Australia';
- 'SE': Loc := 'Sweden';
- 'FI': Loc := 'Finland';
- 'NO': Loc := 'Norway';
- end;
- pre := Between('http://', '.runescape', tsb[1]);
- if pre = '' then
- pre := Replace(Lowercase(Between('>' + #10, #10 + #10, tsb[1])), ' ', '');
- num := StrToIntDef(Replace(pre, 'world', ''), -1);
- if num = -1 then
- Writeln(tsb[1] + ' || ' + pre);
- act := Between('>', '<', tsb[4]);
- 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), '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