欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP實(shí)現(xiàn)抓取迅雷VIP賬號的方法

 更新時間:2015年07月30日 09:31:31   作者:李虎頭  
這篇文章主要介紹了PHP實(shí)現(xiàn)抓取迅雷VIP賬號的方法,實(shí)例分析了php基于采集類Snoopy實(shí)現(xiàn)頁面抓取及正則匹配的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實(shí)例講述了PHP實(shí)現(xiàn)抓取迅雷VIP賬號的方法。分享給大家供大家參考。具體如下:

看了@Jinn_Wei Python版本的抓取賬號,于是順手寫了個PHP版本
PS1:代碼沒經(jīng)過優(yōu)化,只實(shí)現(xiàn)了基本的功能
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';
//找出匹配的網(wǎng)址
$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);
//匹配出需要的內(nèi)容
$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 />';
}

Snoopy-1.2.3.tar.gz點(diǎn)擊此處本站下載。

希望本文所述對大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論