From 1e3637f23851c9acf336076a67b8e82a579e0c07 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: Mon, 10 Nov 2025 18:13:51 +0800 Subject: [PATCH] refactor: update xhs note detail --- config/xhs_config.py | 2 +- media_platform/xhs/core.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config/xhs_config.py b/config/xhs_config.py index 2359b96..434afd0 100644 --- a/config/xhs_config.py +++ b/config/xhs_config.py @@ -17,7 +17,7 @@ SORT_TYPE = "popularity_descending" # 指定笔记URL列表, 必须要携带xsec_token参数 XHS_SPECIFIED_NOTE_URL_LIST = [ - "https://www.xiaohongshu.com/explore/68f99f6d0000000007033fcf?xsec_token=ABZEzjuN2fPjKF9EcMsCCxfbt3IBRsFZldGFoCJbdDmXI=&xsec_source=pc_feed" + "https://www.xiaohongshu.com/explore/64b95d01000000000c034587?xsec_token=AB0EFqJvINCkj6xOCKCQgfNNh8GdnBC_6XecG4QOddo3Q=&xsec_source=pc_cfeed" # ........................ ] diff --git a/media_platform/xhs/core.py b/media_platform/xhs/core.py index 68d2139..73c1c02 100644 --- a/media_platform/xhs/core.py +++ b/media_platform/xhs/core.py @@ -279,12 +279,19 @@ class XiaoHongShuCrawler(AbstractCrawler): Dict: note detail """ note_detail = None + utils.logger.info(f"[get_note_detail_async_task] Begin get note detail, note_id: {note_id}") async with semaphore: try: - utils.logger.info(f"[get_note_detail_async_task] Begin get note detail, note_id: {note_id}") - note_detail = await self.xhs_client.get_note_by_id_from_html(note_id, xsec_source, xsec_token, enable_cookie=True) + try: + note_detail = await self.xhs_client.get_note_by_id(note_id, xsec_source, xsec_token) + except RetryError: + pass + if not note_detail: - raise Exception(f"[get_note_detail_async_task] Failed to get note detail, Id: {note_id}") + note_detail = await self.xhs_client.get_note_by_id_from_html(note_id, xsec_source, xsec_token, + enable_cookie=True) + if not note_detail: + raise Exception(f"[get_note_detail_async_task] Failed to get note detail, Id: {note_id}") note_detail.update({"xsec_token": xsec_token, "xsec_source": xsec_source})