1 Star 0 Fork 0

linyc/91porn_php

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
detailPage.php 2.69 KB
一键复制 编辑 原始数据 按行查看 历史
张智杰 提交于 2020-09-11 10:29 . 91页面结构变动
<?php
require 'downloader.php';
use DiDom\Document;
use DiDom\Query;
function singlePage($page_url, $title)
{
$html = getHtml($page_url);
$page = new Document($html);
try {
$videoUrl = "";
// 先直接取source
$source = $page->first('#player_one source');
if ($source) {
$videoUrl = $source->getAttribute('src');
echo "====直接解析====\n";
}
// 分享链接也没有的话再解密
if (!$videoUrl) {
$cipher = $page->first('#player_one script')->text();
$videoUrl = decode($cipher);
echo "====js解密====\n";
}
// 如果source取不到就找分享链接
if (!$videoUrl) {
$shareLink = $page->first('#linkForm2 #fm-video_link');
$sharePage = new Document(getHtml($shareLink->text()));
$videoUrl = $sharePage->first('source')->getAttribute('src');
echo "====分享链接====\n";
}
$date = $page->find('#videodetails-content')[1]->find('.title-yakov')[1]->text();
echo $videoUrl."\n";
Downloader::download($videoUrl, $title, $date);
}catch(Exception $e) {
echo "这个视频没找到,请排查是否需要挂载代理\n";
}
}
function getHtml($url) {
$header = array();
// $header[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
// $header[] = "Accept-Encoding: gzip, deflate";
$header[] = "Accept-Language:zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7";
// $header[] = "X-Forwarded-For:".random_ip();
// $header[] = "Content-Type: multipart/form-data; session_language=cn_CN";
// $header[] = "Referer:".$url;
// $header[] = "Host:".Config::$url;
// $header[] = "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT,300);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if (property_exists('Config', 'proxy') && (Config::$url=='91porn.com')) {
curl_setopt($ch, CURLOPT_PROXY, Config::$proxy);
}
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
return $data;
}else{
echo "页面未取回,请排查是否需要挂载代理\n";
}
}
function decode($cipher)
{
$js = getHtml('http://'.Config::$url.'/js/md5.js');
$cipher = explode('document.write(', $cipher)[1];
$cipher = explode(');', $cipher)[0];
$file = fopen('./md5.js',"w+");
fputs($file,$js.'console.log('.$cipher.');');//写入文件
fclose($file);
$tag = shell_exec('node ./md5.js');
$videoUrl = explode("<source src='", $tag)[1];
$videoUrl = explode("' type='video/mp4", $videoUrl)[0];
return $videoUrl;
}
if (count($argv)>1) {
singlePage($argv[1], "");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/linyanchao/91porn_php.git
[email protected]:linyanchao/91porn_php.git
linyanchao
91porn_php
91porn_php
master

搜索帮助