Skip to content

Commit

Permalink
🔧: Use retry to increase stability of TikTok APP API
Browse files Browse the repository at this point in the history
  • Loading branch information
Evil0ctal committed Sep 16, 2024
1 parent 538dd59 commit 2980490
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crawlers/tiktok/app/app_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
from crawlers.tiktok.app.endpoints import TikTokAPIEndpoints
from crawlers.utils.utils import model_to_query_string

# 重试机制
from tenacity import *

# TikTok接口数据请求模型
from crawlers.tiktok.app.models import (
BaseRequestModel, FeedVideoDetail
Expand Down Expand Up @@ -79,6 +82,7 @@ async def get_tiktok_headers(self):

# 获取单个作品数据
# @deprecated("TikTok APP fetch_one_video is deprecated and will be removed in a future release. Use Web API instead. | TikTok APP fetch_one_video 已弃用,将在将来的版本中删除。请改用Web API。")
@retry(stop=stop_after_attempt(10), wait=wait_fixed(1))
async def fetch_one_video(self, aweme_id: str):
# 获取TikTok的实时Cookie
kwargs = await self.get_tiktok_headers()
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ ua-parser==0.18.0
user-agents==2.2.0
uvicorn==0.29.0
websockets==12.0
gmssl==3.2.2
gmssl==3.2.2
tenacity~=9.0.0

0 comments on commit 2980490

Please sign in to comment.