Home >php教程 >php手册 >PHP实现抓取迅雷VIP账号的方法,php抓取vip账号

PHP实现抓取迅雷VIP账号的方法,php抓取vip账号

不言
不言Original
2018-06-05 13:50:322066browse


PHP实现抓取迅雷VIP账号的方法,php抓取vip账号

本文实例讲述了PHP实现抓取迅雷VIP账号的方法。分享给大家供大家参考。具体如下:

看了@Jinn_Wei Python版本的抓取账号,于是顺手写了个PHP版本
PS1:代码没经过优化,只实现了基本的功能
PS2:代码中使用了Snoopy
PS3:测试

<?php
/**
 * 抓取爱密码迅雷VIP账号
 * @author kphcdr@163.com
 */
header("Content-type: text/html; charset=UTF-8");
include &#39;Snoopy.php&#39;;
$url = &#39;http://www.521xunlei.com/forum-xunleihuiyuan-1.html&#39;;
//找出匹配的网址
$snoopy = new Snoopy();
$result = $snoopy->fetchlinks($url)->getResults();
foreach($result as $key=>$val)
{
  if(FALSE === strpos($val, &#39;thread-&#39;))
  {
    unset($result[$key]);
  }
  else
  {
    if(!strpos($val, &#39;-1-1.html&#39;))
    {
      unset($result[$key]);
    }
  }
}
$real = new Snoopy();
$result = array_values(array_unique($result));
$text = $real->fetchtext($result[1])->getResults();
$text = iconv(&#39;gbk&#39;,&#39;UTF-8//IGNORE&#39;,$text);
//匹配出需要的内容
$pattern = &#39;/^迅雷会员账号|迅雷共享账号+[a-zA-Z0-9_]{4,15}+:+[0-9]+爱密码分享密码+[a-zA-Z0-9_]{4,20}\s/&#39;;
preg_match_all($pattern,$text,$return);
foreach($return[0] as $a)
{
  echo $a;
  echo &#39;<br />&#39;;
}

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn