diff --git a/TikTok.py b/TikTok.py index 3e687ee..66f753a 100644 --- a/TikTok.py +++ b/TikTok.py @@ -513,9 +513,12 @@ class TikTok(object): # 保存获取到的字典信息 print("[ 提示 ]:正在保存获取到的信息到 result.json\r\n") - with open(os.path.join(aweme_path, "result.json"), "w", encoding='utf-8') as f: - f.write(json.dumps(awemeDict, ensure_ascii=False, indent=2)) - f.close() + try: + with open(os.path.join(aweme_path, "result.json"), "w", encoding='utf-8') as f: + f.write(json.dumps(awemeDict, ensure_ascii=False, indent=2)) + f.close() + except Exception as e: + print("[ 错误 ]:保存 result.json 出错\r\n") # 下载 视频 if awemeDict["awemeType"] == 0: diff --git a/TikTokUtils.py b/TikTokUtils.py index ac9362b..4cdfdec 100644 --- a/TikTokUtils.py +++ b/TikTokUtils.py @@ -67,15 +67,15 @@ class Utils(object): xbogus = execjs.compile(open(self.resource_path(os.path.join("X-Bogus.js"))).read()).call('sign', url, user_agent) params = url + "&X-Bogus=" + xbogus except Exception as e: - print('[ 错误 ]:X-Bogus算法异常或者本地没有JS环境') + # print('[ 错误 ]:X-Bogus算法异常或者本地没有JS环境') try: - print('[ 提示 ]:尝试远程调用X-Bogus接口') + # print('[ 提示 ]:尝试远程调用X-Bogus接口') response = json.loads(requests.post( url=Urls().GET_XB_PATH, data={"param": url}, headers=headers).text) params = response["param"] xbogus = response["X-Bogus"] except Exception as e: - print('[ 错误 ]:X-Bogus接口异常, 可能是访问流量高, 接口限流请稍等几分钟再次尝试') + # print('[ 错误 ]:X-Bogus接口异常, 可能是访问流量高, 接口限流请稍等几分钟再次尝试') return return params