unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, httpsend, ssl_openssl, ssl_openssl_lib;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function StreamToStr(AStream : TMemoryStream) : string;
begin
Result := '';
if AStream.Size > 0 then
begin
SetLength(Result, AStream.Size);
AStream.Read(PChar(Result)^, Length(Result));
Result := UTF8ToAnsi(Result);
end;
end;
procedure TForm1.FormShow(Sender: TObject);
var
SynHttp : THttpSend;
DocStr : String;
begin
SynHttp := THttpSend.Create;
with SynHttp do
begin
KeepAlive := True;
Protocol := '1.1';
MimeType := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
UserAgent := 'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0';
AddPortNumberToHost := False;
HTTPMethod('GET', 'https://zalukaj.com/');
DocStr := StreamToStr(Document);
Form1.Memo1.Lines.Add(DocStr);
Free;
end;
end;
end.
Jak w temacie. Można dodać referer https://zalukaj.com/index.html, ale , gdy patrzyłem na HttpAnalyzer, , to niepotrzebny. Dodam, że strona https://www.google.com się pobiera, czyli wszystko jest, co potrzeba. Strona pobiera się też w pythonie.
W załączniku jest cały programik testowy.
- test.rar (4 MB) - ściągnięć: 133