feat: add 搜韵网诗词日历 (#5430)

Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
Ethan Shen
2020-08-18 21:08:59 +01:00
committed by GitHub
co-authored by Henry Wang
parent 7b9fd58e38
commit 087699ff5f
3 changed files with 49 additions and 0 deletions
+6
View File
@@ -172,6 +172,12 @@ pageClass: routes
</Route>
## 搜韵网
### 诗词日历
<Route author="nczitzk" example="/souyun/today" path="/souyun/today"/>
## 网易公开课
### 精品课程
+3
View File
@@ -3061,6 +3061,9 @@ router.get('/telecompaper/news/:caty/:year?/:country?/:type?/:keyword?', require
// 水木社区
router.get('/newsmth/account/:id', require('./routes/newsmth/account'));
// 搜韵网
router.get('/souyun/today', require('./routes/souyun/today'));
// 生物谷
router.get('/bioon/latest', require('./routes/bioon/latest'));
+40
View File
@@ -0,0 +1,40 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const currentUrl = 'https://sou-yun.cn/AncientToday.aspx';
const poemUrl = 'https://api.sou-yun.cn/api/RecommendedReading?type=poem&needHtml=true';
const wordUrl = 'https://api.sou-yun.cn/api/RecommendedReading?type=word';
const response = await got({
method: 'get',
url: currentUrl,
});
const poemResponse = await got({
method: 'get',
url: poemUrl,
});
const wordResponse = await got({
method: 'get',
url: wordUrl,
});
const $ = cheerio.load(response.data);
const birthday = $('span.titleHint').parent().html();
const today = $('input[name="LastSelectedDate"]').attr('value');
ctx.state.data = {
title: '搜韵网 - 诗词日历',
link: currentUrl,
item: [
{
title: poemResponse.data.Date,
link: currentUrl,
description: poemResponse.data.Content.Text + '<br>' + birthday + '<br>' + wordResponse.data.Content.Text,
pubDate: new Date(today + ' GMT+8').toUTCString(),
},
],
};
};