不好意思,发了这么多帖子,把代码贴上来吧。 [ 新手入门 ]
批量回帖 纯属娱乐,绝无恶意。其他人因使用这段代码被封号啥的与本人无关。
<meta charset="utf-8" />
<?php
function curl($url,$post='',$referer=''){
$ch=curl_init($url);
empty($referer) && $referer=$url;
curl_setopt_array($ch,array(
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1',
CURLOPT_REFERER=>$referer,
CURLOPT_COOKIE=>'这里我就不把自己的贴上来了,免得你们拿我的号做坏事。自己用浏览器看。',
CURLOPT_POSTFIELDS=>$post,
));
$cont=curl_exec($ch);
return $cont;
}
function gethash($fid,$tid){
$url="http://www.yiichina.com/forum/post.php?action=reply&fid=$fid&tid=$tid";
$cont=curl($url);
preg_match('/"formhash"\s+value="(\w+)"/i',$cont,$hash);
return array_pop($hash);
}
function post($fid,$tid){
$url="http://www.yiichina.com/forum/post.php?action=reply&fid=$fid&tid=$tid&extra=&replysubmit=yes";
$ref="http://www.yiichina.com/forum/post.php?action=reply&fid=$fid&tid=$tid";
$hash=gethash($fid,$tid);
$post=array(
'formhash'=>'a2ae5b9b',
'posttime'=>'1352192569',
'wysiwyg'=>'0',
'noticeauthor'=>'',
'noticetrimstr'=>'',
'noticeauthormsg'=>'',
'subject'=>'',
'checkbox'=>'0',
'message'=>'顶一下,顺便挣点积分。
我挣分,说明我爱这里。
挣分不容易
版主请留情
感谢开源事业
绝对没别的意思
除了挣分就是露脸
好了,我要去顶下一贴了,拜拜
发帖时间:'.date('Y-m-d H:i:s'),
'usesig'=>'1',
);
return curl($url,$post,$ref);
}
function getposts($url){
preg_match('/forum-(\d+)/i',$url,$fid);
$cont=curl($url);
$fid=array_pop($fid);
preg_match_all('/thread-(\d+)/',$cont,$tid);
$tid=array_filter(array_unique(array_pop($tid)));
//sort($tid,SORT_NUMERIC);
$data=array();
foreach($tid as $v){
$data[]=array($fid,$v);
}
return $data;
}
//这里填一个板块地址就可以给这个列表页的所有常规贴回一段话。
$posts=getposts('http://www.yiichina.com/forum/forum-7-1.html');
$rst=array();
$i=0;
foreach($posts as $post){
//貌似有30秒的发帖间隔限制,不好玩了。
if($i>0){ sleep(31); }
list($fid,$tid)=$post;
$cont=post($fid,$tid);
preg_match('/<div class="alert.+?>\s*<p>(.+?)<\/p>/i',$cont,$msg);
$rst[]=array($fid,$tid,array_pop($msg));
if(++$i>1){ break; }
}
print_r($rst);
共 0 条回复
没有找到数据。
wxs77577 上海
注册时间:2012-07-09
最后登录:2016-09-29
在线时长:1小时32分
最后登录:2016-09-29
在线时长:1小时32分
- 粉丝3
- 金钱240
- 威望10
- 积分350