feat: 添加码农周刊 (#3291)

This commit is contained in:
仝华帅
2019-10-21 14:55:50 +08:00
committed by DIYgod
parent a226c6ac59
commit d886166575
4 changed files with 48 additions and 0 deletions

View File

@@ -471,6 +471,12 @@ GitHub 官方也提供了一些 RSS:
</Route> </Route>
## 码农周刊
### issues
<Route author="tonghs" example="/manong-weekly" path="/manong-weekly" />
## 前端艺术家&&飞冰早报 ## 前端艺术家&&飞冰早报
### 列表 ### 列表

View File

@@ -33,6 +33,12 @@ pageClass: routes
</Route> </Route>
## 码农周刊
### issues
<Route author="tonghs" example="/manong-weekly" path="/manong-weekly" />
## 扇贝 ## 扇贝
### 用户打卡 ### 用户打卡

View File

@@ -1871,4 +1871,7 @@ router.get('/mcbbs/post/:tid/:authorid?', require('./routes/mcbbs/post'));
// Pocket // Pocket
router.get('/pocket/trending', require('./routes/pocket/trending')); router.get('/pocket/trending', require('./routes/pocket/trending'));
// 码农周刊
router.get('/manong-weekly', require('./routes/manong-weekly/issues'));
module.exports = router; module.exports = router;

View File

@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = 'https://weekly.manong.io/issues/';
const response = await got({
rejectUnauthorized: false,
method: 'get',
url,
});
const $ = cheerio.load(response.data);
const resultItem = $('.issue')
.map((index, elem) => {
elem = $(elem);
const $link = elem.find('a');
const title = $link.text();
const link = $link.attr('href');
const description = elem.find('p').text();
return {
title,
link,
description,
};
})
.get();
ctx.state.data = {
title: '码农周刊',
link: url,
item: resultItem,
};
};