diff --git a/docs/README.md b/docs/README.md index 47224eb6f..f239f10be 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1851,3 +1851,7 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运 ### 观止(每日一文) + +### 后续 + + diff --git a/router.js b/router.js index 33c826146..f9b055b51 100644 --- a/router.js +++ b/router.js @@ -625,6 +625,9 @@ router.get('/pediy/topic/:category?/:type?', require('./routes/pediy/topic')); // 观止(每日一文) router.get('/guanzhi', require('./routes/guanzhi/guanzhi')); +// 后续 +router.get('/houxu/:type/:id', require('./routes/houxu/houxu')); + // 老司机 router.get('/laosiji/hot', require('./routes/laosiji/hot')); router.get('/laosiji/feed', require('./routes/laosiji/feed')); diff --git a/routes/houxu/houxu.js b/routes/houxu/houxu.js new file mode 100644 index 000000000..4996df5ff --- /dev/null +++ b/routes/houxu/houxu.js @@ -0,0 +1,35 @@ +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, + }; +};