我正在尝试向网站发送获取请求。问题是如果请求者是机器人,则网站正在重新定位
const _URL = 'https://www.URL.com/';
var
sSessionID:String;
Params: TStringList;
IdSSL: TIdSSLIOHandlerSocketOpenSSL;
begin
IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP1);
try
IdHTTP1.IOHandler := IdSSL;
IdHTTP1.AllowCookies := True;
IdHTTP1.HandleRedirects := True;
IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0';
IdHTTP1.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
IdHTTP1.Request.AcceptLanguage := 'en-GB,en;q=0.5';
IdHTTP1.Request.Connection := 'keep-alive';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
sSessionID := IdHTTP1.Get(_URL);
{....
extracting SessionID
Params.Add('SessionID=' + 'sSessionID');
IdHTTP1.Post(_URL, Params);
.....}
finally
IdSSL.Free;
end;
IdHTTP.get的结果是<!DOCTYPE html><head><META NAME="ROBOTS".....
空的,我无法获得会话 ID。
http 请求标头与我的浏览器发送的相同。