add indienova (#1509)

This commit is contained in:
幻葬咲夜 2019-01-31 17:21:59 +08:00 committed by DIYgod
parent ab2028ffa2
commit d0d3b69d27
3 changed files with 43 additions and 0 deletions

View File

@ -2337,6 +2337,10 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
<route name="用户动态" author="LogicJake" example="/xiaoheihe/user/7775687" path="xiaoheihe/user/:id" :paramsDesc="['用户 id']"/>
### Indienova
<route name="indienova 文章" author="GensouSakuya" example="/indienova/article" path="indienova/article"/>
## 小说·文学·阅读
### 观止(每日一文)

View File

@ -1037,4 +1037,7 @@ router.get('/d2/daily', require('./routes/d2/daily'));
// ebb
router.get('/ebb', require('./routes/ebb'));
// Indienova
router.get('/indienova/article', require('./routes/indienova/article'));
module.exports = router;

View File

@ -0,0 +1,36 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'https://www.indienova.com/indie-game-news/',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.article-panel');
ctx.state.data = {
title: 'INDIENOVA',
link: 'https://www.indienova.com/indie-game-news/',
description: '独立游戏资讯 | indienova 独立游戏',
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('h4').text(),
description: item.find('p').text() + '<img src="' + item.find('img').attr('src') + '">',
link:
'https://www.indienova.com' +
item
.find('.article-image')
.find('a')
.attr('href'),
};
})
.get(),
};
};