找直播源很难所以我找到一个直播源获取工具并已经搭建好了也会分享源码,下面是获取链接
https://banfeng.top/iptv
源码需要自己创建命为index.txt和get_iptv.txt文件在里面粘贴下面的内容就行然后改后缀得到名为index.html和get_iptv.php就可以了‘在云服务器和虚拟主机创建一个文件夹为iptv吧刚刚源码放进去就行了不需要数据库.
下面是网页源码:自行复制
index.html
<!DOCTYPE html>
<html>
<head>
<title>灵感IPTV直播源获取工具</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
overflow: hidden;
}
h1 {
text-align: center;
font-size: 32px;
margin-top: 20px;
margin-bottom: 20px;
}
#input-container {
display: flex;
justify-content: center;
align-items: center;
}
#input-field {
width: 200px;
height: 50px;
padding: 10px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
#submit-button {
width: 100px;
height: 50px;
padding: 10px;
margin-left: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #337ab7;
color: #fff;
cursor: pointer;
}
#output-container {
position: relative;
display: none;
}
#output {
width: calc(100% - 40px);
max-height: calc(100vh - 210px);
padding: 10px;
margin-top: 20px;
margin-left: 10px;
border: 1px solid #ccc;
border-radius: 5px;
overflow-y: auto;
word-wrap: break-word;
}
#copy-button {
position: absolute;
top: 0px;
right: 10px;
width: 80px;
height: 30px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #337ab7;
color: #fff;
cursor: pointer;
display: none;
}
#copy-button:hover {
background-color: #23527c;
}
#copy-success {
position: absolute;
top: 10px;
right: 100px;
color: green;
display: none;
}
#loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
}
#loading-text {
font-size: 25px;
margin-bottom: 10px;
}
#loading-image {
width: 200px;
height: 100px;
}
@media only screen and (max-width: 600px) {
#input-container {
flex-direction: column;
align-items: center;
margin-left: 50px;
margin-right: 40px;
}
#input-field {
width: calc(100% - 20px);
margin-bottom: 10px;
}
#submit-button {
margin-top: 10px;
}
#output {
max-height: calc(100vh - 280px);
}
}
</style>
</head>
<body>
<h1>IPTV直播源获取</h1>
<div id="input-container">
<input type="text" id="input-field" placeholder="请输入你要获取的直播源名! 比如:cctv6" oninput="toggleInputBorder()">
<button id="submit-button" onclick="getIPTV()">开始获取</button>
</div>
<div id="loading">
<div id="loading-text">正在努力获取中...</div>
<img id="loading-image" src="https://img.soogif.com/74xHrCLAB7FMZJgDtAmnjN0NnqrR26lk.gif" alt="">
</div>
<div id="output-container">
<div id="output"></div>
<button id="copy-button" onclick="copyToClipboard()">复制</button>
<span id="copy-success">已复制</span>
</div>
<script>
function getIPTV() {
var input = document.getElementById("input-field").value;
if (input === "") {
document.getElementById("input-field").style.border = "none";
return;
}
toggleLoading(true);
var xhr = new XMLHttpRequest();
xhr.open("POST", "get_iptv.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("url=" + input);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
toggleLoading(false);
var response = xhr.responseText;
document.getElementById("output").innerHTML = response;
document.getElementById("output-container").style.display = "block";
document.getElementById("copy-button").style.display = "inline";
}
};
}
function copyToClipboard() {
var output = document.getElementById("output").innerText;
var dummyTextarea = document.createElement("textarea");
document.body.appendChild(dummyTextarea);
dummyTextarea.value = output;
dummyTextarea.select();
document.execCommand("copy");
document.body.removeChild(dummyTextarea);
var copyButton = document.getElementById("copy-button");
copyButton.innerText = "已复制";
copyButton.disabled = true;
setTimeout(function() {
copyButton.innerText = "复制";
copyButton.disabled = false;
}, 2000);
}
function toggleInputBorder() {
var inputField = document.getElementById("input-field");
if (inputField.value === "") {
inputField.style.border = "1px solid #ccc";
} else {
inputField.style.border = "1px solid #337ab7";
}
}
function toggleLoading(show) {
var loading = document.getElementById("loading");
if (show) {
loading.style.display = "block";
} else {
loading.style.display = "none";
}
}
</script>
</body>
</html>
get_iptv.php
<?php
// Get the channel name from the request
$channel = $_POST["url"];
// Build the URL with the channel name
$url = "https://api.pearktrue.cn/api/tv/search.php?name=$channel";
// Initialize the output variable
$output = "";
// Get the source code of the URL
$page = 1;
do {
$url_with_page = $url . "&page=$page";
$source = file_get_contents($url_with_page);
$json = json_decode($source, true);
// Check if the response has an error code or message
if (isset($json["code"]) && $json["code"] == 201) {
break;
} elseif (isset($json["msg"]) && $json["msg"] == "获取失败,当前页码无数据") {
break;
}
// Add the source to the output
$output .= $source;
$page++;
} while (true);
// Find the data in the output
$pattern = '/\\{
"videoname": "(.*?)",
"updatetime": "(.*?)",
"link": "(.*?)"
},/';
preg_match_all($pattern, $output, $matches);
// Output the data
if (count($matches[0]) > 0) {
for ($i = 0; $i < count($matches[0]); $i++) {
echo "{$matches[1][$i]},{$matches[3][$i]}<br>";
}
} else {
echo "抱歉,我无法找到相关内容。";
}
?>
这两个内容放在对应的html和php文件里,放在一个目录里访问域名就行
注:源码来自灵感软件库