![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Пытаюсь авторизоваться на форуме rutracker.org, ничего не получается.
1. Нажимаю кнопку получения капчи 2. ввожу текст с капчи в едитбокс 3. нажимаю на кнопку 2 И нифига не логинится. Где бага? Код:
const
link: string = 'http://login.rutracker.org/forum/login.php';
mylogin='логин';
mypass='пароль';
var
Form1: TForm1;
Txt: string;
cap : Boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
C_Url='http://static.rutracker.org/captcha/0/';
var
ris,txt1,ss,lres:string;
sPos, fPos,spos1,fpos1,lpos,lpos2: Integer;
ltxt,ltxt1: Integer;
lStream: TMemoryStream;
jpg: TJPEGImage;
s : TStringList;
begin
txt := HTTP1.Get(link);
s := TStringList.Create;
s.Text := txt;
S.SaveToFile('file.html');
s.Free;
sPos := Pos(C_Url, txt);
if sPos > 0 then
begin
cap := True;
ltxt := Length(C_Url);
Inc(sPos, ltxt);
fPos := sPos;
while (fPos <= ltxt) and (txt[sPos] <> '"') do
Inc(fPos);
ris:=Copy(txt, sPos, 39);
if ris <> '' then
begin
lStream := TMemoryStream.Create;
jpg := TJPEGImage.Create;
try
HTTP2.Get(C_Url + ris , lStream);
lStream.Position := 0;
Jpg.LoadFromStream(lStream);
Image1.Picture.Bitmap.Assign(JPG);
finally
jpg.Free;
lStream.Free;
end;
end;
end
else Cap := False; //ShowMessage('Капчи нет!');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Tst:TStringList;
cookie_test,cap_sid,cap_code: string;
begin
Tst:=TStringList.Create;
if Cap then
begin
cap_sid:=copy(txt,pos('cap_sid', txt) + 15, 21);
cap_code:=copy(txt,pos('cap_code', txt), 41);
end;
Tst.Add('login_username='+mylogin);
tst.Add('login_password='+mypass);
tst.Add('ses_short=1');
// tst.Add('auth_remember=ok');
if cap then
begin
tst.Add('cap_sid=' + cap_sid);
tst.Add(cap_code + '=' + Edit1.Text);
end;
tst.Add('login=Вход');
Txt := Http1.Post(link, tst);
tst.Text:=txt;
tst.SaveToFile('page.html');
If Pos('>Выход</a>', Txt)>0 then
ShowMessage('УРА!!') else ShowMessage('БЛ*ТЬ');
Tst.Free;
Http1.Disconnect;
end; |
|
#2
|
||||
|
||||
|
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.Последний раз редактировалось NumLock, 31.05.2012 в 18:17. |