增加Say花火 (#1984)

This commit is contained in:
junfengP
2019-04-25 12:06:46 +08:00
committed by DIYgod
parent 53c25b3084
commit 5de618fc88
3 changed files with 48 additions and 0 deletions

View File

@@ -26,6 +26,10 @@
<Route name="文章" author="DIYgod" example="/mmgal" path="/mmgal"/> <Route name="文章" author="DIYgod" example="/mmgal" path="/mmgal"/>
## say 花火
<Route name="文章" author="junfengP" example="/sayhuahuo" path="/sayhuahuo"/>
## 终点分享 ## 终点分享
<Route name="最新汉化" author="junfengP" example="/zdfx" path="/zdfx"/> <Route name="最新汉化" author="junfengP" example="/zdfx" path="/zdfx"/>

View File

@@ -577,6 +577,9 @@ router.get('/gitlab/explore/:type', require('./routes/gitlab/explore'));
router.get('/mygalgame', require('./routes/galgame/mmgal')); router.get('/mygalgame', require('./routes/galgame/mmgal'));
router.get('/mmgal', require('./routes/galgame/mmgal')); router.get('/mmgal', require('./routes/galgame/mmgal'));
// say花火
router.get('/sayhuahuo', require('./routes/galgame/sayhuahuo'));
// 终点分享 // 终点分享
router.get('/zdfx', require('./routes/galgame/zdfx')); router.get('/zdfx', require('./routes/galgame/zdfx'));

View File

@@ -0,0 +1,41 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const res = await axios({
method: 'get',
url: 'https://index.say-huahuo.com/',
header: {
Referer: 'https://index.say-huahuo.com/',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('#article-list').find('.article');
ctx.state.data = {
title: $('title').text(),
link: 'https://index.say-huahuo.com/',
description: '花火学园',
item:
list &&
list
.map((index, item) => {
item = $(item);
const time = `${item.find('.month').text()}${item.find('.day').text()}`;
const date = new Date();
// 1-9月 实际抓取为1 月
const math = /(\d+)\s?月(\d+)日/.exec(time);
const pubdate = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
return {
title: item.find('h1').text(),
description: `${item.find('.info p').text()}`,
pubDate: pubdate > date ? new Date(date.getFullYear() - 1, parseInt(math[1]) - 1, math[2]).toUTCString() : pubdate.toUTCString(),
link: item.find('h1 a').attr('href'),
};
})
.get(),
};
};