乐透TV:php 优酷视频采集,小示例(基于phpquery)

<?php
set_time_limit(0);
require '../global.php';
header("Content-type: text/html; charset=utf-8");
L::loadClass('phpQuery' , 'utility' , false);
$url = S::getGP('url');
$vodID = getYoukuID($url);
phpQuery::$documents = null;
phpQuery::$defaultCharset = 'GBK';
phpQuery::newDocumentFileHTML($url);
echo pq("title")->html();
$num = (int) pq("#zySeriesTab")->find('li')->length();
$num = $num>0 ? $num : 1;
echo '<pre>';
for($i=0;$i<$num;$i++){
  $key = ($i*40)+1;
  $reload = "reload_".$key;
  $juji = "http://www.youku.com/show_episode/id_{$vodID}.html?dt=json&divid={$reload}";
  $data =  getJuJI($juji);
 
  foreach($data as $value){
  echo $value."\n";
  }
}
echo '</pre>';
function getYoukuID($url)
{
preg_match("~id_(.*).html~", $url,$arr);
return $arr[1];
}
function getJuJI($juji)
{
phpQuery::$documents = null;
phpQuery::$defaultCharset = 'utf-8';
//$content = file_get_contents($juji);
//phpQuery::newDocumentHTML($content);
phpQuery::newDocumentFileHTML($juji);
$aList =  pq("a");
foreach ($aList as $a)
{
$key =getYoukuID(pq($a)->attr('href'));
$value = pq($a)->html();
$data[] ="第{$value}集\${$key}";
}
return $data;
}

采集结果:
图片
 
用于: 乐透tvhttp://www.letoutv.com

转载于:https://www.cnblogs.com/letoutv/archive/2013/02/28/2936542.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值