diff --git a/main.py b/main.py index ca368fc..42e78d8 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,7 @@ from tqdm import trange, tqdm import requests import time import platform +import chardet texts = list() all_friends = list() @@ -237,7 +238,9 @@ if __name__ == '__main__': signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) for i in trange(int(count / 100) + 1, desc='Progress', unit='100条'): - message = Request.get_message(i * 100, 100).content.decode('utf-8') + content_bytes = Request.get_message(i * 100, 100).content + detected_encoding = chardet.detect(content_bytes)['encoding'] + message = content_bytes.decode(detected_encoding if detected_encoding else "utf-8") time.sleep(0.2) html = Tools.process_old_html(message) if "li" not in html: diff --git a/requirements.txt b/requirements.txt index 04d1b16..71b1d5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,6 @@ Pillow==11.0.0 pyarrow==18.0.0 openpyxl==3.1.5 pyzbar~=0.1.9 -qrcode~=8.0 -fake-useragent \ No newline at end of file +qrcode~=7.4.2 +fake-useragent~=1.5.1 +chardet~=5.2.0 \ No newline at end of file