Пишу регер асеку, не могу получить куки в чем проблема, помогите? HTML: procedure TForm1.Button1Click (Sender : TObject); var file1: textfile; i: integer; link: String; Idhttp1 : TIdHttp; IdHandler: TIdSSlIOHandlerSocketOpenSSl; p : Integer; stream : TFileStream; begin Button1.Enabled := false; Button3.Enabled := false; idhttp1 := Tidhttp.Create(nil); IdHandler := TIdSSLIOHandlerSocketOpenSSl.create(nil); IdSSLIOHandlerSocketOpenSSL1VerifyPeer ; Idhttp1.IOHandler := IDHandler; cook:= TIdCookieManager.Create(idHttp1); IdHttp1.CookieManager := cook; Idhttp1.Request.ContentType := 'application/x-www-form-urlencoded'; IdHttp1.Request.Host:='www.icq.com:443'; IdHttp1.Request.Referer:= 'https://www.icq.com/register/'; IdHttp1.Request.UserAgent:='Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10'; IdHttp1.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; IdHttp1.Request.AcceptLanguage:='ru,en-us;q=0.7,en;q=0.3'; //IdHttp1.Request.RawHeaders.Values['Keep-Alive']:='115'; IdHttp1.Request.AcceptCharSet:='iso-8859-1, utf-8, utf-16, *;q=0.1'; IdHttp1.Request.Connection:='keep-alive'; IDHttp1.HandleRedirects := true; Idhttp1.AllowCookies := true; try s := idhttp1.get('https://www.icq.com:443/register'); finally end; ch := Copy(s , p+15 , 96); l ink := 'https://www.icq.com/img/aa_img.php?gnm=' + ch; p := pos('icq_ln', s); t := copy(s, p+15, 64); stream := TFileStream.Create(extractfilepath(paramstr(0)) + '\captcha.jpg', fmcreate); try idhttp1.get(link, stream); finally end; stream.free; image1.Picture.LoadFromFile (extractfilepath(paramstr(0)) + 'captcha.jpg'); Button3.Enabled := true; end; procedure TForm1.Button3Click (Sender : TObject); var multi: TStringList; str: String; file1: TextFile; i: Integer; cook_ic: String; begin Button1.Enabled := False; Button3.Enabled := False; idhttp1 := Tidhttp.Create(nil); IdHandler := TIdSSLIOHandlerSocketOpenSSl.create(nil); Idhttp1.IOHandler := IDHandler; IDHttp1.HandleRedirects := true; Idhttp1.AllowCookies := true; IdHttp1.Request.Host:='www.icq.com'; IdHttp1.Request.UserAgent:='Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10'; IdHttp1.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; IdHttp1.Request.AcceptLanguage:='ru,en-us;q=0.7,en;q=0.3'; IdHttp1.Request.AcceptCharSet:='windows-1251,utf-8;q=0.7,*;q=0.7'; IdHttp1.Request.Connection:='keep-alive'; IdHttp1.Request.Referer := 'https://www.icq.com/register/'; IdHttp1.Request.ContentLength := 400; multi.Add('service=30'); multi.Add('icq_ln='+t); multi.Add('nickname='+ Edit1.Text); multi.Add('fname='+edit2.Text); multi.Add('lname='+Edit3.Text); multi.Add('email='+ Edit4.Text); multi.Add('password='+ Edit6.Text); Multi.Add('password_confirm='+ Edit6.Text); multi.Add('qa1='+ ComboBox2.Text); multi.Add('answer1='+ Edit9.Text); multi.Add('word='+ Edit10.text); multi.Add('lang=en'); multi.Add('gnm='+ch); str := idhttp1.post ('https://www.icq.com/register/index.php', multi); end; Пробовал в ручную прописывать куки так: HTML: idhttp1.CookieManager.CookieCollection.AddsrcCookie('geo=7;'); idhttp1.CookieManager.CookieCollection.AddsrcCookie('icq_ln='+t+';'); idhttp1.CookieManager.CookieCollection.AddsrcCookie('icq_lang=ru;'); idhttp1.CookieManager.CookieCollection.AddsrcCookie('s_cc=true;'); idhttp1.CookieManager.CookieCollection.AddsrcCookie('s_sq=aolwpicq%3D%2526pid%253Dicq%252520%25253A%252520Help%252520- %252520Registration%252520-%252520Index%2526pidt%253D1%2526oid%253DSubmit%2526oidt%253D3%2526ot%253DSUBMIT;'); Все равно регистрация не происходит
нажимаешь на кнопку Button1: создается idhttp1 и не освобождается!!! А при нажатии на Button3 снова создаешь. Зачем такой геморрой. Лучше уж сделай idhttp1 глобальным и не создавай во второй раз и не придется куки вручную добавлять. P.S. версия Indy должна быть 10.*
Версия инди 10, ZdezBilYa, дело в том что, при нажатии Button1 куки не приходят с сайта, то есть CookieManager.CookieCollection пустое. Отсуда 2 вопроса, 1)почему они могут не приходить(не устанавливаться). 2) Почему даже когда я устанавливаю их в ручную они регистрация все равно не происходит? переменная cook глобальная.
А насчет, почему CookieManager пустой, не знаю) Я при регистрации его вообще не подключал, хватало AllowCookies. Я-то советую сделать глобальным idhttp1. А то создаешь, не удаляешь, потом по новой создаешь
Да, вот запрос страницы регистрации: Code: with HTTP.Request do begin UserAgent:='Opera/9.80 (Windows NT 6.0; U; ru) Presto/2.2.15 Version/10.10'; Host:='icq.com'; Accept:='text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1'; AcceptLanguage:='ru-RU,ru;q=0.9,en;q=0.8'; AcceptCharset:='iso-8859-1, utf-8, utf-16, *;q=0.1'; ContentType:='application/x-www-form-urlencoded'; end; IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method:=sslvSSLv23; Http.IOHandler:=IdSSLIOHandlerSocketOpenSSL1; HTTP.HandleRedirects:=true; HTTP.AllowCookies:=true; HTTP.Get('https://www.icq.com/register/');
То есть получается получать-отсылать куки не обязательно? Если да то почему в моем примере не происходит регистрация, поля заполняю вроде все, в ответ на пост приходит страница с ошибкой...
Еще одна проблема, сниффер не сниффает мое приложение%) использую HttpAnalyze v5. В чем может быть дело?