获取资源网资源,并用PHP写成搜索接口
写了两个小时修复了很多问题!
测试地址
http://jhwsy.cn/sou/?wd=斗破苍穹
去除某某免费视频网站广告,违规等多个元素,只留下资源!
<程序源码PHP>
<!DOCTYPE html>
<html>
<head>
<title>煜慧影视资源API</title>
</head>
<body>
<p>调用参数为/?wd=资源名称&/?id=资源ID</p >
<?php
//获取用户提交的post数据
$user_data = $_GET["wd"];
$user_dataid = $_GET["id"];
if (empty($user_data)) {
} else {
// 拼接数据
$url = "http://fszy1.com/vod/search/?wd=";
//无尽资源搜索接口
$merged_url = $url . $user_data;
// 获取拼接后的网址的源码
$content = file_get_contents($merged_url);
// 根据两头关键词截取需要部分
$keyword1 = "/vod/detail/id/";
$keyword2 = "stui-foot clearfix";
$startPos = strpos($content, $keyword1) +strlen($keyword1);
$endPos = strpos($content, $keyword2);
$result = substr($content, $startPos, $endPos - $startPos);
// 根据@符号分割文本内容
$listItems = explode("vod/detail/id/", $result);
// 使用列表显示分割后的内容
echo "<ul>";
foreach ($listItems as $item) {
$keyword1 = "title=\"";
$keyword2 = "\">";
$startPos = strpos($item, $keyword1) +strlen($keyword1);
$endPos = strpos($item, $keyword2);
$result = substr($item, $startPos, $endPos - $startPos);
$keyword1 = "";
$keyword2 = "/";
$startPos = strpos($item, $keyword1) +strlen($keyword1);
$endPos = strpos($item, $keyword2);
$result1 = substr($item, $startPos, $endPos - $startPos);
//自适应二级目录
$currentPath = $_SERVER['REQUEST_URI'];
$pathParts = explode('/', trim($currentPath, '/'));
$directory = implode('/', array_slice($pathParts, 0, -1));
$result2 ="http://". $_SERVER['HTTP_HOST']."/".$directory."/?id=". $result1;
echo "<li>". "|" . $result . " |选集:" ."<a href='$result2'>$result2</a >"."</li>";
}
echo "</ul>";
}
if (empty($user_dataid)) {
} else {
$url = "http://fszy1.com/vod/detail/id/";
$merged_url = $url . $user_dataid . "/";
// 获取拼接后的网址的源码
$content = file_get_contents($merged_url);
$keyword1 = "<!-- 播放集数 -->";
$keyword2 = "<!-- end 播放地址 -->";
$startPos = strpos($content, $keyword1) +strlen($keyword1);
$endPos = strpos($content, $keyword2);
$result = substr($content, $startPos, $endPos - $startPos);
// 根据@符号分割文本内容
$listItems = explode("<!-- 播放集数 -->", $result);
// 使用列表显示分割后的内容
echo "<ul>";
foreach ($listItems as $item) {
$keyword1 = "";
$keyword2 = "<";
$startPos = strpos($item, $keyword1) +strlen($keyword1);
$endPos = strpos($item, $keyword2);
$result = substr($item, $startPos, $endPos - $startPos);
$keyword1 = "<!-- 播放集数地址 -->";
$keyword2 = "<!-- end 播放集数地址 -->";
$startPos = strpos($item, $keyword1) +strlen($keyword1);
$endPos = strpos($item, $keyword2);
$result1 = substr($item, $startPos, $endPos - $startPos);
echo "<li>". "|".$result . " |m3u8:" ."<a href='$result1'>$result1</a >"."</li>";
}
echo "</ul>";
}
?>
</body>
</html>
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。