mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-05-26 04:27:27 +08:00
feat: 添加海外版小红书(rednote.com)支持
This commit is contained in:
@@ -57,8 +57,12 @@ class XiaoHongShuClient(AbstractApiClient, ProxyRefreshMixin):
|
||||
self.proxy = proxy
|
||||
self.timeout = timeout
|
||||
self.headers = headers
|
||||
self._host = "https://edith.xiaohongshu.com"
|
||||
self._domain = "https://www.xiaohongshu.com"
|
||||
if config.XHS_INTERNATIONAL:
|
||||
self._host = "https://webapi.rednote.com"
|
||||
self._domain = "https://www.rednote.com"
|
||||
else:
|
||||
self._host = "https://edith.xiaohongshu.com"
|
||||
self._domain = "https://www.xiaohongshu.com"
|
||||
self.IP_ERROR_STR = "Network connection error, please check network settings or restart"
|
||||
self.IP_ERROR_CODE = 300012
|
||||
self.NOTE_NOT_FOUND_CODE = -510000
|
||||
@@ -681,7 +685,7 @@ class XiaoHongShuClient(AbstractApiClient, ProxyRefreshMixin):
|
||||
|
||||
"""
|
||||
url = (
|
||||
"https://www.xiaohongshu.com/explore/"
|
||||
f"{self._domain}/explore/"
|
||||
+ note_id
|
||||
+ f"?xsec_token={xsec_token}&xsec_source={xsec_source}"
|
||||
)
|
||||
|
||||
@@ -55,7 +55,7 @@ class XiaoHongShuCrawler(AbstractCrawler):
|
||||
cdp_manager: Optional[CDPBrowserManager]
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.index_url = "https://www.xiaohongshu.com"
|
||||
self.index_url = "https://www.rednote.com" if config.XHS_INTERNATIONAL else "https://www.xiaohongshu.com"
|
||||
# self.user_agent = utils.get_user_agent()
|
||||
self.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
||||
self.cdp_manager = None
|
||||
@@ -364,10 +364,10 @@ class XiaoHongShuCrawler(AbstractCrawler):
|
||||
"accept-language": "zh-CN,zh;q=0.9",
|
||||
"cache-control": "no-cache",
|
||||
"content-type": "application/json;charset=UTF-8",
|
||||
"origin": "https://www.xiaohongshu.com",
|
||||
"origin": self.index_url,
|
||||
"pragma": "no-cache",
|
||||
"priority": "u=1, i",
|
||||
"referer": "https://www.xiaohongshu.com/",
|
||||
"referer": f"{self.index_url}/",
|
||||
"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"',
|
||||
|
||||
@@ -219,6 +219,6 @@ class XiaoHongShuLogin(AbstractLogin):
|
||||
await self.browser_context.add_cookies([{
|
||||
'name': key,
|
||||
'value': value,
|
||||
'domain': ".xiaohongshu.com",
|
||||
'domain': ".rednote.com" if config.XHS_INTERNATIONAL else ".xiaohongshu.com",
|
||||
'path': "/"
|
||||
}])
|
||||
|
||||
Reference in New Issue
Block a user