diff --git a/docs/README.md b/docs/README.md index ab413ff29..a753e0de7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2801,7 +2801,17 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 ### 后续 - + + +| 全部 | 原创 | 精选 | +| ---- | -------- | -------- | +| all | original | featured | + + + + + + ### 老司机 diff --git a/lib/router.js b/lib/router.js index 521a8d941..fdecd0d36 100644 --- a/lib/router.js +++ b/lib/router.js @@ -772,7 +772,9 @@ router.get('/miniapp/article/:category', require('./routes/miniapp/article')); router.get('/miniapp/store/newest', require('./routes/miniapp/store/newest')); // 后续 -router.get('/houxu/:type/:id', require('./routes/houxu/houxu')); +router.get('/houxu/live/:id/:timeline?', require('./routes/houxu/live')); +router.get('/houxu/events', require('./routes/houxu/events')); +router.get('/houxu/lives/:type', require('./routes/houxu/lives')); // 老司机 router.get('/laosiji/hot', require('./routes/laosiji/hot')); diff --git a/lib/routes/houxu/events.js b/lib/routes/houxu/events.js new file mode 100644 index 000000000..163d332ac --- /dev/null +++ b/lib/routes/houxu/events.js @@ -0,0 +1,50 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const baseUrl = `https://houxu.app/events`; + const res = await axios.get(baseUrl); + const data = res.data; + const $ = cheerio.load(data); + + const list = $('div.list > div'); + const descriptionSelector = '.summary'; + const out = list + .map((_, el) => { + const each = $(el); + return { + title: + each + .find('a') + .first() + .text() + .trim() + + ' | ' + + each + .find('h3') + .text() + .trim(), + description: each + .find(descriptionSelector) + .text() + .trim(), + link: + 'https://houxu.app' + + each + .find('a') + .first() + .attr('href'), + }; + }) + .get(); + ctx.state.data = { + title: $('title') + .text() + .trim(), + description: $('title') + .text() + .trim(), + link: baseUrl, + item: out, + }; +}; diff --git a/lib/routes/houxu/houxu.js b/lib/routes/houxu/houxu.js deleted file mode 100644 index 4996df5ff..000000000 --- a/lib/routes/houxu/houxu.js +++ /dev/null @@ -1,35 +0,0 @@ -const axios = require('../../utils/axios'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const { type, id } = ctx.params; - const baseUrl = `https://houxu.app/${type}/${id}`; - const res = await axios.get(baseUrl); - const data = res.data; - const $ = cheerio.load(data); - - const list = $('section.threads > div').get(); - const descriptionSelector = type === 'live' ? '.summary' : '.readable'; - const out = list.map((item) => { - const each = $(item); - return { - title: each - .find('a') - .text() - .trim(), - description: each - .find(descriptionSelector) - .text() - .trim(), - link: each.find('a').attr('href'), - }; - }); - ctx.state.data = { - title: $('.large-title').text(), - description: $('title') - .text() - .trim(), - link: baseUrl, - item: out, - }; -}; diff --git a/lib/routes/houxu/live.js b/lib/routes/houxu/live.js new file mode 100644 index 000000000..062b77274 --- /dev/null +++ b/lib/routes/houxu/live.js @@ -0,0 +1,47 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { id, timeline } = ctx.params; + const filter = timeline ? timeline : 'all'; + const baseUrl = `https://houxu.app/lives/${id}?filter=${filter}`; + const res = await axios.get(baseUrl); + const data = res.data; + const $ = cheerio.load(data); + + const list = $('section.threads > div'); + const out = list + .map((_, el) => { + const each = $(el); + return { + title: + each + .find('a') + .first() + .text() + .trim() + + ' | ' + + each + .find('h3') + .text() + .trim(), + description: each + .find('.summary') + .text() + .trim(), + link: each + .find('a') + .first() + .attr('href'), + }; + }) + .get(); + ctx.state.data = { + title: $('.large-title').text(), + description: $('title') + .text() + .trim(), + link: baseUrl, + item: out, + }; +}; diff --git a/lib/routes/houxu/lives.js b/lib/routes/houxu/lives.js new file mode 100644 index 000000000..4be2fa708 --- /dev/null +++ b/lib/routes/houxu/lives.js @@ -0,0 +1,54 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { type } = ctx.params; + const baseUrl = `https://houxu.app/lives/${type}`; + const res = await axios.get(baseUrl); + const data = res.data; + const $ = cheerio.load(data); + + const list = $('div.list > div'); + const out = list + .map((_, el) => { + const each = $(el); + return { + title: + each + .find('cite') + .text() + .trim() + + ' | ' + + each + .find('a') + .first() + .text() + .trim(), + description: each + .find('p > a') + .contents() + .filter(function() { + return this.nodeType === 3; + }) + .text() + .trim(), + link: + 'https://houxu.app' + + each + .find('a') + .first() + .attr('href'), + }; + }) + .get(); + ctx.state.data = { + title: $('title') + .text() + .trim(), + description: $('li.active') + .text() + .trim(), + link: baseUrl, + item: out, + }; +};