diff --git a/docs/other.md b/docs/other.md index 174456d1a..c512f080e 100644 --- a/docs/other.md +++ b/docs/other.md @@ -396,7 +396,7 @@ type 为 all 时,category 参数不支持 cost 和 free ### 发现用户 - + 分类 | 推荐 | 最热 | @@ -413,7 +413,7 @@ type 为 all 时,category 参数不支持 cost 和 free ### 用户动态 - + ## 澳門特別行政區政府各公共部門獎助貸學金服務平台 @@ -427,15 +427,15 @@ type 为 all 时,category 参数不支持 cost 和 free -## 百度搜索风云榜 +## 百度热搜 ### 榜单 - + -| 实时热点 | 今日热点 | 七日热点 | 民生热点 | 娱乐热点 | 体育热点 | -| ---- | ---- | ---- | ---- | ---- | ---- | -| 1 | 341 | 42 | 342 | 344 | 11 | +| 热搜榜 | 小说榜 | 电影榜 | 电视剧榜 | 汽车榜 | 游戏榜 | +| -------- | ----- | ----- | -------- | --- | ---- | +| realtime | novel | movie | teleplay | car | game | diff --git a/lib/router.js b/lib/router.js index 12ea0f83a..84d59ee05 100644 --- a/lib/router.js +++ b/lib/router.js @@ -950,7 +950,7 @@ router.get('/geekpark/breakingnews', lazyloadRouteHandler('./routes/geekpark/bre // 百度 router.get('/baidu/doodles', lazyloadRouteHandler('./routes/baidu/doodles')); -router.get('/baidu/topwords/:boardId?', lazyloadRouteHandler('./routes/baidu/topwords')); +// router.get('/baidu/topwords/:boardId?', lazyloadRouteHandler('./routes/baidu/topwords')); router.get('/baidu/daily', lazyloadRouteHandler('./routes/baidu/daily')); // 搜狗 diff --git a/lib/routes/baidu/topwords.js b/lib/routes/baidu/topwords.js deleted file mode 100644 index cebab5f6d..000000000 --- a/lib/routes/baidu/topwords.js +++ /dev/null @@ -1,38 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const { boardId = 1 } = ctx.params; - const response = await got({ - method: 'get', - url: `http://top.baidu.com/mobile_v2/buzz?b=${boardId}`, - }); - - const { board, topwords, descs } = response.data.result; - const items = topwords.map((item, index) => { - const title = item.keyword; - const content = descs[index].content; - const desc = content - ? content.data[0] - : { - originlink: `https://www.baidu.com/s?ie=utf-8&wd=${encodeURIComponent(title)}`, - title, - description: title, - pubDate: Date.now(), - }; - - return { - title, - description: ` - ${desc.title}
- ${desc.description || ''} - `, - link: desc.originlink, - pubDate: new Date(desc.pubDate).toUTCString(), - }; - }); - - ctx.state.data = { - title: `百度搜索风云榜-${board.boardname}`, - item: items, - }; -}; diff --git a/lib/v2/baidu/maintainer.js b/lib/v2/baidu/maintainer.js index b63e79ea6..8e0f88c0f 100644 --- a/lib/v2/baidu/maintainer.js +++ b/lib/v2/baidu/maintainer.js @@ -5,4 +5,5 @@ module.exports = { '/tieba/post/:id': ['u3u'], '/tieba/post/lz/:id': ['u3u'], '/tieba/user/:uid': ['igxlin', 'nczitzk'], + '/top/:board?': ['xyqfer'], }; diff --git a/lib/v2/baidu/radar.js b/lib/v2/baidu/radar.js index 96e5ff46f..9803ecbcc 100644 --- a/lib/v2/baidu/radar.js +++ b/lib/v2/baidu/radar.js @@ -56,5 +56,13 @@ module.exports = { }, }, ], + top: [ + { + title: '热搜榜单', + docs: 'https://docs.rsshub.app/other.html#bai-du-re-sou', + source: ['/board'], + target: (_, url) => `/baidu/top/${new URL(url).searchParams.get('tab')}`, + }, + ], }, }; diff --git a/lib/v2/baidu/router.js b/lib/v2/baidu/router.js index 585f674c7..f01ef64f9 100644 --- a/lib/v2/baidu/router.js +++ b/lib/v2/baidu/router.js @@ -5,4 +5,5 @@ module.exports = (router) => { router.get('/tieba/post/:id', require('./tieba/post')); router.get('/tieba/post/lz/:id', require('./tieba/post')); router.get('/tieba/user/:uid', require('./tieba/user')); + router.get('/top/:board?', require('./top')); }; diff --git a/lib/v2/baidu/templates/top.art b/lib/v2/baidu/templates/top.art new file mode 100644 index 000000000..c7f4b680b --- /dev/null +++ b/lib/v2/baidu/templates/top.art @@ -0,0 +1,9 @@ +{{ if item.img }} +
+{{ /if }} +{{ if item.show }} + {{ each item.show s }} + {{ s }}
+ {{ /each }} +{{ /if }} +{{ item.desc }} diff --git a/lib/v2/baidu/top.js b/lib/v2/baidu/top.js new file mode 100644 index 000000000..2dfb374cf --- /dev/null +++ b/lib/v2/baidu/top.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { board = 'realtime' } = ctx.params; + const link = `https://top.baidu.com/board?tab=${board}`; + const { data: response } = await got(link); + + const $ = cheerio.load(response); + + const { data } = JSON.parse( + $('#sanRoot') + .contents() + .filter((e) => e.nodeType === 8) + .prevObject[0].data.match(/s-data:(.*)/)[1] + ); + + const items = data.cards[0].content.map((item) => ({ + title: item.word, + description: art(path.join(__dirname, 'templates/top.art'), { + item, + }), + link: item.rawUrl, + })); + + ctx.state.data = { + title: `${data.curBoardName} - 百度热搜`, + description: $('meta[name="description"]').attr('content'), + link, + item: items, + }; +};