parent
ecb0fdc57e
commit
3707145428
|
|
@ -1851,3 +1851,7 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
|
|||
### 观止(每日一文)
|
||||
|
||||
<route name="观止" author="Andiedie" example="/guanzhi" path="/guanzhi"/>
|
||||
|
||||
### 后续
|
||||
|
||||
<route name="后续" author="fengkx" example="/houxu/events/38" path="/houxu/:type/:id" :paramsDesc="['类型', 'ID']"/>
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue