From 0eea72fc7b83c656a66122aa7b3d8d8ea35285cf Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:31:14 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=B5=8B=E8=AF=95.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/测试.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/py/测试.py b/py/测试.py index 153302d..73673dd 100644 --- a/py/测试.py +++ b/py/测试.py @@ -113,6 +113,14 @@ for valid_url in valid_urls: # 确保这里是 valid_urls lines = json_data.split('\n') except UnicodeDecodeError: pass + text_data = response.content.decode('utf-8') + # 如果解码成功,处理 text_data + # 例如打印或进一步处理 + print(text_data) # 这里只是打印,你可以根据需要进行其他处理 + except UnicodeDecodeError: + # 如果出现 UnicodeDecodeError,打印错误信息并跳过当前循环 + print(f"无法解码来自 {url} 的响应内容,跳过此 URL。") + continue # 正则表达式匹配 #EXTINF 行 pattern = r"#EXTINF:-1 group-title=\"([^\"]+)\"," matches = re.finditer(pattern, json_data)