feat: 增加005.tv的二次元资讯 (#2335)

This commit is contained in:
junfengP 2019-06-06 11:55:40 +08:00 committed by DIYgod
parent 45cfbebb52
commit 612e30747a
3 changed files with 57 additions and 0 deletions

View File

@ -4,6 +4,11 @@ pageClass: routes
# 二次元
## 005.tv
### 二次元资讯
<Route author="junfengP" example="/005tv/zx/latest" path="/005tv/zx/latest"/>
## Anime1
### 動畫

View File

@ -1386,4 +1386,7 @@ router.get('/yxdzqb/:type', require('./routes/yxdzqb'));
// 怪物猎人
router.get('/monsterhunter/update', require('./routes/monsterhunter/update'));
// 005.tv
router.get('/005tv/zx/latest', require('./routes/005tv/zx'));
module.exports = router;

49
lib/routes/005tv/zx.js Normal file
View File

@ -0,0 +1,49 @@
const got = require('@/utils/got');
const host = 'http://www.005.tv/zx';
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got(host);
const data = response.body;
const $ = cheerio.load(data);
const list = $('div.article-list li');
ctx.state.data = {
title: $('head > title').text(),
link: host,
description: '二次元资讯',
item: list
.map((index, item) => ({
title: $(item)
.find('h3 > a')
.text()
.trim(),
description: `<img referrerpolicy="no-referrer" src="${$(item)
.find('img')
.attr('src')}" /> <br>
${$(item)
.find('div.p-row')
.text()}`,
link: $(item)
.find('h3 > a')
.attr('href'),
pubDate: new Date(
$(item)
.find('span.fr.time')
.text()
.trim()
.substr(0, 4),
$(item)
.find('span.fr.time')
.text()
.trim()
.substr(5, 2),
$(item)
.find('span.fr.time')
.text()
.trim()
.substr(8, 4)
).toUTCString(),
}))
.get(),
};
};