PHP页面数据采集程序的一个插件子类
2013-12-23 08:49
495 查看
下面我们实现一个具体的采集类,这个类用来采集 游戏币交易网站的游戏币价格和库存数据
我们共开发了几十个采集插件,打算将市面上所有的游戏币交易网站的数据都收集起来,
这是其中的一个,(有些必要的注释已经去除,太长了,而且都是一样的)
阅读(353) | 评论(0) | 转发(0) |
0
上一篇:PHP开发的页面数据采集程序 的基础类
下一篇:PHP页面数据采集程序的主程序
相关热门文章
南京网站建设,dx2.0升级dx3.1...
vim脚本写法
河南内黄县国税局收入提高企业...
谷歌清理Chrome插件:多用途插...
Java关键字介绍之final
承接自动化测试培训、外包、实...
Solaris PowerTOP 1.0 发布
For STKMonitor
busybox的httpd使用CGI脚本(Bu...
项目小体会
LNMP 老是会出现502?
suse 运用一个shell获取本机和...
虚拟机 unix 配置ip
hp-un 主机新系统读不到磁盘阵...
mysql出现问题:Starting MySQ...
给主人留下些什么吧!~~
评论热议
我们共开发了几十个采集插件,打算将市面上所有的游戏币交易网站的数据都收集起来,
这是其中的一个,(有些必要的注释已经去除,太长了,而且都是一样的)
<?php //包含共用函数库 include_once('Gather_Base.php'); final class bank extends Gather_Base{ private $homepage='http://www.rmt-bank.co.jp/'; private $classname='bank'; private $encoding='shift-jis'; function __construct(){ //调用父类的构造方法,增加两个参数, //一个是类名,一个是编码 parent::Gather_Base($this->classname,$this->encoding); } //得到数据 function getData(){ $games=$this->getGames($this->homepage); if($games===false)return false; //每个游戏处理 foreach($games as $name=>$http){ echo "\nGame:$name\n"; $this->log('Game',$name); $price=$this->getPrice($http['sell']); if($price!==false) $this->areasSell[$name]=$price; $price=$this->getPrice($http['buy']); if($price!==false) $this->areasBuy[$name]=$price; } } function getPrice($http){ if(!$http)return false; $thisGame=array(); $doc=$this->get($http); $doc=$this->getMiddle($doc,'cart_t'); $table=$this->getTableData($doc); //dump($table);exit; $headers=$table[1]; $favorCount=count($headers); $last='last area'; for($i=2;$i<count($table);$i+=2){ $tds=$table[$i]; $name=trim($tds[0]); //echo "I=$i Name=$name Last=$last\n"; if(substr($name,0,strlen($last))==$last)continue; $last=$name; $stock=intval($tds[1]); $price=intval($tds[3]); $thisGame[$name]=array( 'areaName'=>$name, 'basePrice'=>$price, 'stock'=>$stock, 'favor'=>array() ); for($j=0;$j<$favorCount;$j++){ $favorStock=intval($headers[$j]); $favorPrice=$tds[$j +3]; $thisGame[$name]['favor'][$favorStock]=intval($favorPrice); } } //dump($thisGame);exit; return $thisGame; } function getBuyPrice($http){ $thisGame=array(); $doc=$this->get($http); $doc=$this->getMiddle($doc,'botan'); $table=$this->getTableData($doc); //dump($table);exit; for($i=1;$i<count($table);$i++){ $tds=$table[$i]; $name=$tds[0]; $stock=intval($tds[1]); $price=intval($tds[2]); $thisGame[$name]=array( 'areaName'=>$name, 'basePrice'=>$price, 'stock'=>$stock, ); } //dump($thisGame);exit; return $thisGame; } function getGames($GamePage){ $doc = $this->get($GamePage); if($doc===false)return false; $reg='/<td[^>]*><a\s*href="([^"]*)"\s*target="\_self"><img[^>]*alt="([^"]*)"><\/a><\/td>/i'; $matchs=$this->pregMatchAll($reg,$doc); //dump($matchs);exit; foreach($matchs as $match){ if($match==$matchs[0])continue; $name=$match[2]; $mts=$this->pregMatch('/(?:rmt)?\s*(\S*)/i',$name); //dump($name);dump($mts);exit; $name=trim($mts[1]); $name=$this->getMiddle($name,null,' ',true); $http=$match[1]; $doc=$this->get2($http); $regSell='/<A\s*href="([^"]*)"\s*target="\_self"><IMG\s*src="gallery\/order\_sell\.jpg"[^>]*>/i'; $regBuy='/<A\s*href="([^"]*)"\s*target="\_self"><IMG\s*src="gallery\/order\_buy\.jpg"[^>]*>/i'; $mtsSell=$this->pregMatch($regSell,$doc,true); $mtsBuy=$this->pregMatch($regBuy,$doc,true); if($mtsSell) $httpSell=$mtsSell[1]; else $httpSell=false; if($mtsBuy) $httpBuy=$mtsBuy[1]; else $httpBuy=false; //dump($http);dump($mtsSell);dump($mtsBuy);exit; if(!$mts)continue; $games[$name]=array( 'sell'=>$httpSell, 'buy'=>$httpBuy ); } //dump($games);exit; return $games; } } ?>
阅读(353) | 评论(0) | 转发(0) |
0
上一篇:PHP开发的页面数据采集程序 的基础类
下一篇:PHP页面数据采集程序的主程序
相关热门文章
南京网站建设,dx2.0升级dx3.1...
vim脚本写法
河南内黄县国税局收入提高企业...
谷歌清理Chrome插件:多用途插...
Java关键字介绍之final
承接自动化测试培训、外包、实...
Solaris PowerTOP 1.0 发布
For STKMonitor
busybox的httpd使用CGI脚本(Bu...
项目小体会
LNMP 老是会出现502?
suse 运用一个shell获取本机和...
虚拟机 unix 配置ip
hp-un 主机新系统读不到磁盘阵...
mysql出现问题:Starting MySQ...
给主人留下些什么吧!~~
评论热议
相关文章推荐
- PHP开发的页面数据采集程序 的基础类
- PHP页面数据采集程序的主程序
- 小程序获取上一页的数据修改上一个页面的数据
- 基于PHP的简单采集数据入库程序【续篇】
- 一个简单的有分页采集功能的php采集程序--自制的哦
- 基于PHP的简单采集数据入库程序
- php 论坛采集程序 模拟登陆,抓取页面 实现代码
- 通过Z-BlogPHP程序快速在论坛里搭建一个博客页面
- php实现的一个很好用HTML解析器类可用于采集数据
- 基于PHP的简单采集数据入库程序
- php实现的一个很好用HTML解析器类可用于采集数据
- curl乱码有两个方面的原因一个是因为我们采集页面的php页面编码与远程文档编码不致导致的,另一种可能是页面进入了gzip压缩传输导致的
- PHP程序开发之使用header定义一个php页面为utf-8编码或GBK编码
- php点击修改数据(同页面修改mysql数据)jeditable插件
- 发一个php简单的伪原创程序,配合商城采集用的
- php 论坛采集程序 模拟登陆,抓取页面 实现代码
- ASP网站数据采集程序制作:一个采集入库生成本地文件的几个FUCTION(可用来生成HTML静态网页)
- ASP网站数据采集程序制作:一个采集入库生成本地文件的几个FUCTION(可用来生成HTML静态网页)
- 微信小程序编译过程中如何将一个页面的数据传到另一个页面呢
- 在小程序中修改上一个页面里data中的数据调用上一个页面的方法