From fc06c783f5013fc00905365da19fbcb687b31584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Wed, 23 Jul 2025 13:28:58 +0800 Subject: [PATCH] fix: fixed xhs req headers --- media_platform/xhs/core.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/media_platform/xhs/core.py b/media_platform/xhs/core.py index ed64591..4eb563e 100644 --- a/media_platform/xhs/core.py +++ b/media_platform/xhs/core.py @@ -404,11 +404,22 @@ class XiaoHongShuCrawler(AbstractCrawler): xhs_client_obj = XiaoHongShuClient( proxies=httpx_proxy, headers={ - "User-Agent": self.user_agent, + "accept": "application/json, text/plain, */*", + "accept-language": "zh-CN,zh;q=0.9", + "cache-control": "no-cache", + "content-type": "application/json;charset=UTF-8", + "origin": "https://www.xiaohongshu.com", + "pragma": "no-cache", + "priority": "u=1, i", + "referer": "https://www.xiaohongshu.com/", + "sec-ch-ua": '"Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-site", + "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36", "Cookie": cookie_str, - "Origin": "https://www.xiaohongshu.com", - "Referer": "https://www.xiaohongshu.com", - "Content-Type": "application/json;charset=UTF-8", }, playwright_page=self.context_page, cookie_dict=cookie_dict,