fix(route): baidu top (#11754)
This commit is contained in:
parent
2ae299f978
commit
69ba50d69b
|
|
@ -396,7 +396,7 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
|
||||
### 发现用户
|
||||
|
||||
<Route author="sanmmm" example="/afdian/explore/hot/所有" path="/afdian/explore/:type/:category?" :paramsDesc="['分类', '目录类型, 默认为 `所有`']">
|
||||
<Route author="sanmmm" example="/afdian/explore/hot/所有" path="/afdian/explore/:type/:category?" :paramsDesc="['分类', '目录类型,默认为 `所有`']">
|
||||
分类
|
||||
|
||||
| 推荐 | 最热 |
|
||||
|
|
@ -413,7 +413,7 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
|
||||
### 用户动态
|
||||
|
||||
<Route author="sanmmm" example="/afdian/dynamic/@afdian" path="/afdian/dynamic/:uid?" :paramsDesc="['用户id, 用户动态页面url里可找到']"/>
|
||||
<Route author="sanmmm" example="/afdian/dynamic/@afdian" path="/afdian/dynamic/:uid?" :paramsDesc="['用户id,用户动态页面url里可找到']"/>
|
||||
|
||||
## 澳門特別行政區政府各公共部門獎助貸學金服務平台
|
||||
|
||||
|
|
@ -427,15 +427,15 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
|
||||
</Route>
|
||||
|
||||
## 百度搜索风云榜
|
||||
## 百度热搜
|
||||
|
||||
### 榜单
|
||||
|
||||
<Route author="xyqfer" example="/baidu/topwords/1" path="/baidu/topwords/:boardId?" :paramsDesc="['榜单 id, 默认为`1`']">
|
||||
<Route author="xyqfer" example="/baidu/top" path="/baidu/top/:board?" :paramsDesc="['榜单,默认为 `realtime`']" radar="1">
|
||||
|
||||
| 实时热点 | 今日热点 | 七日热点 | 民生热点 | 娱乐热点 | 体育热点 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| 1 | 341 | 42 | 342 | 344 | 11 |
|
||||
| 热搜榜 | 小说榜 | 电影榜 | 电视剧榜 | 汽车榜 | 游戏榜 |
|
||||
| -------- | ----- | ----- | -------- | --- | ---- |
|
||||
| realtime | novel | movie | teleplay | car | game |
|
||||
|
||||
</Route>
|
||||
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
// 搜狗
|
||||
|
|
|
|||
|
|
@ -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: `
|
||||
<a href="${desc.originlink}">${desc.title}</a><br>
|
||||
${desc.description || ''}
|
||||
`,
|
||||
link: desc.originlink,
|
||||
pubDate: new Date(desc.pubDate).toUTCString(),
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `百度搜索风云榜-${board.boardname}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -5,4 +5,5 @@ module.exports = {
|
|||
'/tieba/post/:id': ['u3u'],
|
||||
'/tieba/post/lz/:id': ['u3u'],
|
||||
'/tieba/user/:uid': ['igxlin', 'nczitzk'],
|
||||
'/top/:board?': ['xyqfer'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{{ if item.img }}
|
||||
<img src="{{ item.img }}"><br>
|
||||
{{ /if }}
|
||||
{{ if item.show }}
|
||||
{{ each item.show s }}
|
||||
{{ s }}<br>
|
||||
{{ /each }}
|
||||
{{ /if }}
|
||||
{{ item.desc }}
|
||||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue