From 9801c4c7ff73e8b1508deb2785a6b6e54cf442ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B4=9B?= <2443958507@qq.com> Date: Sat, 29 Nov 2025 15:14:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E5=8D=9A403?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更换了微博的API接口 --- src/routes/weibo.ts | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/routes/weibo.ts b/src/routes/weibo.ts index bf6ddfe..37d9973 100644 --- a/src/routes/weibo.ts +++ b/src/routes/weibo.ts @@ -19,43 +19,36 @@ export const handleRoute = async (_: undefined, noCache: boolean) => { }; const getList = async (noCache: boolean) => { - 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 url = "https://weibo.com/ajax/side/hotSearch"; 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", + Referer: "https://weibo.com/", "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", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", }, }); - const list = result.data.data.cards?.[0]?.card_group; + + if (!result.data?.data?.realtime) { + return { ...result, data: [] }; + } + + const list = result.data.data.realtime; return { ...result, - data: list - .filter( - (v: RouterType["weibo"]) => - !( - v?.pic === "https://simg.s.weibo.com/20210408_search_point_orange.png" && - config.FILTER_WEIBO_ADVERTISEMENT - ), - ) - .map((v: RouterType["weibo"]) => { - const key = v.word_scheme ?? `#${v.desc}`; - return { - id: v.itemid, - title: v.desc, - desc: key, - timestamp: getTime(v.onboard_time), - hot: v.desc_extr, - url: `https://s.weibo.com/weibo?q=${encodeURIComponent(key)}&t=31&band_rank=1&Refer=top`, - mobileUrl: v?.scheme, - }; - }), + data: list.map((v: any, index: number) => { + const title = v.word || v.word_scheme || `热搜${index + 1}`; + return { + id: v.mid || v.word_scheme || `weibo-${index}`, + title: title, + desc: v.word_scheme || `#${title}#`, + timestamp: getTime(v.onboard_time || Date.now()), + url: `https://s.weibo.com/weibo?q=${encodeURIComponent(title)}`, + mobileUrl: `https://s.weibo.com/weibo?q=${encodeURIComponent(title)}`, + }; + }), }; };