BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / soft-design / #37546同步于 2010/1/30
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖

论坛发帖机的问题。

bylee
2010/1/30镜像同步4 回复
想在暑假弄个论坛的发帖机练练手。网上查了资料,得知要先使用浏览器登陆,然后截取数据,在分析得到要提交的格式。。现在以学校论坛为例,在浏览器登陆,使用wireshark得到如下数据 我参考一个注册机的代码,写了以下代码,但是没有成功登陆。不知道是哪里写错了?用C#写的。 Encoding myEncoding = Encoding.GetEncoding("gb2312"); CookieContainer container = new CookieContainer(); string param = "id=bingyelee&passwd=3404aasdf&selectlist=3&comeurl=.%2Fdefault.php&logon=%B5%C7%C2%BC"; string url = "http://forum.byr.edu.cn"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url+"?"+param+new Random().NextDouble()); req.CookieContainer = container; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = param.Length; req.Method = "POST"; 不知道是不是param的格式出错,还是url出错。谢谢了~~
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
coolwc机器人#1 · 2010/1/30
出错在于没有用对HTTP METHOD http request两种method GET 和 POST GET是发送的数据在url里包含 POST是发送的数据在Content里包含 论坛的登录用的是POST方式
jokerlee机器人#2 · 2010/1/30
【 在 bylee 的大作中提到: 】 : 想在暑假弄个论坛的发帖机练练手。网上查了资料,得知要先使用浏览器登陆,然后截取数据,在分析得到要提交的格式。。现在以学校论坛为例,在浏览器登陆,使用wireshark得到如下数据 : : 我参考一个注册机的代码,写了以下代码,但是没有成功登陆。不知道是哪里写错了?用C#写的。 : ................... 都用上wireshark这种神器了.... firefox、chrome随便装个插件就能抓http包...
coolfantasy机器人#3 · 2010/1/31
给个例子,以前是可以跑的,现在不知道 <?php $status = $argv[1]; $subject = "[VOL]$status"; $content = "[".date('Y-m-d H:i:s')."]".' Post By Robot Program'; $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); $login_url = "http://forum.test.cn/wForum/logon.php"; $login_post_fields = "id=user&passwd=123&CookieDate=0&comeurl=http://forum.test.cn/wForum/index.php"; curl_setopt($curl, CURLOPT_URL, $login_url); curl_setopt($curl, CURLOPT_POSTFIELDS, $login_post_fields); curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.data"); $rt = curl_exec($curl); //echo $rt; $post_url = "http://forum.test.cn/wForum/dopostarticle.php"; curl_setopt($curl, CURLOPT_URL, $post_url); $post_post_fields = "board=BUPTVOL&reID=0&font=&subject=$subject&Content=$content&emailflag=0"; curl_setopt($curl, CURLOPT_POSTFIELDS, $post_post_fields); curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie.data"); $rt = curl_exec($curl); //echo $rt; mail('test@gmail.com', $subject, $content); ?>
bingyelee机器人#4 · 2010/1/31
终于是登陆成功了。。。。。。。。还是wireshark好用。。。。。 原来的代码 用的是 get 另外,提交的数据格式也不对,不截取数据还真不知道。