Update IPTV搜索引擎采集.py
This commit is contained in:
+8
-4
@@ -70,10 +70,14 @@ def get_tonkiang(keyword):
|
|||||||
try:
|
try:
|
||||||
status = div.xpath('./div[3]/div/text()')[0]
|
status = div.xpath('./div[3]/div/text()')[0]
|
||||||
if "暂时失效" not in status:
|
if "暂时失效" not in status:
|
||||||
ip = div.xpath('./div[1]/a/b/text()')[0].strip()
|
# 尝试提取IP地址或域名
|
||||||
if via_tonking(ip):
|
ip_or_domain = div.xpath('./div[1]/a/b/text()')[0].strip()
|
||||||
result_urls.append(f'http://{ip}')
|
# 解析IP地址或域名
|
||||||
except (IndexError, ValueError):
|
parsed_url = urlparse(f'http://{ip_or_domain}')
|
||||||
|
if parsed_url.scheme and parsed_url.netloc:
|
||||||
|
if via_tonking(parsed_url.geturl()):
|
||||||
|
result_urls.append(parsed_url.geturl())
|
||||||
|
except (IndexError, ValueError, AttributeError):
|
||||||
continue
|
continue
|
||||||
return result_urls
|
return result_urls
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user