mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-06-02 15:10:15 +00:00
修复使用wan2选项时'立即检测一次'无法使用,增加一个检测多wan出口url
This commit is contained in:
@@ -316,7 +316,7 @@ class MySender:
|
||||
|
||||
|
||||
class IpLocationParser:
|
||||
def __init__(self, settings_file_path, max_ips=4):
|
||||
def __init__(self, settings_file_path, max_ips=3):
|
||||
self._settings_file_path = settings_file_path
|
||||
self._max_ips = max_ips # 最大历史IP数量
|
||||
self._ips = self.read_ips("ips") # 初始化时读取已存储的 IP 地址
|
||||
@@ -327,7 +327,7 @@ class IpLocationParser:
|
||||
parser_methods = {
|
||||
"https://ip.orz.tools": IpLocationParser._parse_ip_orz_tools,
|
||||
"https://ip.skk.moe/multi": IpLocationParser._parse_ip_skk_moe,
|
||||
"http://revproxy.ustc.edu.cn:8000": IpLocationParser._parse_ip_ustc,
|
||||
"https://ip.m27.tech": IpLocationParser._parse_ip_m27,
|
||||
}
|
||||
parser_method = parser_methods.get(url)
|
||||
if parser_method is None:
|
||||
@@ -405,25 +405,25 @@ class IpLocationParser:
|
||||
return IpLocationParser._remove_duplicates(ipv4_addresses, locations)
|
||||
|
||||
@staticmethod
|
||||
def _parse_ip_ustc(page):
|
||||
def _parse_ip_m27(page):
|
||||
"""解析 https://ip.m27.tech 页面中的 IP 和归属地"""
|
||||
rows = page.query_selector_all(
|
||||
'body > div:nth-child(4) > center > table > tbody > tr > td:nth-child(2)'
|
||||
'body > div > div.panel.panel-success > div.panel-body > table > tbody > tr'
|
||||
)
|
||||
# print(f"ip_ustc共找到 {len(rows)} 行数据")
|
||||
# print(f"共找到 {len(rows)} 行数据")
|
||||
ipv4_addresses, locations = [], []
|
||||
|
||||
for row in rows:
|
||||
row_text = row.inner_text().strip()
|
||||
|
||||
# 提取 IP 地址
|
||||
ip_match = re.match(r'(\d+\.\d+\.\d+\.\d+)', row_text)
|
||||
ip_match = re.search(r'(\d+\.\d+\.\d+\.\d+)', row_text)
|
||||
if ip_match:
|
||||
ip = ip_match.group(1).strip()
|
||||
if not IpLocationParser._is_valid_ipv4(ip):
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
||||
#
|
||||
# 提取归属地
|
||||
location_match = re.search(r'(China|中国).*', row_text)
|
||||
location = location_match.group(0).strip() if location_match else "未知"
|
||||
@@ -439,7 +439,7 @@ class IpLocationParser:
|
||||
# 导航到目标页面
|
||||
page.goto(url)
|
||||
# 等待一段时间,让所有动态渲染的内容加载完成
|
||||
page.wait_for_timeout(10000) # 等待 10 秒钟
|
||||
page.wait_for_timeout(8000) # 等待 8 秒钟
|
||||
# 调用解析器解析数据
|
||||
ipv4_addresses, locations = IpLocationParser._parse(page, url)
|
||||
# 筛选出属于中国的 IP 地址
|
||||
|
||||
Reference in New Issue
Block a user