作者:Richardx

发码的地址各位看观自己找,草榴的地址各位也自己找找。。某家不敢传播地址,只分享技术。。。

PS:
1.补充一下,本代码是抓取那些发布在yahoo-group特定页面的邀请码,然后每段时间抓一下,只要页面有更新最新的邀请码,程序就会运行并注册之
2.可针对性草榴某个发码的贴子进行抓取,比如皇会发码的贴子,当然相关正则要小改一下
3.本代码均测试通过,只有最后注册那部份对错误的处理不完全,因为俺也不知道有多少种错误。。。
4.新增了// 論壇設置:刷新不要快於 2 秒
5. 草榴每月1号都会有发码活动

<?php
/**
* 获取草榴邀请码
* 学习研究A与V之间的相互关系
* @author richard
* 2013-2-28
*/
// 配置环境
ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
error_reporting(7);
set_time_limit(0);
header(‘Content-Type:text/html;charset=utf8’);
date_default_timezone_set(‘RPC’);

// 注册参数
$interval = 30*60;// 每隔s运行
$name = ‘a’;//注意长度 加起来不得超过12个字符 a+time() = 11字符
$email = ‘explamp@163.com’;

// 发码地址 search in google
$adressCodes = array(
‘http://127.0.0.1’,// 你看不到我。。aHR0cDovL3RlY2guZ3JvdXBzLnlhaG9vLmNvbS9ncm91cC8xMDI0Lw==
);

//定时执行
do{
start($adressCodes,$name, $email);
sleep($interval);
}while(true);

//start($adressCodes,$name, $email);

function start($adressCodes,$name, $email){

foreach($adressCodes as $key => $url){
// 抓取code
$result = getCodes($url);

// 匹配code
preg_match_all(‘#<!– Description –>.*<!– End Center Section Content –>#Us’, $result, $result);
preg_match_all(‘#[a-f0-9]{16}#’, $result[0][0], $codes);
//        var_dump($codes[0]);

if($codes[0]){
foreach($codes[0] as $k => $code){
// 检测是否存在记录
$codetxt = file_get_contents(‘code.txt’); // code log
if(strpos($codetxt, $code) === false){

// 校验邀请码
$result = checkRegister($code);
sleep(2); //論壇設置:刷新不要快於 2 秒
if(strpos($result, “parent.retmsg_invcode(‘1’)”) === false && strpos($result, “MySQL Server Error”) === false){
register($name, $email, $code); // 注册
}else{// 邀请码无效,写记录
file_put_contents(“code.txt”, $code.PHP_EOL, FILE_APPEND|LOCK_EX);
}
}
}
}
}
}

// 抓取code
function getCodes($url){
// 抓取网页
$result = array();
$options = array(
CURLOPT_URL => $url,
CURLOPT_USERAGENT => ‘Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120101 Firefox/17.0’,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 0,
CURLOPT_TIMEOUT => 10,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

// 校验邀请码
function checkRegister($code){
$result = array();
$postFields = array(
‘action’ => ‘reginvcodeck’,
‘reginvcode’ => $code
);
$options = array(
CURLOPT_URL => ‘http://*.*.*.244/register.php?’,
CURLOPT_USERAGENT => ‘Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120101 Firefox/17.0’,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => http_build_query($postFields),
CURLOPT_TIMEOUT => 10,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

// 注册
function register($name, $email, $code){
$temp = $name.time();
$postFields = array(
‘forward’ => ”,
‘invcode’ => $code,
‘regemail’ => $email,
‘regname’ => $temp,
‘regpwd’ => ‘123456’,
‘regpwdrepeat’ => ‘123456’,
‘step’ => ‘2’
);
$options = array(
CURLOPT_URL => ‘http://*.*.*.244/register.php?’,
CURLOPT_USERAGENT => ‘Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120101 Firefox/17.0’,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => http_build_query($postFields),
CURLOPT_TIMEOUT => 10,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);

if($result){
$result = iconv(‘gbk’, ‘utf-8’, $result);
if(strpos($result, “邀請碼錯誤”) === false && strpos($result, “MySQL Server Error”) === false){
file_put_contents(“caoliu.txt”, $temp.PHP_EOL, FILE_APPEND|LOCK_EX);
}
}
if(!$result || strpos($result, “MySQL Server Error”) !== false){
sleep(2);//論壇設置:刷新不要快於 2 秒
register($name, $email, $code);
}
}

0 Comments

Leave a reply

电子邮件地址不会被公开。 必填项已用*标注

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

联系

微信ruinews360 微信公众号:小芳侠

Sending

Log in with your credentials

Forgot your details?