Update 测试.py
This commit is contained in:
@@ -110,8 +110,13 @@ for valid_url in valid_urls: # 确保这里是 valid_urls
|
|||||||
# 发送GET请求获取JSON文件,设置超时时间为3秒
|
# 发送GET请求获取JSON文件,设置超时时间为3秒
|
||||||
response = requests.get(valid_url, timeout=3)
|
response = requests.get(valid_url, timeout=3)
|
||||||
json_data = response.content.decode('utf-8')
|
json_data = response.content.decode('utf-8')
|
||||||
lines = json_data.split('\n')
|
# 如果解码成功,处理 json_data
|
||||||
|
# 例如打印或进一步处理
|
||||||
|
print(json_data)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
# 如果出现 UnicodeDecodeError,打印错误信息并跳过当前循环
|
||||||
|
print(f"无法解码来自 {url} 的响应内容,跳过此 URL。")
|
||||||
|
continue
|
||||||
# 正则表达式匹配 #EXTINF 行
|
# 正则表达式匹配 #EXTINF 行
|
||||||
pattern = r"#EXTINF:-1 group-title=\"([^\"]+)\","
|
pattern = r"#EXTINF:-1 group-title=\"([^\"]+)\","
|
||||||
matches = re.finditer(pattern, json_data)
|
matches = re.finditer(pattern, json_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user