feat(route): add xboxfan.com (#12717)
* add xboxfan.com * Create radar.js * Update news.js * Update lib/v2/xboxfan/radar.js * remove trailing whitespace * Apply suggestions from code review ---------
This commit is contained in:
parent
07825f1340
commit
fa7cabe797
|
|
@ -623,6 +623,12 @@ News 的数据来自 <https://warthunder.com/en/news/>
|
|||
|
||||
<Route author="DIYgod" example="/mhw/news" path="/mhw/news" radar="1" rssbud="1"/>
|
||||
|
||||
## 盒心光环
|
||||
|
||||
### 资讯
|
||||
|
||||
<Route author="XXY233" example="/xboxfan/news" path="/xboxfan/news" radar="1"/>
|
||||
|
||||
## 剑网 3
|
||||
|
||||
### 新闻资讯
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/news': ['XXY233'],
|
||||
};
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
const md5 = require('@/utils/md5');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://xboxfan.com/';
|
||||
const { data: response } = await got(baseUrl);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
$('div.homeCom').remove();
|
||||
$('div.homeMore').remove();
|
||||
|
||||
$('el-image').each((index, el_image) => {
|
||||
const img = $('<img>');
|
||||
img.attr('src', $(el_image).attr('src'));
|
||||
$(el_image).replaceWith(img);
|
||||
});
|
||||
|
||||
const items = $(`div.homeItem[v-if="showFeedLevel == 'read'"]`)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
const data = {
|
||||
title: '资讯',
|
||||
author: $(item).find('div.homeName').text(),
|
||||
pubDate: parseRelativeDate($(item).find('div.homeTime').first().text().split(' ')[0]),
|
||||
};
|
||||
|
||||
$(item).find('div.homeName').remove();
|
||||
$(item).find('div.homeTime').remove();
|
||||
|
||||
const md5Value = md5($(item).text());
|
||||
data.guid = md5Value;
|
||||
|
||||
data.description = $(item).html();
|
||||
|
||||
return data;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '盒心光环·资讯',
|
||||
link: 'https://xboxfan.com/',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'xboxfan.com': {
|
||||
_name: '盒心光环',
|
||||
'.': [
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/game.html#he-xin-guang-huan',
|
||||
source: '/',
|
||||
target: '/xboxfan/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/news', require('./news'));
|
||||
};
|
||||
Loading…
Reference in New Issue