diff --git a/docs/new-media.md b/docs/new-media.md index 6c83fe90ef..68ab1fac7a 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1343,6 +1343,10 @@ area 分区选项 +## 妖火网 + + + ## 异次元软件世界 ### 首页 diff --git a/lib/router.js b/lib/router.js index 9c6da40071..267a73dccd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/yaohuo/index.js b/lib/routes/yaohuo/index.js new file mode 100644 index 0000000000..6b3ad444a6 --- /dev/null +++ b/lib/routes/yaohuo/index.js @@ -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, + }; +};