From 259dd2c2707241d362153770df6c09badba90098 Mon Sep 17 00:00:00 2001 From: imsyy Date: Thu, 31 Jul 2025 23:39:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BE=AE=E5=8D=9A=E7=83=AD=E6=A6=9C=20#110?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router.types.d.ts | 3 +++ src/routes/weibo.ts | 35 +++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/router.types.d.ts b/src/router.types.d.ts index d51370e..4f727f6 100644 --- a/src/router.types.d.ts +++ b/src/router.types.d.ts @@ -82,6 +82,9 @@ export type RouterType = { }; weibo: { mid: string; + itemid: string; + desc: string; + scheme: string; word: string; word_scheme: string; note: string; diff --git a/src/routes/weibo.ts b/src/routes/weibo.ts index 4c0f37e..ae8f5b1 100644 --- a/src/routes/weibo.ts +++ b/src/routes/weibo.ts @@ -18,24 +18,35 @@ export const handleRoute = async (_: undefined, noCache: boolean) => { }; const getList = async (noCache: boolean) => { - const url = `https://weibo.com/ajax/side/hotSearch`; - const result = await get({ url, noCache, ttl: 60 }); - const list = result.data.data.realtime; + const url = + "https://m.weibo.cn/api/container/getIndex?containerid=106003type%3D25%26t%3D3%26disable_hot%3D1%26filter_type%3Drealtimehot&title=%E5%BE%AE%E5%8D%9A%E7%83%AD%E6%90%9C&extparam=filter_type%3Drealtimehot%26mi_cid%3D100103%26pos%3D0_0%26c_type%3D30%26display_time%3D1540538388&luicode=10000011&lfid=231583"; + + const result = await get({ + url, + noCache, + ttl: 60, + headers: { + Referer: "https://s.weibo.com/top/summary?cate=realtimehot", + "MWeibo-Pwa": "1", + "X-Requested-With": "XMLHttpRequest", + "User-Agent": + "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1", + }, + }); + const list = result.data.data.cards?.[0]?.card_group; return { ...result, data: list.map((v: RouterType["weibo"]) => { - const key = v.word_scheme ? v.word_scheme : `#${v.word}`; + const key = v.word_scheme ? v.word_scheme : `#${v.desc}`; return { - id: v.mid, - title: v.word, - desc: v.note || key, - author: v.flag_desc, + id: v.itemid, + title: v.desc, + desc: key, + // author: v.flag_desc, timestamp: getTime(v.onboard_time), - hot: v.num, + // hot: v.num, url: `https://s.weibo.com/weibo?q=${encodeURIComponent(key)}&t=31&band_rank=1&Refer=top`, - mobileUrl: `https://s.weibo.com/weibo?q=${encodeURIComponent( - key, - )}&t=31&band_rank=1&Refer=top`, + mobileUrl: v?.scheme, }; }), };