增加:百度-搜索风云榜 (#1228)

Closes #1177
This commit is contained in:
凉凉 2018-12-04 15:34:41 +08:00 committed by DIYgod
parent b207bc0e10
commit 8180939675
3 changed files with 38 additions and 0 deletions

View File

@ -2413,6 +2413,14 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
<route name="百度趣画" author="xyqfer" example="/baidu/doodles" path="/baidu/doodles"/>
<route name="搜索风云榜" author="xyqfer" example="/baidu/topwords/1" path="/baidu/topwords/:boardId?" :paramsDesc="['榜单 id, 默认为`1`']">
| 实时热点 | 今日热点 | 七日热点 | 民生热点 | 娱乐热点 | 体育热点 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| 1 | 341 | 42 | 342 | 344 | 11 |
</route>
### 搜狗
<route name="搜狗特色LOGO" author="xyqfer" example="/sogou/doodles" path="/sogou/doodles"/>

View File

@ -776,6 +776,7 @@ router.get('/geekpark/breakingnews', require('./routes/geekpark/breakingnews'));
// 百度
router.get('/baidu/doodles', require('./routes/baidu/doodles'));
router.get('/baidu/topwords/:boardId?', require('./routes/baidu/topwords'));
// 搜狗
router.get('/sogou/doodles', require('./routes/sogou/doodles'));

29
routes/baidu/topwords.js Normal file
View File

@ -0,0 +1,29 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const { boardId = 1 } = ctx.params;
const response = await axios({
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 desc = descs[index].content.data[0];
return {
title: item.keyword,
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,
};
};