增加: 技术头条 (#1077)
* 增加:有品-每日上新 * 修复 summary 字段错误 * 将 youpin 模块转移至 mi 目录下,并更新文档 * 增加: 技术头条
This commit is contained in:
parent
e2218f84f7
commit
b29ef8f941
|
|
@ -730,6 +730,10 @@ GitHub 官方也提供了一些 RSS:
|
|||
|
||||
</route>
|
||||
|
||||
### 技术头条
|
||||
|
||||
<route name="最新分享" author="xyqfer" example="/blogread/newest" path="/blogread/newest"/>
|
||||
|
||||
## 直播
|
||||
|
||||
### 哔哩哔哩直播
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue