
31.05.2012, 18:14
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
captcha не нужна:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
AStrings: TStrings;
ACookie: String;
begin
AStrings:=TStringList.Create;
try
IdHTTP1.HandleRedirects:=False;
IdHTTP1.Request.UserAgent:='Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';
IdHTTP1.Request.Host:='login.rutracker.org';
IdHTTP1.Request.Referer:='http://rutracker.org/forum/index.php';
IdHTTP1.Request.CustomHeaders.Add('Cookie: spylog_test=1');
AStrings.Add('login_username=username');
AStrings.Add('login_password=password');
AStrings.Add('login=Вход');
try
Memo1.Text:=IdHTTP1.Post('http://login.rutracker.org/forum/login.php', AStrings);
Memo1.Lines.SaveToFile('log.htm');
except
ACookie:=IdHTTP1.Response.RawHeaders.Values['Set-Cookie'];
IdHTTP1.CookieManager.CookieCollection.Clear;
IdHTTP1.Request.Clear;
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+ACookie);
Memo1.Text:=IdHTTP1.Get(IdHTTP1.Response.Location);
Memo1.Lines.SaveToFile('log.htm');
if Pos('>Выход</a>', Memo1.Text)>0 then ShowMessage('Okay');
end;
finally
AStrings.Free;
end;
end;
end.
__________________
Пишу программы за еду.
__________________
|