我正在尝试登录一个网站,但是该网站总是回复:
“您似乎不接受 cookie。需要 cookie 才能登录。”
为什么我的程序不允许使用 cookie?
function HF_Login(): boolean;
var
HTTP : TIDHTTP;
Cookie : TidCookieManager;
Data, Page : TStringList;
begin
HTTP := TIDHTTP.Create(NIL);
Cookie := TidCookieManager.Create(NIL);
HTTP.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1';
HTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
HTTP.Request.AcceptLanguage := 'en-us;q=0.7,en;q=0.3';
HTTP.Request.AcceptCharSet := 'windows-1251,utf-8;q=0.7,*;q=0.7';
HTTP.Request.Pragma := 'no-cache';
HTTP.Request.CacheControl := 'no-cache';
HTTP.Request.RawHeaders.Add('X-Requested-With: XMLHttpRequest');
HTTP.AllowCookies := True;
HTTP.HandleRedirects := True;
HTTP.ProtocolVersion := pv1_1;
HTTP.Request.Connection := 'Keep-Alive';
HTTP.CookieManager := Cookie;
Data := TStringList.Create;
Page := TStringList.Create;
// returnto=%2F&user=[user]&pass=[pass]
Data.Add('returnto=%2F&user=csz0021&pass=Yese0071');
page.Text := HTTP.Post('http://hotfile.com/login.php', Data);
//form1.RichEdit1.Text := HTTP.Post('http://hotfile.com/login.php', Data);
If Pos('Bad username/password combination.', Page.Text) <> 0 Then Result := False
else Result := True;
Page.Free;
Data.Free;
end;
这是一个用于测试网站的免费账户。
csz0021
Yese0071
谢谢。