Delphi Idhttp Post Question ذات الصلة
سؤال
أنا جديد على دلفي. وأيضًا جديدًا تقريبًا في عالم البرمجة.
لقد صنعت بعض البرامج البسيطة التي تستخدم وحدة IDHTTP.
ولكن عند تنفيذها ، فإنه لا يعمل بشكل صحيح.
هذا البرنامج البسيط هو التحقق من حالة حسابي.
إذا نجحت تسجيل الدخول في الحساب إلى إرجاع بعض التعليمات البرمجية المصدر التي تتضمن "top.location = '
في المصدر ، وإذا فشل تسجيل الدخول ، فلا يتم إرجاعه "top.location = '
Inside Account.txt متابعة أول حساب وحساب ثالث كان حسابًا
ولكن يمكن فقط للتحقق من الحساب الأول ، بعد أول حساب لا يمكن للتحقق من الحساب الآخر
ليس لدي أي فكرة عن الخطأ في ذلك
PH896011 PK1089
FSADFASDF DDDDDSS
PH896011 PK1089
فيما يلي مصدر دلفي
إذا كان هناك من يساعدني كثيرا!
UNIT1 ؛
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, IdCookieManager, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
IdCookieManager1: TIdCookieManager;
lstAcct: TListBox;
result: TLabel;
Edit1: TEdit;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
//procedure FormCreate(Sender: TObject);
//procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
AccList: TStringList;
IdCookie: TIdCookieManager;
CookieList: TList;
StartCnt: Integer;
InputCnt: Integer;
WordList: TStringList;
WordNoList: TStringList;
WordCntList: TStringList;
StartTime: TDateTime;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
//temp: String;
lsttemp: TStringList;
sl : tstringlist;
//userId,userPass: string;
begin
InputCnt:= 0;
WordList := TStringList.Create;
CookieList := TList.create;
IdCookie := TIdCookieManager.Create(self);
if FileExists(ExtractFilePath(Application.ExeName) + 'account.txt') then
WordList.LoadFromFile(ExtractFilePath(Application.ExeName) + 'account.txt');
WordNoList:= TStringList.Create;
WordCntList := TStringList.Create;
lsttemp := TStringList.create;
sl :=Tstringlist.Create;
try
try
for i := 0 to WordList.Count -1 do
begin
ExtractStrings([' '], [' '], pchar(WordList[i]), lsttemp);
WordNoList.add(lsttemp[0]);
//ShowMessage(lsttemp[0]);
WordCntList.add(lsttemp[1]);
//ShowMessage(lsttemp[1]);
sl.Add('ID='+ lsttemp[0]);
sl.add('PWD=' + lsttemp[1]);
sl.add('SECCHK=0');
IdHTTP1.HandleRedirects := True;
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
memo1.Text:=idhttp1.Post('http://user.buddybuddy.co.kr/Login/Login.asp',sl);
if pos('top.location =',Memo1.Text)> 0 then
begin
application.ProcessMessages;
ShowMessage('Alive Acc!');
//result.Caption := 'alive acc' ;
sleep(1000);
Edit1.Text := 'alive acc';
lsttemp.Clear;
Memo1.Text := '';
//memo1.Text := IdHTTP1.Get('https://user.buddybuddy.co.kr/Login/Logout.asp');
Sleep(1000);
end;
if pos('top.location =', memo1.Text) <> 1 then
begin
application.ProcessMessages;
ShowMessage('bad');
Edit1.Text := 'bad';
//edit1.Text := 'bad';
lsttemp.Clear;
memo1.Text := '';
sleep(1000) ;
end;
Edit1.Text := '';
end;
finally
lsttemp.free;
end;
StartCnt := lstAcct.items.Count;
StartTime := Now;
finally
sl.Free;
end;
end;
end.
المحلول
قبل:
sl.Add('ID='+ lsttemp[0]);
يفعل:
sl.Clear;
في التشغيل الأول ، يحمل "SL" معلمتي المنشورتين ، ولكن ما لم تقم بمسحها في المدى الثاني ، فأنت تستمر فقط في إضافة معلمات ، مما يربك خادم HTTP الذي تحاول الاتصال به!
قد لا تكون هذه مشكلتك الوحيدة ، ولكن هذه بالتأكيد واحدة من المشاكل.