目标:通过服务器名称和角色名获取用户所有数据包括:
包括不限于:
密林游侠90级熊猫人武僧
成就12120
物品平均等级:555
装备:鹤羽兜帽 飓风之543/暖阳项圈 焦躁之543/主宰之梦肩胄强效虎爪铭文567/忿欲,雪怒之怒608/帕美拉的穆斯卡特裹手 567 /幽暗城战袍
沸腾之怒护腕 567 /七星圣印之握 561/荧光琥珀腰带 567/七星圣印护561/执迷长靴548/暖阳指环 屠夫之543/暖阳指环 无懈之543/迷时神器 496 /哈洛姆的护符 536/库卡隆霸权之杖536
专业技能:制皮 剥皮
已收集坐骑:124只
详细清单:
已收集宠物:276只
详细清单:
局部代码:
我这些的是可以循环多采集的:
加入了缓存使得效率更高。
[code lang=”php”]
public function index(){
$db = M(‘Wowcj’);
$hash = $this->_get(‘hash’);
if(!$hash) exit(‘采集中断,请重新采集:<a href="’.U("Cj/cindex").’">点击这里</a>’);
$id = $this->_get(‘id’);
if(!$id) $id = $db->where("status=3 and typehash=’$hash’")->getFieldByID(‘id’);
$cont = $db->find($id);
if($cont){
$sname=$cont[‘fwq’];
$wowname=$cont[‘wowname’];
$page = ‘wow’;
$pet = $cont[‘pet’];
$zuoqi = $cont[‘zuoqi’];
$content = S($page.urlencode($sname.$wowname));
if(!$content){
$content = $this->urlc($sname,$wowname,$page);
S($page.urlencode($sname.$wowname),$content,86400);
}
//preg_match(‘#<div\s+class="profile-info">\s.*<span class="level"><strong>(\d+)</strong></span>\s+<a href="javascript:;" class="race">(.*)</a>\s+.*<a href="javascript:;" class="class">(.*)</a>.*<span class="realm tip" id="profile-info-realm" data-battlegroup="(.*)">\s[^>]+(.*)\s+</span>.*<div class="achievements"><a href=".*">(\d+)</a>.*<ul\s+class="profile-sidebar-menu"\s+id="profile-sidebar-menu">#isU’,$content,$machs);
preg_match(‘#<div\s+class="profile-info">\s.*<span class="level"><strong>(\d+)</strong></span>\s+<a href=".*" class="race">(.*)</a>\s+.*<a href=".*" class="class">(.*)</a>.*<span class="realm tip" id="profile-info-realm" data-battlegroup="(.*)">\s[^>]+(.*)\s+</span>.*<div class="achievements"><a href=".*">(\d+)</a>.*<ul class="profile-sidebar-menu" id="profile-sidebar-menu">#isU’,$content,$machs);
preg_match(‘#<div\s+id="summary-averageilvl-best"\s+class="best\s+tip"\s+data-id="averageilvl">\s+(\d+)\s+</div>#isU’,$content,$machs2);
//echo $content;
//dump($machs);
preg_match(‘#<div\s+id="summary-inventory"\s+class="summary-inventory\s+summary-inventory-advanced">\s+(.*)<script type="text/javascript">\s#isU’,$content,$machs3);
//preg_match(‘#<div id="summary-inventory" class="summary-inventory summary-inventory-advanced">\s+(.*)<div data-id="1" data-type="2" class="slot slot-2 item-quality-4" style=" left: 0px; top: 58px;">#isU’,$content,$machs3);
//dump($machs3);
//exit;
preg_match(‘#<div\s+class="summary-professions">\s+(.*)</li>\s+</ul>\s+</div>\s+<div class="summary-pets">#isU’,$content,$machs4);
$wowinfo = $machs;//姓名 服务器 荣誉点数 等级
$wupinlv = $machs2[1];//物品平均等级
$wowzb = $machs3[0];//所有装备
$jineng = $machs4[0];//专业技能
preg_match_all(‘#<span class="name">(.*)</span>#isU’,$jineng,$machall); //专业技能
preg_match_all(‘#<span class="name-shadow">(.*)</span>.*<span class="level">(\d+)</span>#isU’,$wowzb,$machall2); //所有装备
$jineng =implode($machall[1],’ ‘);//string(13) "制皮 剥皮"
foreach($machall2[1] as $key=>$val){
$strs[] = $val." ".$machall2[2][$key];
}
$wowzb =implode($strs,’/’);//string(384) "鹤羽兜帽 飓风之 543/暖阳项圈 焦躁之 543/主宰之梦肩胄 567/忿欲,雪怒之怒 608/帕美拉的
$lv = $wowinfo[1];//等级 string(2) "90"
$zongzu = $wowinfo[2];//种族 string(9) "熊猫人"
$class = $wowinfo[3];//职业 string(9) "武僧"
$zy = ‘联盟’;//1联盟 2部落
if(strstr($content,"profile-wrapper-horde")) $zy =’部落’ ;
$petarr = $this->pet($sname,$wowname,$pet);
$zuoqiarr = $this->zuoqi($sname,$wowname,$zuoqi);
//dump($zuoqiarr);
$data[‘zy’]=$zy;
$data[‘time’]=time();
$data[‘sname’]=$sname;
$data[‘wowname’]=$wowname;
$data[‘lv’]=$lv;
$data[‘zhongzu’]=$zongzu;
$data[‘zhiye’]=$class;
$data[‘zhuanye’]=$jineng;
$data[‘zhuanbei’]=$wowzb;
$data[‘wplv’]=$wupinlv;
$data[‘rongyu’]=$wowinfo[6];
$data[‘md5typehash’]=md5(urlencode($sname.$wowname));
$data[‘petnum’]=$petarr[‘petnum’];
$data[‘petjd’]=$petarr[‘jingdianpet’];
$data[‘zuoqinum’]=$zuoqiarr[‘petnum’];
$data[‘zuoqijd’]=$zuoqiarr[‘jingdianzq’];
$havedata = M(‘Wowdb’)->where("md5typehash = ‘".$data[‘md5typehash’]."’")->find();
//dump($havedata);
//exit;
if($havedata){
$data[‘uptime’]=time();
$data[‘status’]=0;
$re = M(‘Wowdb’)->where("md5typehash = ‘".$data[‘md5typehash’]."’")->save($data);
}else{
$data[‘typehash’]=$hash;
$re = M(‘Wowdb’)->add($data);
}
if($re){
$db->where("id=".$id)->setField(‘status’,5);//标记为完成采集
echo ‘写入数据成功!’;
}else{
echo ‘数据写入错误!’;
}
$nextid = $id+1;
$url = U(‘Cj/index’)."/hash/".$hash."/id/".$nextid;
echo ‘<Br>进入分析下一个id,<a href="’.$url.’" >如果有没无跳转请点击此处</a><script>window.location.href="’.$url.’"</script>’;
}else{
echo ‘采集已完成’;
echo ‘<br>’;
echo ‘<a href="’.U("Cj/cjlist")."/hash/".$hash.’">点击查看刚采集的列表</a>’;
echo ‘<br>’;
echo ‘<a href="’.U("Cj/cjlist").’">点击查看所有列表</a>’;
}
}
[/code]
数据采集完成后生成一个csv文件。可以批了导入到淘宝内。可以自动选定区服。
这里就不贴出来了。