From c7d48dd4f9a64206c7a7553b8501a1b7b6023bd6 Mon Sep 17 00:00:00 2001 From: Chen <36214945+chen-rn@users.noreply.github.com> Date: Mon, 17 Jul 2023 14:25:26 -0700 Subject: [PATCH] Update scraper.py bug fix, if you enter a url that comes from the user profile page(like the following) it would not return any user id. https://www.douyin.com/user/MS4wLjABAAAA6MgkojtAI7ZEK-vcJIly157umW6ANrtsAvk9QUar98XntKAYsFHO3WxCFLUYFWYI?modal_id=7222522822483103010 --- scraper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scraper.py b/scraper.py index a9edab53b6..6ba3690b7d 100644 --- a/scraper.py +++ b/scraper.py @@ -257,6 +257,12 @@ async def get_douyin_video_id(self, original_url: str) -> Union[str, None]: key = re.findall('/note/(\d+)?', video_url)[0] print('获取到的抖音笔记ID为: {}'.format(key)) return key + # 个人主页 + elif "user" in video_url: + # https://www.douyin.com/user/MS4wLjABAAAA6MgkojtAI7ZEK-vcJIly157umW6ANrtsAvk9QUar98XntKAYsFHO3WxCFLUYFWYI?modal_id=7222522822483103010 + key = re.findall("modal_id=(\d+)", video_url)[0] + print("获取到的抖音用户ID为: {}".format(key)) + return key except Exception as e: print('获取抖音视频ID出错了:{}'.format(e)) return None