From 3808040fc728d15aeae1a48f362733ea59300fe8 Mon Sep 17 00:00:00 2001 From: ihmily <961532186@qq.com> Date: Thu, 14 Sep 2023 00:52:36 +0800 Subject: [PATCH] Fix douyin record bug --- main.py | 2 +- spider.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 71934f0..6680a1f 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,7 @@ from web_rid import * from msg_push import * # 版本号 -version = "v1.0.7" +version = "v1.0.8" platforms = "抖音|Tiktok|快手|虎牙|斗鱼|YY|B站" # --------------------------log日志------------------------------------- diff --git a/spider.py b/spider.py index 885c1f2..ece60cc 100644 --- a/spider.py +++ b/spider.py @@ -4,7 +4,7 @@ Author: Hmily Github:https://github.com/ihmily Date: 2023-07-15 23:15:00 -Update: 2023-09-07 20:25:16 +Update: 2023-09-14 00:27:55 Copyright (c) 2023 by Hmily, All Rights Reserved. Function: Get live stream data. """ @@ -41,7 +41,10 @@ def get_douyin_stream_data(url, cookies=''): req = urllib.request.Request(url, headers=headers) response = opener.open(req, timeout=15) html_str = response.read().decode('utf-8') - json_str = re.findall(r'(\{\\\"state\\\"\:\{\\\"appStore\\\"\:.*?)\]\\n\"\]\)', html_str)[-1] + match_json_str = re.search(r'(\{\\\"state\\\"\:.*?)\]\\n\"\]\)', html_str) + if not match_json_str: + match_json_str = re.search(r'(\{\\\"common\\\"\:.*?)\]\\n\"\]\)\<\/script\>\