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:
| library Project2;
uses SysUtils, Classes,ShareMem, Forms, WinInet;
{$R *.res}
procedure GetHTML(AUrl: string); export; var databuffer : array[0..4095] of char; ResStr : string; hSession, hfile: hInternet; dwindex,dwcodelen,dwread,dwNumber: cardinal; dwcode : array[1..20] of char; res : pchar; Str : pchar; F : TextFile; 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 Try hfile:=InternetOpenUrl( hsession, pchar(AUrl), nil, 0, INTERNET_FLAG_RELOAD, 0); if assigned(hfile) then Try 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)) AND (dwRead <>0) do begin databuffer[dwread]:=#0; Str := pchar(@databuffer); resStr := resStr + Str; Application.ProcessMessages; end; end else ResStr := 'Status:'+res; Finally InternetCloseHandle(hfile); End; Finally InternetCloseHandle(hsession); AssignFile(F,'1.tmp'); Rewrite(F); Writeln(F, ResStr); CloseFile(F); End; end; |