代码拉取完成,页面将自动刷新
<?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], "");
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。