fix(route): 妖火 (#8503)

This commit is contained in:
Ethan Shen
2021-11-27 08:57:04 +00:00
committed by GitHub
parent d3a9b3aeb9
commit a33ae5a274
6 changed files with 50 additions and 34 deletions
+1 -1
View File
@@ -3360,7 +3360,7 @@ router.get('/chuhaibiji', lazyloadRouteHandler('./routes/chuhaibiji/index'));
router.get('/blogs/jianning', lazyloadRouteHandler('./routes/blogs/jianning'));
// 妖火网
router.get('/yaohuo/:type?', lazyloadRouteHandler('./routes/yaohuo/index'));
// router.get('/yaohuo/:type?', lazyloadRouteHandler('./routes/yaohuo/index'));
// 互动吧
router.get('/hudongba/:city/:id', lazyloadRouteHandler('./routes/hudongba/index'));
-33
View File
@@ -1,33 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
ctx.params.type = ctx.params.type || 'new';
const rootUrl = `https://yaohuo.me`;
const currentUrl = `${rootUrl}/bbs/book_list.aspx?action=${ctx.params.type}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('div.line1, div.line2')
.slice(0, 15)
.map((_, item) => {
item = $(item);
const a = item.find('a').eq(0);
return {
title: a.text(),
link: `${rootUrl}${a.attr('href')}`,
author: item.text().split('/')[0].split(a.text())[1],
};
})
.get();
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: list,
};
};
+30
View File
@@ -0,0 +1,30 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'https://yaohuo.me';
const response = await got({
method: 'get',
url: rootUrl,
});
const $ = cheerio.load(response.data);
const items = $('.list a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
};
});
ctx.state.data = {
title: $('title').text(),
link: rootUrl,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'yaohuo.me': {
_name: '妖火',
'.': [
{
title: '首页',
docs: 'https://docs.rsshub.app/new-media.html#yao-huo-shou-ye',
source: ['/'],
target: '/yaohuo',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/', require('./index'));
};