研究如何做站群批量采集,下面给大家分享一下自己的代码,如果有技术厉害的大神可以做下优化改进帝国cms自动采集的原创代码:

<?php
set_time_limit(0);
require("e/class/connect.php");
if(!defined('InEmpireCMS'))
{exit();
}
/*
$loginuserid = getcvar('loginuserid',1); //用户ID
$loginusername = getcvar('loginusername',1); //用户名
$loginlevel = getcvar('loginlevel',1); //组IDif($loginuserid!=1 || $loginlevel!=1){exit('没有操作权限,网站管理员登陆后操作');
}
*/
//为真输出采集信息,为假发布采集信息
$debug = false;//获取数组给定位置上一个下一个下标
class Steps {private $all;private $count;private $curr;function __construct() {$this->count = 0;}function add($step) {$this->count++;$this->all[$this->count] = $step;}function setCurrent($step) {reset($this->all);for ($i = 1; $i <= $this->count; $i++) {if ($this->all[$i] == $step)break;next($this->all);}$this->curr = current($this->all);}function getCurrent() {return $this->curr;}function getNext() {self::setCurrent($this->curr);return next($this->all);}function getPrev() {self::setCurrent($this->curr);return prev($this->all);}
}$cps = array('全国彩'=>array(//这里的采集地址写完整地址带上http'福彩3d'=>'采集地址1','福彩双色球'=>'采集地址2','体彩大乐透'=>'采集地址3','体彩排列3'=>'采集地址4','体彩排列5'=>'采集地址5','体彩七星彩'=>'采集地址6','福彩七乐彩'=>'采集地址7',),
$czs = array('福彩3d'=>array('classid'=>3,'titlepic'=>'/skin/images/fcsd.gif'),'福彩双色球'=>array('classid'=>5,'titlepic'=>'/skin/images/fcssq.gif'),'体彩大乐透'=>array('classid'=>6,'titlepic'=>'/skin/images/tcdlt.gif'),'体彩排列3'=>array('classid'=>4,'titlepic'=>'/skin/images/tcp3.gif'),'体彩排列5'=>array('classid'=>77,'titlepic'=>'/skin/images/tcp5.gif'),'体彩七星彩'=>array('classid'=>8,'titlepic'=>'/skin/images/tcqxc.gif'),'福彩七乐彩'=>array('classid'=>7,'titlepic'=>'/skin/images/fcqlc.gif'),
);$sites = array(
'https://www.scw88.com',
//可以增加多个网站 但是确保网站后台地址和数据字段一致
);$area = isset($_GET['a']) ? $_GET['a'] : '全国彩';
$total = isset($_GET['t']) ? $_GET['t'] : 0;
$site = isset($_GET['s']) ? $_GET['s'] : 'https://www.scw88.com';
if(empty($site)) exit("采集完毕");
//获取所有地区
$keys = array_keys($cps);
//判断地区是否存在
if(!in_array($area,$keys)) die('not found area');
//获取当前地区彩种数量
$area_count = count($cps[$area]);
//彩种采集完成跳到下一个地区
if($total==$area_count){//获取当前区域下标$area_index = array_keys($keys,$area,true);$steps = new Steps();foreach($keys as $key=>$value){$steps->add($key);}$steps->setCurrent($area_index[0]);$next = $steps->getNext();unset($steps);//获取当前站点下标$steps = new Steps();foreach($sites as $key=>$value){$steps->add($value);}$steps->setCurrent($site);$next_site = $steps->getNext();if(!$next){echo('当前:'.$steps->getCurrent().',采集完毕,开始下一个站');exit("<script>location.href='cj.php?s=$next_site'</script>");}else{//获取下一个区域$next_area = $keys[$next];//获取下一个地区所有彩种$next_name_keys = array_keys($cps[$next_area]);//获取下一个地区彩种名称$next_name = $next_name_keys ? $next_name_keys[0] : '';exit("<script>location.href='cj.php?next=2&a=$next_area&c=$next_name&t=0&s=$site'</script>");}
}
//获取当前地区所有彩种
$name_keys = array_keys($cps[$area]);
//获取当前地区彩种名称
$name = $name_keys[$total];
//获取彩种url
$url = $cps[$area][$name];
//采集彩种
require_once('curl.class.php');
$curl = new Curl();
$curl->setOpt(CURLOPT_SSL_VERIFYPEER,0);
$curl->setOpt(CURLOPT_SSL_VERIFYHOST,0);
$curl->get($url);
//var_dump($curl);
if ($curl->error) {print('error code : '.$curl->error_code .'<br>error message : '. $curl->error_message);//如果超时,刷新页面if($curl->error_code==7){exit('<script>location.reload();</script>');}
}
//curl返回值为对象
$obj1 = json_encode($curl->response);
$obj = json_decode($obj1,TRUE);
$html = "";
foreach($obj['result'] as $row){$html .= '<p name="num">'.str_replace(date('Y',time()),'',$row['issue_no']).'</p>';$html .= '<p name="qihao">'.$row['issue_no'].'</p>';$html .= '<p name="kaijiangriqi">'.$row['award_date'].'</p>';$html .= '<p name="jiangchi">'.$row['pool_amount'].'元</p>';$html .= '<p name="xiaoshoujine">'.$row['all_amount'].'元</p>';$objc = json_decode($row['award_count'],TRUE);//print_r($objc);$jiangxiang = '<thead><tr><th>奖项</th><th>中奖注数</th><th>单注金额</th></tr></thead><tbody>';if(isset($objc['awardinfo'])){foreach($objc['awardinfo'] as $ainfo){$jiangxiang .= '<tr><td>'.$ainfo['awards'].'</td><td>'.$ainfo['bet'].'</td><td>'.$ainfo['amount'].'</td></tr>';}}$jiangxiang .= '</tbody>';$html .= '<p name="jiangxiang">'.$jiangxiang.'</p>';$html .= '<p name="hongqiu">'.implode('',array_map(function($obj){return '<span class="num">'.$obj.'</span>';},$row['awardResultList']['redBall'])).'</p>';$html .= '<p name="langqiu">'.(isset($row['awardResultList']['buleBall']) ? implode('',array_map(function($obj){return '<span class="num blue">'.$obj.'</span>';},$row['awardResultList']['buleBall'])) : '').'</p>';$html .= '<p name="kaijihao">'.(isset($row['result']) ? implode('',array_map(function($obj){return '<span class="mr-10">'.$obj.'</span>';},explode(',',$row['result']))) : '').'</p>';$html .= '<p name="shijihao">'.(isset($row['test_result']) ? implode('',array_map(function($obj){return '<span class="mr-10">'.$obj.'</span>';},explode(',',$row['test_result']))) : '').'</p><hr>';//发布采集结果if(!$debug){//下面这里是发布插件 跟火车头发布插件一样的操作$curl->post($site . '/e/admin/kaijiang.php?pw=123456', array('title' => $name.'第'.$row['issue_no'].'期开奖结果','ftitle' => $name.$row['issue_no'],'classid' => isset($czs[$name]['classid']) ? $czs[$name]['classid'] :'','kaijihao' => (isset($row['result']) ? implode('',array_map(function($obj){return '<span class="mr-10">'.$obj.'</span>';},explode(',',$row['result']))) : ''),'kaijiangjieguo' => implode('',array_map(function($obj){return '<span class="num">'.$obj.'</span>';},$row['awardResultList']['redBall'])).(isset($row['awardResultList']['buleBall']) ? implode('',array_map(function($obj){return '<span class="num blue">'.$obj.'</span>';},$row['awardResultList']['buleBall'])) : ''),'shijihao' => (isset($row['test_result']) ? implode('',array_map(function($obj){return '<span class="mr-10">'.$obj.'</span>';},explode(',',$row['test_result']))) : ''),'qishuo' => str_replace(date('Y',time()),'',$row['issue_no']),'benqixiaoliang' => "<b>{$row['all_amount']}元</b>",'kaijiangshijian' => $row['award_date'],'benqiqishu' => $row['issue_no'],'newstext' => $jiangxiang,'titlepic' => isset($czs[$name]['titlepic']) ? $czs[$name]['titlepic'] :'','newstime' => date('Y-m-d H:i:s',time()),'filepass' => '','checked' => 1,'username' => 'admin','ZC'=>get_week($row['award_date'])));print(strip_tags($curl->response) . '<br>');}$jiangxiang = '';
}//输出结果
if($debug) echo $html;//下一个彩种
$total = $total+1;
echo "<script>location.href='cj.php?next=1&a=$area&c=$name&t=$total&s=$site'</script>";
$curl->close();
?>

如果使用需要服务器开启curl,全自动运行可以利用宝塔的计划任务来实现,直接保存代码为cj.php,增加URL访问即可,之前说的双彩网走势图功能还在完善中,等完善了会将走势图的一些相关源码放出来供大家学习,关于走势图的美化大家也给提点建议~

帝国cms站群全自动采集入库程序源码分享相关推荐

  1. 蜘蛛池源码php,PHP蜘蛛池泛站群系统完整运行版源码分享,强大的蜘蛛池系统PHP完美无错...

    一.源码说明: PHP蜘蛛池泛站群系统完整运行版源码分享,强大的蜘蛛池系统PHP完美无错版源码下载,搭建好php环境之后,设置404.php,而后将域名泛解析,修改目录下的domains文件,启动即可 ...

  2. 百度SEO站群vivi万能小偷站群版3.5程序源码去除授权

    emmm,这个程序名称怎么说是小偷站群呢,其实也就是克隆站点. 也可以说镜像站点.程序无任何使用限制,大家自行研究,希望大家对别人站点多一点的Respect(尊重). 下载地址: http://www ...

  3. 帝国CMS开发主播/直播视频网站源码+WAP/可封装APP运营

    正文: 帝国CMS开发主播/直播视频网站源码+WAP/可封装APP运营,这系统支持三端,就例如PC+WAP+APP,有兴趣的自己去体验吧,其它的就没什么好介绍的了. 程序: wwuef.lanzouy ...

  4. 简约风车壁纸自动采集小程序源码

    介绍: 风车壁纸自动采集小程序源码,自动采集,自动更新,无需数据库. 内壁纸资源采自: https://api.zhuti.xiaomi.com; https://at.aliCDN.com; htt ...

  5. 轻量级简约的自动采集小说程序源码

    正文: 轻量级简约的自动采集小说程序源码,全程序自动采集​,更新提示:已经更新采集规则. 安装环境: 1.Nginx环境 2.php7.0,mysql 3.宝塔服务器 4.正常的域名 安装教程: 1. ...

  6. 帝国CMS金融财经新闻资讯门户网站源码 PC+WAP手机版

    介绍: 帝国CMS金融财经新闻资讯门户网站源码 PC+WAP手机版 网盘下载地址: http://kekewl.net/wyHvrIZ7NON0 图片:

  7. 帝国CMS仿《游戏鸟》模板源码/92kaifa版大型手机游戏门户网站模板

    帝国CMS仿<游戏鸟>模板源码/92kaifa版大型手机游戏门户网站模板 ☑️ 编号:ym434 ☑️ 品牌:帝国CMS ☑️ 语言:php ☑️ 大小:200MB ☑️ 类型:仿< ...

  8. 130个免费 微信小程序源码分享

    130个免费 微信小程序源码分享 - AppleMusic - B站首页界面设计:附详细教程 - FlexLayout布局 - HIapp - IT-EBOOK - LOL战绩查询 - Railay: ...

  9. C# 自动投票和手机号码归属地查询 - 简单程序源码分享(高手飘过)

    C# 自动投票和手机号码归属地查询 - 简单程序源码分享(高手飘过) C# 自动投票和手机号码归属地查询 - 简单程序源码分享(高手飘过) 如有转载,请注明出处: http://www.cnblogs ...

最新文章

  1. 深度学习常用数据集介绍
  2. NYOJ 229 工程 二分+dp检验
  3. android-NDK-Opengl
  4. 钮扣电池电压电量_纽扣厂
  5. Visual Studio Code 1.3终于增加了标签页
  6. 使用Spring Boot构建REST Web服务
  7. 黑科技揭秘:3分钟,轻松构建一张覆盖全球的企业专有网络
  8. Python 小白从零开始 PyQt5 项目实战(1)安装与环境配置
  9. leetcode链表题
  10. 小齐是如何提高自己的「编程能力」的?
  11. Simbad的使用--检索、导入、保存
  12. 男女洗澡前后区别,太形象了!(文末送书)
  13. php提示返回,PHP指定方法的返回类型提示
  14. matlab将数据集分成训练集和测试集,如何将数据分成训练集和测试集?
  15. oracle时间相减得到天_oracle中计算两个日期之间得天数、月数、年数
  16. 如何利用会员积分体系提高用户活跃留存
  17. 全球与中国糖粉市场深度研究分析报告
  18. pythonmath库round计算_Python tensorflow.math.round()用法及代码示例
  19. 蓝桥2——Beaver's Calculator
  20. Java很傻,但是IDE很聪明,Intellij IDEA 是一款好产品

热门文章

  1. Scrapy-Redis使用教程将现有爬虫修改为分布式爬虫
  2. 模板方法模式--我们一起下饺子
  3. 零基础入门运维必备 | 一文总结学习 Python 的 14 张思维导图
  4. 第二篇 第三章防火防烟分区检查(一)
  5. 创建简易的金融数据库
  6. tomcat java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit异常解决
  7. 考勤登记管理系统(参考答案)
  8. 菜鸟教程,css小白入门
  9. react 微信公众平台实现支付功能
  10. 解决can't find -lGL的问题