绿
绿人
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我写的论坛自动登陆代码,但总是登陆不成功,不知道问题出在哪里?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP: TIdHTTP;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
BaseURL = 'http://bbs.hangzhou.com.cn/'; //论坛所在地址
UserName = ''; //登录用户名
Password = ''; //登录密码
var
Params: TStrings;
HTML: String;
MD5Pass: String;
p1,p2: Integer;
begin
Params:=TStringList.Create;
Params.Add('username='+UserName);
Params.Add('password='+Password);
Params.Add('cookietime='+InttoStr(CookieNone));
Params.Add('comeurl='+BASEURL+'logging.php?action=login');
HTML:=IdHttp.Post(BaseURL+'logging.php?action=login',Params);
if Pos(BASEURL+'index.php',HTML)=0 then
begin
ShowMessage('登录失败');
Exit;
end
else
ShowMessage('登陆成功');
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP: TIdHTTP;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
BaseURL = 'http://bbs.hangzhou.com.cn/'; //论坛所在地址
UserName = ''; //登录用户名
Password = ''; //登录密码
var
Params: TStrings;
HTML: String;
MD5Pass: String;
p1,p2: Integer;
begin
Params:=TStringList.Create;
Params.Add('username='+UserName);
Params.Add('password='+Password);
Params.Add('cookietime='+InttoStr(CookieNone));
Params.Add('comeurl='+BASEURL+'logging.php?action=login');
HTML:=IdHttp.Post(BaseURL+'logging.php?action=login',Params);
if Pos(BASEURL+'index.php',HTML)=0 then
begin
ShowMessage('登录失败');
Exit;
end
else
ShowMessage('登陆成功');
end;
end.