From 82f983793cf10cfbd1af3e6683dea59c85f5062d Mon Sep 17 00:00:00 2001
From: xuan <27200289+wuaishare@users.noreply.github.com>
Date: Thu, 18 Dec 2025 17:35:48 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=99=8E=E5=97=85=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
改为抓取虎嗅移动端页面的 window.__NUXT__ 内联数据,使用移动 UA/Referer 获取有效列表。
解析 NUxT 数据时处理 moment_id/origin_publish_time,生成正确的链接与时间戳。
重新拆分内容:以首行作标题(去掉末尾句号),其余行合并为描述,避免标题夹带全文、描述为空。
增加结构缺失和解析失败的错误提示,便于排查。
---
src/routes/huxiu.ts | 67 +++++++++++++++++++++++++++++----------------
1 file changed, 44 insertions(+), 23 deletions(-)
mode change 100644 => 100755 src/routes/huxiu.ts
diff --git a/src/routes/huxiu.ts b/src/routes/huxiu.ts
old mode 100644
new mode 100755
index 7a04b32..8906d13
--- a/src/routes/huxiu.ts
+++ b/src/routes/huxiu.ts
@@ -16,36 +16,57 @@ export const handleRoute = async (_: undefined, noCache: boolean) => {
return routeData;
};
-// 标题处理
-const titleProcessing = (text: string) => {
- const paragraphs = text.split("
");
- const title = paragraphs.shift()?.replace(/。$/, "");
- const intro = paragraphs.join("
");
- return { title, intro };
-};
-
const getList = async (noCache: boolean) => {
- const url = `https://www.huxiu.com/moment/`;
+ // 使用移动端页面,数据通过 window.__NUXT__ 内联
+ const url = `https://m.huxiu.com/moment/`;
const result = await get({
url,
noCache,
+ headers: {
+ "User-Agent":
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1",
+ Referer: "https://m.huxiu.com/moment/",
+ },
+ responseType: "text",
});
- // 正则查找
- const pattern =
- /