Skip to content

Commit

Permalink
🐛 fix: touch home page to avoid anti-crawler error
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Nov 14, 2023
1 parent 1a96bd2 commit 5f49f5d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions yutto/api/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def get_user_name(session: ClientSession, mid: MId) -> str:
params = {"mid": mid}
params = encode_wbi(params, wbi_img)
space_info_api = "https://api.bilibili.com/x/space/wbi/acc/info"
await Fetcher.touch_url(session, "https://www.bilibili.com")
user_info = await Fetcher.fetch_json(session, space_info_api, params=params)
assert user_info is not None
return user_info["data"]["name"]
Expand Down
2 changes: 1 addition & 1 deletion yutto/utils/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Fetcher:
proxy: str | None = None
trust_env: bool = True
headers: dict[str, str] = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
"Referer": "https://www.bilibili.com",
}
cookies = {}
Expand Down

0 comments on commit 5f49f5d

Please sign in to comment.