Написал спамер, но с отправкой капчи проблема.Первый раз капча отправляется на сервер нормально, а второй раз когда капча вылетает программа останавливается. Отправляет пост запрос(Отмечено зеленым), получает {"ok":-2,"captcha_sid":"786535411050","text":"Enter code","difficult":0} и останавливается. В чем я допустил ошибку? Code: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, IdCookieManager, XPMan, jpeg, StrUtils, IdMultipartFormData, SyncObjs, ExtCtrls; type TForm1 = class(TForm) IdHTTP1: TIdHTTP; IdCookieManager1: TIdCookieManager; XPManifest1: TXPManifest; Memo1: TMemo; Memo4: TMemo; Edit1: TEdit; Edit2: TEdit; Memo2: TMemo; CheckBox1: TCheckBox; Edit5: TEdit; Edit6: TEdit; Button1: TButton; Image1: TImage; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; TNewThread = class(TThread) private protected procedure Execute; override; end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} function recognize(filename: string; apikey: string; is_phrase: boolean; is_regsense: boolean; is_numeric: boolean; min_len: integer; max_len: integer): string; var ftype,tmpstr,captcha_id: String; i: integer; http: TIdHTTP; multi: Tidmultipartformdatastream; begin if FileExists(filename)=false then begin result:='ERROR: file not found'; exit; end; ftype:='image/pjpeg'; if strpos(Pchar(filename),'jpg')<>nil then ftype:='image/pjpeg'; if strpos(Pchar(filename),'gif')<>nil then ftype:='image/gif'; if strpos(Pchar(filename),'png')<>nil then ftype:='image/png'; multi:=Tidmultipartformdatastream.Create; multi.AddFormField('method','post'); multi.AddFormField('key',apikey); multi.AddFile('file',filename,ftype); if is_phrase=true then multi.AddFormField('phrase','1'); if is_regsense=true then multi.AddFormField('regsense','1'); if is_numeric=true then multi.AddFormField('numeric','1'); if min_len>0 then multi.AddFormField('min_len',inttostr(min_len)); if max_len>0 then multi.AddFormField('max_len',inttostr(max_len)); http:=TIdHTTP.Create(nil); tmpstr:=http.Post('http://antigate.com/in.php',multi); http.Free; captcha_id:=''; if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end; if strpos(Pchar(tmpstr),'OK|')<>nil then captcha_id:=AnsiReplaceStr(tmpstr,'OK|',''); if captcha_id='' then result:='ERROR: bad captcha id'; for i:=0 to 20 do begin Application.ProcessMessages; sleep(5000); http:=TIdHttp.Create(nil); tmpstr:=http.Get('http://antigate.com/res.php?key='+apikey+'&action=get&id='+captcha_id); http.Free; if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end; if strpos(Pchar(tmpstr),'OK|')<>nil then begin result:=AnsiReplaceStr(tmpstr,'OK|',''); exit; end; end; end; procedure TNewThread.Execute; var a,b : TStringList; s,p : string; naa,aba,i,iy : integer; kaa,sid,y : string; na,ab,o,ui,io : integer; str1,str2,str4,str5,hash1 : string; ka,keyc : string; MS : TMemoryStream; Jpg : TJpegImage; begin b:=TStringList.Create; a:=TStringList.Create; Ms := TMemoryStream.Create; Jpg := TJpegImage.Create; a.Add('act=login'); a.Add('email='+Form1.Edit1.Text); a.Add('pass='+Form1.Edit2.Text); b.Text:=Form1.IdHTTP1.Post('http://login.vk.com/',a); s:=copy(b.Text,285,56); a.Clear; b.Clear; a.Add('s='+s); a.Add('op=slogin'); b.Text:=Form1.IdHTTP1.Post('http://vkontakte.ru/login.php',a); a.Clear; b.Clear; Form1.IdHTTP1.Request.CustomHeaders.Add('Cookie: remixsid='+s); b.Text:=Form1.IdHTTP1.Get('http://vkontakte.ru/profile.php'); b.Clear; a.Clear; B.Text:=Form1.IdHTTP1.Get('http://vkontakte.ru/friends_ajax.php') ; y:=b.Text; repeat Delete(y,1,50); o:=pos(',[',y)+2; ui:=pos(',"',y); io:=ui-o; p:=(copy(y,o,io)); Form1.Memo4.Lines.Add(p) ; y:=copy(y,o,length(y)); until (pos(',[',y)=0); Iy := 0; while Form1.Memo4.Lines.Count <> Iy do begin if (Form1.Memo4.Lines[Iy] <> '') and (Trim(Form1.Memo4.Lines[Iy]) <> '') then Inc(Iy) else Form1.Memo4.Lines.Delete(Iy); end; b.Clear; a.Clear; for i:=0 to Form1.Memo4.Lines.Count-1 do begin b.Text:=Form1.idhttp1.Get('http://vkontakte.ru/id'+Form1.Memo4.Lines[i]); naa:=pos('decodehash(',b.Text)+12; kaa:=copy(b.Text,naa,100); aba:=pos(')',kaa)-1; Delete(kaa,aba,100); str1:=copy(kaa,5,27); str2:=copy(kaa,35,5); str4:=ReverseString(str1); str5:=ReverseString(str2); hash1:=str4+str5; na:=pos('name="to_id" value="',b.Text)+20; ka:=copy(b.Text,na,50); ab:=pos('"',ka); Delete(ka,ab,50); a.Clear; b.Clear; a.Add('act=get10'); a.Add('wall_hash='+hash1); a.Add('wpage=100000'); a.Add('seed='+Form1.Memo2.Text+ ' to_'+ Form1.Memo4.Lines[i]); a.Add('fpage=1'); a.Add('mid='+ka); a.Add('n=3'); [COLOR=Lime]b.Text:=Form1.IdHTTP1.Post('http://vkontakte.ru/wall.php',a);[/COLOR] If Pos('captcha_sid', b.Text) <> 0 Then begin sid := b.Text; sid := Copy(sid, Pos('":"', sid) + 3, Length(sid)); Delete(sid, Pos(#34, sid), Length(sid)); Form1.IdHTTP1.Get('http://vkontakte.ru/captcha.php?s=1&sid=' + sid, Ms); Ms.Position := 0; Jpg.LoadFromStream(ms); Form1.Image1.Picture.Graphic := Jpg; Form1.Image1.Picture.SaveToFile('1.jpg'); Jpg.Free; Ms.Free; b.Clear; a.Clear; keyc:=recognize(Form1.Edit6.Text,Form1.Edit5.Text,false,true,false,0,0); sleep(5000); a.Add('act=get10'); a.Add('wall_hash='+hash1); a.Add('wpage=100000'); a.Add('seed='+Form1.Memo2.Text+ ' to_'+ Form1.Memo4.Lines[i]); a.Add('fpage=1'); a.Add('mid='+ka); a.Add('n=3'); a.Add('captcha_sid=' + sid); a.Add('captcha_key=' + keyc); b.Text:=Form1.IdHTTP1.Post('http://vkontakte.ru/wall.php',a); a.Clear; b.Clear; end; end; end; procedure TForm1.Button1Click(Sender: TObject); var NewThread: TNewThread; begin NewThread:=TNewThread.Create(true); NewThread.FreeOnTerminate:=true; NewThread.Priority:=tpLower; NewThread.Resume; end; end.
Чють переделал, теперь он после вывода изображения в image останавливается, не сохраняя это изображение.Подозреваю что функция отправки капчи использует изображение и оно не удалается, не сохраняется сново. Вот что вылазит Code: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, IdCookieManager, XPMan, jpeg, StrUtils, IdMultipartFormData, SyncObjs, ExtCtrls; type TForm1 = class(TForm) IdHTTP1: TIdHTTP; IdCookieManager1: TIdCookieManager; XPManifest1: TXPManifest; Memo1: TMemo; Memo4: TMemo; Edit1: TEdit; Edit2: TEdit; Memo2: TMemo; CheckBox1: TCheckBox; Edit5: TEdit; Edit6: TEdit; Button1: TButton; Image1: TImage; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; TNewThread = class(TThread) private protected procedure Execute; override; end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} function recognize(filename: string; apikey: string; is_phrase: boolean; is_regsense: boolean; is_numeric: boolean; min_len: integer; max_len: integer): string; var ftype,tmpstr,captcha_id: String; i: integer; http: TIdHTTP; multi: Tidmultipartformdatastream; begin if FileExists(filename)=false then begin result:='ERROR: file not found'; exit; end; ftype:='image/pjpeg'; if strpos(Pchar(filename),'jpg')<>nil then ftype:='image/pjpeg'; if strpos(Pchar(filename),'gif')<>nil then ftype:='image/gif'; if strpos(Pchar(filename),'png')<>nil then ftype:='image/png'; multi:=Tidmultipartformdatastream.Create; multi.AddFormField('method','post'); multi.AddFormField('key',apikey); multi.AddFile('file',filename,ftype); if is_phrase=true then multi.AddFormField('phrase','1'); if is_regsense=true then multi.AddFormField('regsense','1'); if is_numeric=true then multi.AddFormField('numeric','1'); if min_len>0 then multi.AddFormField('min_len',inttostr(min_len)); if max_len>0 then multi.AddFormField('max_len',inttostr(max_len)); http:=TIdHTTP.Create(nil); tmpstr:=http.Post('http://antigate.com/in.php',multi); http.Free; captcha_id:=''; if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end; if strpos(Pchar(tmpstr),'OK|')<>nil then captcha_id:=AnsiReplaceStr(tmpstr,'OK|',''); if captcha_id='' then result:='ERROR: bad captcha id'; for i:=0 to 20 do begin Application.ProcessMessages; sleep(5000); http:=TIdHttp.Create(nil); tmpstr:=http.Get('http://antigate.com/res.php?key='+apikey+'&action=get&id='+captcha_id); http.Free; if strpos(Pchar(tmpstr),'ERROR_')<>nil then begin result:=tmpstr; exit; end; if strpos(Pchar(tmpstr),'OK|')<>nil then begin result:=AnsiReplaceStr(tmpstr,'OK|',''); exit; end; end; end; procedure TNewThread.Execute; var a,b : TStringList; s,p : string; naa,aba,i,iy : integer; kaa,sid,y : string; na,ab,o,ui,io : integer; str1,str2,str4,str5,hash1 : string; ka,keyc : string; MS : TMemoryStream; Jpg : TJpegImage; begin b:=TStringList.Create; a:=TStringList.Create; a.Add('act=login'); a.Add('email='+Form1.Edit1.Text); a.Add('pass='+Form1.Edit2.Text); b.Text:=Form1.IdHTTP1.Post('http://login.vk.com/',a); s:=copy(b.Text,285,56); a.Clear; b.Clear; a.Add('s='+s); a.Add('op=slogin'); b.Text:=Form1.IdHTTP1.Post('http://vkontakte.ru/login.php',a); a.Clear; b.Clear; Form1.IdHTTP1.Request.CustomHeaders.Add('Cookie: remixsid='+s); b.Text:=Form1.IdHTTP1.Get('http://vkontakte.ru/profile.php'); b.Clear; a.Clear; B.Text:=Form1.IdHTTP1.Get('http://vkontakte.ru/friends_ajax.php') ; y:=b.Text; repeat Delete(y,1,50); o:=pos(',[',y)+2; ui:=pos(',"',y); io:=ui-o; p:=(copy(y,o,io)); Form1.Memo4.Lines.Add(p) ; y:=copy(y,o,length(y)); until (pos(',[',y)=0); Iy := 0; while Form1.Memo4.Lines.Count <> Iy do begin if (Form1.Memo4.Lines[Iy] <> '') and (Trim(Form1.Memo4.Lines[Iy]) <> '') then Inc(Iy) else Form1.Memo4.Lines.Delete(Iy); end; b.Clear; a.Clear; for i:=0 to Form1.Memo4.Lines.Count-1 do begin b.Text:=Form1.idhttp1.Get('http://vkontakte.ru/id'+Form1.Memo4.Lines[i]); naa:=pos('decodehash(',b.Text)+12; kaa:=copy(b.Text,naa,100); aba:=pos(')',kaa)-1; Delete(kaa,aba,100); str1:=copy(kaa,5,27); str2:=copy(kaa,35,5); str4:=ReverseString(str1); str5:=ReverseString(str2); hash1:=str4+str5; na:=pos('name="to_id" value="',b.Text)+20; ka:=copy(b.Text,na,50); ab:=pos('"',ka); Delete(ka,ab,50); a.Clear; b.Clear; a.Add('act=get10'); a.Add('wall_hash='+hash1); a.Add('wpage=100000'); a.Add('seed='+Form1.Memo2.Text+ ' to_'+ Form1.Memo4.Lines[i]); a.Add('fpage=1'); a.Add('mid='+ka); a.Add('n=3'); b.Text:=Form1.IdHTTP1.Post('http://vkontakte.ru/wall.php',a); If Pos('captcha_sid', b.Text) <> 0 Then begin Ms := TMemoryStream.Create; Jpg := TJpegImage.Create; sid := b.Text; sid := Copy(sid, Pos('":"', sid) + 3, Length(sid)); Delete(sid, Pos(#34, sid), Length(sid)); Form1.IdHTTP1.Get('http://vkontakte.ru/captcha.php?s=1&sid=' + sid, Ms); Ms.Position := 0; Jpg.LoadFromStream(ms); [COLOR=Lime]Form1.Image1.Picture.Graphic := Jpg;[/COLOR] Form1.Image1.Picture.SaveToFile('1.jpg'); ms.Free; jpg.Free; b.Clear; a.Clear; keyc:=recognize(Form1.Edit6.Text,Form1.Edit5.Text,false,true,false,0,0); form sleep(5000); DeleteFile('1.jpg'); a.Add('act=get10'); a.Add('wall_hash='+hash1); a.Add('wpage=100000'); a.Add('seed='+Form1.Memo2.Text+ ' to_'+ Form1.Memo4.Lines[i]); a.Add('fpage=1'); a.Add('mid='+ka); a.Add('n=3'); a.Add('captcha_sid=' + sid); a.Add('captcha_key=' + keyc); b.Text:=Form1.IdHTTP1.Post('http://vkontakte.ru/wall.php',a); a.Clear; b.Clear; end; end; end; procedure TForm1.Button1Click(Sender: TObject); var NewThread: TNewThread; begin NewThread:=TNewThread.Create(true); NewThread.FreeOnTerminate:=true; NewThread.Priority:=tpLower; NewThread.Resume; end; end.
Все решил проблему, надо было очистить переменую в которую добавляется файл.Теперь вопрос, как правильно остановить мою программу, а потом продолжить с места остановки.Сделать это на две кнопки стоп, продолжить.
а терь сделайте еще мне дизайн, поставте мой копирайт и создайте тему в "Покупка, продажа, услуги в соц. сетях"