From 887748d2b176b6c14ca10917b7a68c0d427d4ea3 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Sun, 15 Sep 2024 12:06:49 +0800 Subject: [PATCH] =?UTF-8?q?Update=20IPTV=E6=90=9C=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E9=87=87=E9=9B=86.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/IPTV搜索引擎采集.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/py/IPTV搜索引擎采集.py b/py/IPTV搜索引擎采集.py index de99a49..4846f66 100644 --- a/py/IPTV搜索引擎采集.py +++ b/py/IPTV搜索引擎采集.py @@ -30,15 +30,19 @@ header = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" } -# 验证tonkiang可用IP +import requests +from lxml import etree + def via_tonking(url): headers = { 'Referer': 'http://tonkiang.us/hotellist.html', 'User-Agent': header["User-Agent"], } try: + # 提取 IP 地址部分,去除协议 + ip_address = url.split("//")[-1] response = requests.get( - url=f'http://tonkiang.us/alllist.php?s={url}&c=false&y=false', + url=f'http://tonkiang.us/hoteliptv.php?s={ip_address}&c=false&y=false', headers=headers, timeout=10 ) @@ -47,9 +51,10 @@ def via_tonking(url): div_text = et.xpath('//div[@class="result"]/div/text()')[1] return "暂时失效" not in div_text except Exception as e: - print(f"验证IP时发生错误: {e}") + print(f"验证 IP 时发生错误: {e}") return False + # 从tonkiang获取可用IP def get_tonkiang(keyword): data = {