From 8180939675e794cd8bf9b792eb4d8b034564fea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E5=87=89?= Date: Tue, 4 Dec 2018 15:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E7=99=BE=E5=BA=A6-?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=A3=8E=E4=BA=91=E6=A6=9C=20(#1228)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1177 --- docs/README.md | 8 ++++++++ router.js | 1 + routes/baidu/topwords.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 routes/baidu/topwords.js diff --git a/docs/README.md b/docs/README.md index 4f7151439..a24306df6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2413,6 +2413,14 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运 + + +| 实时热点 | 今日热点 | 七日热点 | 民生热点 | 娱乐热点 | 体育热点 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| 1 | 341 | 42 | 342 | 344 | 11 | + + + ### 搜狗 diff --git a/router.js b/router.js index b50011315..2e634bce8 100644 --- a/router.js +++ b/router.js @@ -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')); diff --git a/routes/baidu/topwords.js b/routes/baidu/topwords.js new file mode 100644 index 000000000..61bcfe3ee --- /dev/null +++ b/routes/baidu/topwords.js @@ -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: ` + ${desc.title}
+ ${desc.description} + `, + link: desc.originlink, + pubDate: new Date(desc.pubDate).toUTCString(), + }; + }); + + ctx.state.data = { + title: `百度搜索风云榜-${board.boardname}`, + item: items, + }; +};