Registriert seit: 21. Okt 2003
Ort: Dresden
177 Beiträge
|
Re: Quelltext einer Seite runterladen
24. Apr 2004, 12:48
Vielleicht hilft dir diese Funktion hier:
Delphi-Quellcode:
Function GetHTML(AUrl: string): string;
var
databuffer : array[0..4095] of char;
ResStr : string;
hSession, hfile, hRequest: hInternet;
dwindex,dwcodelen,datalen,dwread,dwNumber: cardinal;
dwcode : array[1..20] of char;
res : pchar;
Str : pchar;
begin
ResStr:='';
if pos('http://',lowercase(AUrl))=0 then
AUrl:='http://'+AUrl;
hSession:=InternetOpen('InetURL:/1.0',
INTERNET_OPEN_TYPE_PRECONFIG,
nil,
nil,
0);
if assigned(hsession) then
begin
hfile:=InternetOpenUrl(
hsession,
pchar(AUrl),
nil,
0,
INTERNET_FLAG_RELOAD,
0);
dwIndex := 0;
dwCodeLen := 10;
HttpQueryInfo(hfile,
HTTP_QUERY_STATUS_CODE,
@dwcode,
dwcodeLen,
dwIndex);
res := pchar(@dwcode);
dwNumber := sizeof(databuffer)-1;
if (res ='200') or (res ='302') then
begin
while (InternetReadfile(hfile,
@databuffer,
dwNumber,
DwRead)) do
begin
if dwRead =0 then
break;
databuffer[dwread]:=#0;
Str := pchar(@databuffer);
resStr := resStr + Str;
end;
end
else
ResStr := 'Status:'+res;
if assigned(hfile) then
InternetCloseHandle(hfile);
end;
InternetCloseHandle(hsession);
Result := resStr;
end;
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Text := GetHTML('http://wetter.rtl.de/static/index_ok.php');
end;
|
|
Zitat
|