找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 5661|回复: 53

[iptv信源 资源分享或寻求] 浏览器抓取接口,PHP获取下一页ID实例一:PPS美女直播

  [复制链接]
发表于 2022-7-31 19:18 | 显示全部楼层 |阅读模式
本帖最后由 jiteloozz 于 2022-8-1 18:41 编辑

进入奇秀分类:

https://x.pps.tv/category/amuse/切换下面的页面数字按钮,可以看到地址栏中的地址不变。这种情况下,通过获取网页源码,只能获取到第一页的ID数据。



如果要获取下一页数据,当然是得从抓取接口入手。
按F12,打开网页调试工具,定位到network选项(红圈标记处)



然后点击网页中页码数字(这里由当前2点到3),又边就会出现很多数据流~~~(如图)



因为切换页面后,变化的只是头像图片资源,数据流里出现的非图片的那个差不多就是接口了。如图红框处



箭头所指就是接口输出内容了。。。
定位到headers标签项,可以分析出接口为post请求,参数为椭圆红圈处。

至此,接口抓取完毕。
根据以上所述,PPS美女直播PHP代码如下:
测试:
获取直播列表,http://mmitv.top/test/xpps.php?id=list
随机美女直播,http://mmitv.top/test/xpps.php?id=top
<?php
/******************************************
//PPS直播PHP
1.获取下一页ID代码更新;
2.移除失效m3u8线路。
******************************************/
header('Content-Type: text/html;charset=UTF-8');
$id = isset($_GET['id'])?$_GET['id']:'';
if($id=='list'){
$bstrURL = 'https://x.pps.tv/api/page/pcInfo';
$post = 'page_id=yule&page=1&page_size=100';//实测不需要&dfp=参数
$json=json_decode(get_data($bstrURL,$post));
echo '===pps美女直播===</a><br>';
foreach ($json->data->items as $va){
  preg_match('/user_id=(.*?)&/',$va->action,$uid);
  $uid=$uid[1];
  $rid=$va->room_id;
  $name=$va->live_title;
  echo $name.',http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?id='.$rid.'&u='.$uid.'</a><br>';  
}
}else{
if($id!=='top'&&$id!==''){
$bstrURL = 'https://x.pps.tv/room/'.$id;
$data=get_data($bstrURL);
if(strpos($data,'window._stream_config = null') !== false){
  $id='';
  }else{
  $playurl=get_m3u8($data);
  }
}
if($id=='top'||$id==''){   
  $url =array(
   'https://x.pps.tv/category/amuse/pretty',
   'https://x.pps.tv/category/amuse/music',
   'https://x.pps.tv/category/amuse/hotdance',
   );
  $bstrURL =$url[array_rand($url, 1)];
  $data=get_data($bstrURL);
  preg_match_all('/"user_id".*?),.*?"room_id".*?),.*?"live_title":"(.*?)"/is',$data,$str);//多元素匹配成一个数组
  $bstrURL = 'https://x.pps.tv/room/'.$str[2][mt_rand(0,count($str[0])-1)];
  $data=get_data($bstrURL);
  $playurl=get_m3u8($data);
}
//print_r($playurl);
header('Location:'.$playurl);
}

function get_m3u8($data){
preg_match('/https_flv":"(.*?)",/',$data,$http);
$cdn=array(
   'https://flv-bdplay.inter.71edge.com',
   'https://flv-aliplay.inter.71edge.com',
   'https://flv-qqplay.inter.71edge.com'
   );
$host=$cdn[array_rand($cdn, 1)];
$playurl=$host.parse_url($http[1], PHP_URL_PATH);
return $playurl;
}
function get_data($url,$post=null){
$header=array(
    'User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64) AppleWebKit/536.26 (KHTML, like Gecko)  Chrome/86.0.3282.186 Safari/537.36',
    );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if(!empty($post)){
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  }
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
若有不足之处,请指正~~~
请教大神,如何获取&dfp=a0455883f1f3b94e1aae962b8e7aa97d29db4f20a6b4431505df5ddabdc9152063这个参数?Thanks!


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
发表于 2022-7-31 19:32 | 显示全部楼层
感谢分享         
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 20:07 | 显示全部楼层
谢谢分享谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 20:19 | 显示全部楼层
感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 20:19 | 显示全部楼层
谢谢分享谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 20:43 | 显示全部楼层
感谢楼主分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 21:20 | 显示全部楼层
感谢你的分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 21:21 来自手机 | 显示全部楼层
谢谢(*°°)=3
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 21:39 | 显示全部楼层
keyiya
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 21:50 | 显示全部楼层
PPS美女直播
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 21:51 | 显示全部楼层
666666666666666666666666
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-7-31 23:35 | 显示全部楼层
bbbbbbbbbbbbbbbbbbbbbbbb
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-8-1 00:41 | 显示全部楼层
谢谢分享         
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-8-1 02:52 | 显示全部楼层
谢谢分享谢谢分享谢谢分享谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-8-1 06:25 | 显示全部楼层
谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-3-28 22:25

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表