feat: add 妖火网 (#5628)

Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
Ethan Shen
2020-09-08 12:39:14 +01:00
committed by GitHub
co-authored by Henry Wang
parent 9307a03f7b
commit 1667a7ff6d
3 changed files with 40 additions and 0 deletions
+4
View File
@@ -1343,6 +1343,10 @@ area 分区选项
<Route author="hillerliao" example="/xuangubao/subject/41" path="/xuangubao/subject/:subject_id" :paramsDesc="['主题 id,网址 https://xuangubao.cn/subject/41 中最后的数字']"/>
## 妖火网
<Route author="nczitzk" example="/yaohuo/new" path="/yaohuo/:type?" :paramsDesc="['排序类型,可选 `new` 指最新,`hot` 指最热',默认为 `new`]"/>
## 异次元软件世界
### 首页
+3
View File
@@ -3191,6 +3191,9 @@ router.get('/chuhaibiji', require('./routes/chuhaibiji/index'));
// 建宁闲谈
router.get('/blogs/jianning', require('./routes/blogs/jianning'));
// 妖火网
router.get('/yaohuo/:type?', require('./routes/yaohuo/index'));
// 互动吧
router.get('/hudongba/:city/:id', require('./routes/hudongba/index'));
+33
View File
@@ -0,0 +1,33 @@
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,
};
};