1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71:
| library WikiPedia;
uses SysUtils, Classes, idhttp, Windows, StrUtils, Controls, Forms, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient; type TArrayofstring = array of string;
{$R *.res}
function FindInString(Text, SearchFrom, SearchTo: string; FirstOnly: Boolean; var Return: TArrayofstring): Boolean; var i: Cardinal; FoundString: string; begin Result := False; SetLength(Return, 0); i := Pos(SearchFrom, Text); while i > 0 do begin Result := True; i := i + Length(SearchFrom); FoundString := Copy(Text, i, PosEx(SearchTo,Text,i) - i); [...] if FirstOnly then Break; end; end;
function GetWikipediaID(url:String):String; var p1: integer; begin p1 := Pos('i/',url); Result := Copy(url,p1+2,11); end;
function GetWikipediaTitle(id:string):string; var client : TidHttp; s : string; p1,p2 : integer; begin client := TidHttp.Create(nil); client.AllowCookies := False; client.HandleRedirects := True; client.Request.UserAgent := 'IE';
s := client.Get(id); client.Free;
p1 := Pos('<title>',s); p2 := Pos('</title>',s); Result := Copy(s,p1+7,(p2-p1)-7); end;
exports GetWikipediaID, GetWikipediaTitle, FindInString;
begin end. |