diff --git a/docs/README.md b/docs/README.md index c7a72b9b42..621ddaa1f8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -730,6 +730,10 @@ GitHub 官方也提供了一些 RSS: +### 技术头条 + + + ## 直播 ### 哔哩哔哩直播 diff --git a/router.js b/router.js index 1e63fa7663..767e0cb8c7 100644 --- a/router.js +++ b/router.js @@ -753,6 +753,9 @@ router.get('/hko/weather', require('./routes/hko/weather')); // sankakucomplex router.get('/sankakucomplex/post', require('./routes/sankakucomplex/post')); +// 技术头条 +router.get('/blogread/newest', require('./routes/blogread/newest')); + // gnn游戏新闻 router.get('/gnn/gnn', require('./routes/gnn/gnn')); diff --git a/routes/blogread/newest.js b/routes/blogread/newest.js new file mode 100644 index 0000000000..9af3e8d5c2 --- /dev/null +++ b/routes/blogread/newest.js @@ -0,0 +1,42 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://blogread.cn/news/newest.php'; + const response = await axios({ + method: 'get', + url, + }); + const $ = cheerio.load(response.data); + const resultItem = $('.media') + .map((index, elem) => { + elem = $(elem); + const $link = elem.find('dt a'); + const pubDate = elem + .find('.small') + .text() + .match(/\s[0-9-]+\s[0-9:]+\s/g)[0] + .trim(); + + return { + title: $link.text(), + description: elem + .find('dd') + .eq(0) + .text(), + link: $link.attr('href'), + pubDate: new Date(pubDate).toUTCString(), + author: elem + .find('.small a') + .eq(0) + .text(), + }; + }) + .get(); + + ctx.state.data = { + title: '技术头条', + link: url, + item: resultItem, + }; +};