|
|
导航: |
论坛 -> DELPHI技术
斑竹:liumazi,sephil |
|
作者: |
|
2010/4/10 9:39:10 |
标题: |
成功登陆Delphi盒子后如何自动发帖 |
浏览:2774 |
|
加入我的收藏 |
楼主: |
自动登陆Delphi盒子代码如下(delphi2010): procedure TMyThread.Execute; var code: string; done: Boolean; postList: TStrings; Response: TStringStream; begin Form1.Memo1.clear;
// 开始登录代码 Response := TStringStream.Create('', TEncoding.UTF8); postList := TStringList.Create; postList.add('membername=用户名'); postList.add('memberpass=密码'); postList.add('membercookie=1'); postList.add('act=1'); try Form1.IdHTTP2.HandleRedirects := True; Form1.IdHTTP2.HTTPOptions:=Form1.IdHTTP2.HTTPOptions+[hoKeepOrigProtocol];//关键这行 Form1.IdHTTP2.ProtocolVersion:= pv1_1; Form1.IdHTTP2.Request.Accept:='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml,application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'; Form1.IdHTTP2.Request.Referer:='http://bbs.2ccc.com/default.asp'; Form1.IdHTTP2.Request.AcceptLanguage:='zh-cn'; Form1.IdHTTP2.Request.ContentType:='application/x-www-form-urlencoded'; Form1.IdHTTP2.Request.AcceptEncoding:='gzip, deflate'; Form1.IdHTTP2.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)'; Form1.IdHTTP2.Request.Host:='bbs.2ccc.com'; //Form1.IdHTTP2.Request.ContentLength:=postList.Count; Form1.IdHTTP2.Request.Connection:='Keep-Alive'; Form1.IdHTTP2.Request.CacheControl:='no-cache'; Form1.IdHTTP2.AllowCookies := true;
Form1.IdHTTP2.Post('http://www.2ccc.com/login.asp', postList, Response); done := True; except done := false; end; if (done) and (Pos('200 OK', Form1.IdHTTP2.ResponseText) <> 0) then begin //code := Form1.IdHTTP2.Get('http://bbs.2ccc.com/default.asp'); //Form1.Memo1.lines.add(mycookie); //Cookie的值 Form1.Label1.Caption:='已经登录成功了啊!!!'; Form1.Label1.Update; { if(Pos('membername=用户名', code)>0) then begin Form1.Label1.Caption:='已经登录成功了啊!!!'; Form1.Label1.Update; end else begin Form1.Label1.Caption:='登录失败了啊!!!'; Form1.Label1.Update; end; }
end else begin Form1.mmo1.lines.add('logon error,error code:' + Form1.IdHTTP2.Response.RawHeaders.Text); end;
Response.Free; postList.Free;
end;
----------------------------------------------
- |
作者: |
|
2010/4/10 9:41:04 |
1楼: |
Const CRLF = #13#10; var done: Boolean; aStream: TMemoryStream; Params: TMemoryStream; S: String;
begin aStream := TMemoryStream.create; Params := TMemoryStream.Create; try S := '----------7da34b2e73079c' + CRLF + 'Content-Disposition: form-data; name="FID"' +CRLF + CRLF + '1'+ CRLF + '----------7da34b2e73079c' + CRLF + 'Content-Disposition: form-data; name="topicid"' +CRLF + CRLF + '351706' + CRLF + '----------7da34b2e73079c' + CRLF + 'Content-Disposition: form-data; name="topic_title"' +CRLF + CRLF + '3' + CRLF + '----------7da34b2e73079c' + CRLF + 'Content-Disposition: form-data; name="topic_content"' +CRLF + CRLF + 'AAAA'+ CRLF + '----------7da34b2e73079c' + CRLF + 'Content-Disposition: form-data; name="roomid"' +CRLF + CRLF + '1'+ CRLF + '----------7da6d19a076e' + CRLF + 'Content-Disposition: form-data; name="file1"; filename=""' + CRLF + 'Content-Type: application/octet-stream'+CRLF + CRLF + '----------7da34b2e73079c' + CRLF + 'Content-Disposition: form-data; name="url"' +CRLF + CRLF + '2ccc.com'+ CRLF + '----------7da6d19a076e--' ;
Params.Write(S[1], Length(S)); IdHTTP2.HandleRedirects := True; //IdHTTP2.Request. .SetHeaders; //最重要的初始化。 IdHTTP2.Request.RawHeaders.Values['Cookie'] := mycookie;
IdHTTP2.Request.Accept:='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml,application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'; IdHTTP2.Request.AcceptEncoding:='gzip, deflate'; IdHTTP2.Request.CacheControl:='no-cache'; IdHttp2.Request.Connection:='Keep-Alive'; IdHttp2.Request.ContentType:='multipart/form-data; boundary=----------7da34b2e73079c'; IdHttp2.Request.Host:='bbs.2ccc.com'; IdHttp2.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)'; Idhttp2.Request.Referer:='http://bbs.2ccc.com/topic.asp?topicid=351659'; IdHTTP2.Post('http://bbs.2ccc.com/topic_submit.asp', Params, aStream); done := True; Label1.Caption:='发帖测试'+inttostr(Length(S)); Label1.Update; except done := false; end;
aStream.Free; Params.Free;
end;
----------------------------------------------
-
|
作者: |
|
2010/4/10 9:43:03 |
2楼: |
mycookie值的由来 procedure TForm1.IdCookieManager2NewCookie(ASender: TObject; ACookie: TIdCookieRFC2109; var VAccept: Boolean); begin mycookie:=ACookie.ClientCookie; end;
----------------------------------------------
-
|
作者: |
|
2010/4/10 9:44:45 |
3楼: |
我感觉好像boundary=----------7da34b2e73079c这个值一直变化,怎么获取这个值?????????? 网上只有登录,但是登录后如何发帖的代码好像都不行,希望有朋友讨论讨论??????????
----------------------------------------------
-
|
作者: |
|
2010/4/10 11:12:22 |
4楼: |
你准备用广告洗劫盒子? 动机有很大问题哦,这里估计有人知道也不会告诉你的
----------------------------------------------
--
|
作者: |
|
2010/4/10 11:48:22 |
5楼: |
简单的论坛发帖是可以做出来的.但自从那些自动发帖的工具泛烂之后,很多论坛都加了不少机制来防止.比如登录时的图片验证码,一个比一个复杂,肉眼都要认好久才看清楚.
----------------------------------------------
-
|
作者: |
|
2010/4/10 12:15:23 |
6楼: |
绝对不会用广告洗劫盒子,自己就是想研究一下的,没有别的意思啊,知道的高手可以说说思路啊
----------------------------------------------
-
|
作者: |
|
2010/4/10 15:33:35 |
7楼: |
登录后网页上可以查到的,不容易啊!!!!!
----------------------------------------------
-
|
作者: |
|
2010/4/10 22:50:36 |
8楼: |
嘿嘿!!!,你已经做到了。有好多你的测试回复贴,去别的论坛再去调试吧。
----------------------------------------------
-Delphi Tips Study
|
作者: |
|
2010/4/11 12:12:03 |
9楼: |
呵呵,不再调试了啊,就是想试一试Idhttp技术的,没有别的意思,代码就不再贴出来了啊,自己琢磨琢磨我觉得还是可以弄出来的!!!!
----------------------------------------------
-
|
作者: |
|
2010/4/11 16:56:54 |
10楼: |
呵呵,不会要攻击网站吧吧!!
----------------------------------------------
-
|
作者: |
|
2010/4/12 8:50:56 |
11楼: |
难怪我前段时间删除了这么多广告贴呀.哎. 哈哈.我也没有研究过怎么自动发帖
----------------------------------------------
我的博客:huangjacky.cnblogs.com
|
作者: |
|
2010/7/2 2:15:34 |
12楼: |
有不明白想请教~
小猪猪QQ号是多少呢??????????
help me! please!
----------------------------------------------
-
|
作者: |
|
2010/7/2 2:16:16 |
12楼: |
晕。。。。回复不了。。。 小猪猪Q号多少? 有事找你。。。 要不你加我:694911754
----------------------------------------------
-
|
作者: |
|
2010/7/2 6:50:45 |
13楼: |
加个简单的验证码就可以防止机器灌水
----------------------------------------------
-
|
|