Top.Mail.Ru
Ответы

Программа-бот

Дополнен

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, ExtCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Button1: TButton;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
Button2: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Button3: TButton;
Timer1: TTimer;
Label14: TLabel;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
StrPage, ssylka:string;
Log:TstringList;

begin
ssylka:='http:/play.tegos.ru/login/';
Log:=TstringList.Create;
Log.Add('login='+Edit1.Text);
Log.Add('password='+Edit2.Text);
Log.Add('action=login');
Log.Add('enter=%D0%92%D0%BE%D0%B9%D1%82%D0%B8');
StrPage:=idhttp1.Post(ssylka,Log);
if pos ('MANIMI', StrPage) >0
then
Label1.Caption:= 'Авторизация успешна! '
else
Label1.Caption:= 'Ошибка авторизации';
Log.Free;
Edit1.Visible:=False;
Edit2.Visible:=False;
Label12.Visible:=False;
Label13.Visible:=False;
Label14.Visible:=False;
Button1.Visible:=False;
Button2.Visible:=True;
Button3.Visible:=True;
Label1.Visible:=True;
Label2.Visible:=True;
end;

Дополнен

procedure TForm1.Button2Click(Sender: TObject);
function Pars(T_, ForS, _T:string):string; //Ooieoey ia?neiaa
var a, b:integer;
begin
Result := '';
if (T_='') or (ForS='') or (_T='') then Exit;
a:=Pos(T_, ForS);
if a=0 then Exit else a:=a+Length(T_);
ForS:=Copy(ForS, a, Length(ForS)-a+1);
b:=Pos(_T, ForS);
if b>0 then
Result:=Copy(ForS, 1, b - 1);
end;
var
ssylka: TStrings;
res1, res2, res3, res4, time: String;
begin
Label3.Visible:=True;
Label4.Visible:=True;
Label5.Visible:=True;
Label6.Visible:=True;
Label7.Visible:=True;
Label8.Visible:=True;
Label9.Visible:=True;
Label10.Visible:=True;
Label14.Visible:=True;
Button2.Visible:=False;
ssylka := TStringList.Create;
ssylka.Text := IdHTTP1.Get('http:// mobilewar.play.tegos.ru/showFarms.do');
ssylka.Text := IdHTTP1.Get('http:// mobilewar.play.tegos.ru/showFarms.do');
res1:= Pars('

', ssylka.Text, '+');
res1:= Trim(res1);
Label4.Caption:= res1;
res2:= Pars('

', ssylka.Text, '+');
res2:= trim (res2);
Label6.Caption:= res2;
res3:= Pars('

', ssylka.Text, '+');
res3:= trim (res1);
Label8.Caption:= res3;
res4:= Pars('

', ssylka.Text, '+');
res4:= trim (res4);
Label10.Caption:= res4;
time:= Pars('Время:', ssylka.Text, '<');
time:= Trim(time);
Label14.Caption:= time;
memo1.Lines.Add('Ресурсы опрошены')

end;

Дополнен

procedure TForm1.Button3Click(Sender: TObject);
var
ssylka:string;
begin
ssylka:='http:// play.tegos.ru/logout/';
Edit1.Visible:=True;
Edit2.Visible:=True;
Label12.Visible:=True;
Label13.Visible:=True;
Button1.Visible:=True;
Button2.Visible:=False;
Button3.Visible:=False;
Label1.Visible:=False;
Label2.Visible:=False;
Label3.Visible:=False;
Label4.Visible:=False;
Label5.Visible:=False;
Label6.Visible:=False;
Label7.Visible:=False;
Label8.Visible:=False;
Label9.Visible:=False;
Label10.Visible:=False;
end;

Дополнен

procedure TForm1.Button4Click(Sender: TObject);
function Pars(T_, ForS, _T:string):string; //Ooieoey ia?neiaa
var a, b:integer;
begin
Result := '';
if (T_='') or (ForS='') or (_T='') then Exit;
a:=Pos(T_, ForS);
if a=0 then Exit else a:=a+Length(T_);
ForS:=Copy(ForS, a, Length(ForS)-a+1);
b:=Pos(_T, ForS);
if b>0 then
Result:=Copy(ForS, 1, b - 1);
end;
var
Response: TStrings;
res1, res2, res3, res4, time,siti0,idsiti0,siti1,idsiti1,siti2,idsiti2,siti3,idsiti3,siti4,idsiti4,idsiti5,siti5: string;
begin
Response := TStringList.Create;
Response.Text := IdHTTP1.Get('http:// mobilewar1.play.tegos.ru/showTown.do');
siti0:= Pars('cityChoose">', Response.Text, '');
idsiti0:= Trim( copy(siti0,16,5));
Memo1.Lines.Add(idsiti0);
siti1:= Pars(siti0+'', Response.Text, '');
idsiti1:= Trim( copy(siti1,18,5));
Memo1.Lines.Add(idsiti1);
siti2:= Pars(siti1+'', Response.Text, '');
idsiti2:= Trim( copy(siti2,18,5));
Memo1.Lines.Add(idsiti2);
siti3:= Pars(siti2+'', Response.Text, '');
idsiti3:= Trim( copy(siti3,18,5));
Memo1.Lines.Add(idsiti3);
siti4:= Pars(siti3+'', Response.Text, '');
idsiti4:= Trim( copy(siti4,18,5));
Memo1.Lines.Add(idsiti4);
end;

end.

Дополнен

помогите дописать код на второй батон - нужно зациклить ее процедуру с интервалом в 1 минуту

По дате
По рейтингу
Аватар пользователя
Мудрец
11лет

найти ошибку?

Аватар пользователя
Мастер
11лет

нет, помочь реализовать цикл на второй батон с интервалом 1 минута

Аватар пользователя
Ученик
11лет

То есть ты хочешь что бы код выполнялся через каждую секунду ?
Если да то есть компонент Timer.
http :// www. bzfar. net/ publ/komponent_delphi_timer/13-1-0-320
(УДАЛИ В ССЫЛКЕ ЛИШНИЕ ПРОБЕЛЫ)

Аватар пользователя
Мастер
11лет

через каждую минуту

Аватар пользователя
Ученик
11лет

Неважно в Timer можно задать любое время.



Видео по теме