procedure TForm1.Button1Click(Sender: TObject);
const
BaseURL = 'http://www.cityin.cn/bbs/'; //论坛所在地址
UserName = 'speari'; //登录用户名
Password = '111111'; //登录密码
CookieNone = 0; //不保留Cookie
CookieDay = 1; //保留Cookie一天
CookieMonth = 2; //保留Cookie一月
CookieYear = 3; //保留Cookie一年
UserNormal = 2; //正常登录
UserHidden = 1; //隐身登录
BoardID = 2; //DVBBS中的灌水乐园,其他只用知道版块号即可,也可根据得到的页面自动提取版块号
var
Params: TStrings;
HTML: String;
MD5Pass: String;
p1,p2: Integer;
begin
Params:=TStringList.Create;
try
Params.Add('username='+UserName);
Params.Add('password='+Password);
Params.Add('CookieDate='+InttoStr(CookieNone));
Params.Add('userhidden='+InttoStr(UserNormal));
Params.Add('comeurl='+BASEURL+'index.asp');
HTML:=IdHttp1.Post(BaseURL+'login.asp?action=chk',Params);
if Pos(BASEURL+'index.asp',HTML)=0 then
begin
ShowMessage('登录失败');
Exit;
end;
HTML:=IdHttp1.Get(BASEURL+'announce.asp?boardid='+InttoStr(BoardID));
p1:=Pos('Dvbbs.MemberWord=''',HTML);
if p1=0 then
begin
ShowMessage('获取HTML失败!');
Exit;
end;
Inc(p1,18);
p2:=PosEx('',HTML,p1);
MD5Pass:=Copy(HTML,p1,p2-p1);
Params.Clear;
Params.Add('followup=');
Params.Add('rootID=');
Params.Add('star=');
Params.Add('TotalUseTabl=');
Params.Add('upfilerename=');
Params.Add('username='+UserName);
Params.Add('passwd='+MD5Pass);
Params.Add('font='+'[灌水]');
Params.Add('subject='+'测试,请版主删除!'); //发帖标题,不得超过 25 个汉字或50个英文字符
Params.Add('Expression='+'face1.gif'); //发帖心情,请自行查阅心情图片名称
Params.Add('Content='+'测试,请版主删除!'+#13#10+'测试内容'); //发帖内容
Params.Add('emailflag='+'yes'); //有回复时使用邮件通知您?
Params.Add('signflag='+'yes'); //是否显示您的签名?
IdHttp.Request.Referer:=BASEURL+'announce.asp?boardid='+InttoStr(BoardID);
HTML:=IdHttp1.Post(BaseURL+'Saveannounce.asp?boardID='+InttoStr(BoardID),Params);
if Pos('错误信息',HTML)>0 then
ShowMessage('发帖不成功!')
else
ShowMessage('发帖成功!');
finally
Params.Free;
end;
{var
strMsg:string;
S:TStringList;
begin
idHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
S := TStringList.Create;
S.Add('user='+edit1.text);
S.Add('pass='+edit2.text);
try
strMsg:=idHTTP1.Post('http://www.cityin.cn/bbs/dispbbs.asp?boardID=102&ID=192254&star=234', S);
memo1.Text:=strmsg;
finally
idHTTP1.Free;
end;}
end;
//http://www.cityin.cn/bbs/dispbbs.asp?boardID=102&ID=192254&star=234
end.
以上是我试写的,但HTML没看明白,硬是没成功啊,谁帮解决一下谢谢了,我每天上来一次的。