![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Загрузка веб страницы как html код
arturich © (2007-03-03 23:28:00)Люди, подскажите, пожалуйста, как загрузить веб страницу, допустим, в TMemo как её html код?
arturich (2007-03-04 16:59:00) [1]спасибо всем, это оказывается двумя строчками делается )
Fredy314 (2007-03-04 09:26:00) [2]или
{Forces a download of the requested file, object, or directory
listing from the origin server, not from the cache}
function DownloadURL_NOCache(const aUrl: string; var s: String): Boolean;
var
hSession: HINTERNET;
hService: HINTERNET;
lpBuffer: array[0..1024 + 1] of Char;
dwBytesRead: DWORD;
begin
Result := False;
s := '';
// hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
if Assigned(hSession) then
begin
hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, INTERNET_FLAG_RELOAD, 0);
if Assigned(hService) then
try
while True do
begin
dwBytesRead := 1024;
InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead);
if dwBytesRead = 0 then break;
lpBuffer[dwBytesRead] := #0;
s := s + lpBuffer;
end;
Result := True;
finally
InternetCloseHandle(hService);
end;
end;
finally
InternetCloseHandle(hSession);
end;
end;
//aufrufen
var
s: String;
begin
if DownloadURL(' http://www.swissdelphicenter.ch/', s) then
ShowMessage(s);
end;
Fredy314 (2007-03-04 09:25:00) [3]uses
Wininet;
function DownloadURL(const aUrl: string): Boolean;
var
hSession: HINTERNET;
hService: HINTERNET;
lpBuffer: array[0..1024 + 1] of Char;
dwBytesRead: DWORD;
begin
Result := False;
// hSession := InternetOpen( 'MyApp', INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
if Assigned(hSession) then
begin
hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0);
if Assigned(hService) then
try
while True do
begin
dwBytesRead := 1024;
InternetReadFile(hService, @lpBuffer, 1024, dwBytesRead);
if dwBytesRead = 0 then break;
lpBuffer[dwBytesRead] := #0;
Form1.Memo1.Lines.Add(lpBuffer);
end;
Result := True;
finally
InternetCloseHandle(hService);
end;
end;
finally
InternetCloseHandle(hSession);
end;
end;
Dmitrij_K (2007-03-04 00:08:00) [4]URLDownLoadToFile
UrlMon.pas
DVM (2007-03-03 23:39:00) [5]
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Text :=idhttp1.Get(' http://www.delphimaster.ru/cgi-bin/forum.pl?id=1172953711&n=18');
end;