From cf22e7cfa090b94fae4f3c9b754dba8f6de5b9ec Mon Sep 17 00:00:00 2001 From: Evil0ctal Date: Thu, 10 Nov 2022 13:03:00 -0800 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=9B=A0=20Fix=20regex=20to=20find=20Tik?= =?UTF-8?q?Tok=20video=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scraper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scraper.py b/scraper.py index db5c949..427f413 100644 --- a/scraper.py +++ b/scraper.py @@ -284,7 +284,10 @@ class Scraper: video_id = original_url.split('/')[-1] if '.html' in video_id: video_id = video_id.replace('.html', '') - video_id = re.findall('/video/(\d+)', original_url)[0] + elif '/video/' in video_id: + video_id = re.findall('/video/(\d+)', original_url)[0] + elif '/v/' in video_id: + video_id = re.findall('/v/(\d+)', original_url)[0] print('获取到的TikTok视频ID是{}'.format(video_id)) # 返回视频ID/Return video ID return video_id @@ -538,5 +541,5 @@ if __name__ == '__main__': api = Scraper() # 运行测试 douyin_url = 'https://v.douyin.com/rLyrQxA/6.66' - tiktok_url = 'https://vm.tiktok.com/ZMFf3HPbB/' + tiktok_url = 'https://vm.tiktok.com/ZTRx423kK/' asyncio.run(async_test(douyin_url=douyin_url, tiktok_url=tiktok_url))