diff options
| author | blackhao <13851610112@163.com> | 2025-04-28 23:17:35 -0500 |
|---|---|---|
| committer | blackhao <13851610112@163.com> | 2025-04-28 23:17:35 -0500 |
| commit | 7dfacb1dc9e4093121e05854a510525a41a5858d (patch) | |
| tree | c03ec516f338cd809d91623768a8f66a900ec72e | |
| parent | 1aa82ba951444e985775a55a5bb99e766aa84c31 (diff) | |
add header
| -rw-r--r-- | fetch_update.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fetch_update.py b/fetch_update.py index d055dad..a653d0f 100644 --- a/fetch_update.py +++ b/fetch_update.py @@ -10,11 +10,19 @@ BASE_URL = "https://api.aicu.cc/api/v3/search/getreply" UID = int(os.getenv("BILIBILI_UID", "1")) # 改成目标 UID,或在 Actions secrets 中设 EXCEL_FILE = pathlib.Path("replies.xlsx") MAX_P_PAGE = 500 +HEADERS = { + "User-Agent": ( + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/123.0 Safari/537.36" + ), + # "Referer": "https://www.aicu.cc/", # 如果仍 403 就把这行放开 +} def fetch_all(uid: int): replies, pn = [], 1 while True: - r = requests.get(BASE_URL, params=dict(uid=uid, pn=pn, ps=MAX_P_PAGE, mode=0), timeout=15) + r = requests.get(BASE_URL, params=dict(uid=uid, pn=pn, ps=MAX_P_PAGE, mode=0), headers=HEADERS, timeout=15) r.raise_for_status() data = r.json() if data.get("code") != 0: |
