具体如下:
看了@jinn_wei python版本的抓取账号,于是顺手写了个php版本
ps1:代码没经过优化,只实现了基本的功能
ps2:代码中使用了snoopy
ps3:测试地址:http://xunlei.kphcdr.com
<?php/** * 抓取爱密码迅雷vip账号 * @author kphcdr@163.com */header("content-type: text/html; charset=utf-8");include 'snoopy.php';$url = 'http://www.521xunlei.com/forum-xunleihuiyuan-1.html';//找出匹配的网址$snoopy = new snoopy();$result = $snoopy->fetchlinks($url)->getresults();foreach($result as $key=>$val){ if(false === strpos($val, 'thread-')) { unset($result[$key]); } else { if(!strpos($val, '-1-1.html')) { unset($result[$key]); } }}$real = new snoopy();$result = array_values(array_unique($result));$text = $real->fetchtext($result[1])->getresults();$text = iconv('gbk','utf-8//ignore',$text);//匹配出需要的内容$pattern = '/^迅雷会员账号|迅雷共享账号+[a-za-z0-9_]{4,15}+:+[0-9]+爱密码分享密码+[a-za-z0-9_]{4,20}\s/';preg_match_all($pattern,$text,$return);foreach($return[0] as $a){ echo $a; echo '<br />';}
总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
php中ob函数缓冲机制
php针对文件的递归操作的方法
php结合session操作数据库的方法
以上就是php基于采集类snoopy实现抓取迅雷vip账号的方法的详细内容。
