Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scraper.py #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一段貌似只处理了modal_id=存在在URL中的情况,是否可以使用urllib对URL进行拆分然后取值?

print("获取到的抖音用户ID为: {}".format(key))
return key
except Exception as e:
print('获取抖音视频ID出错了:{}'.format(e))
return None
Expand Down