diff --git a/docs/bbs.md b/docs/bbs.md index 914771366..fa0deaa51 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -385,3 +385,7 @@ pageClass: routes ### 回帖 + +### 滚动新闻 + + diff --git a/lib/router.js b/lib/router.js index a5f0f09ae..a6d139fc1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1695,6 +1695,7 @@ router.get('/dekudeals/:type', require('./routes/dekudeals')); // 直播吧 router.get('/zhibo8/forum/:id', require('./routes/zhibo8/forum')); router.get('/zhibo8/post/:id', require('./routes/zhibo8/post')); +router.get('/zhibo8/more/:caty', require('./routes/zhibo8/more')); // 东方网-上海 router.get('/eastday/sh', require('./routes/eastday/sh')); diff --git a/lib/routes/zhibo8/more.js b/lib/routes/zhibo8/more.js new file mode 100644 index 000000000..57f0fea86 --- /dev/null +++ b/lib/routes/zhibo8/more.js @@ -0,0 +1,46 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const currentUrl = `https://news.zhibo8.cc/${ctx.params.caty}/more.htm`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + const $ = cheerio.load(response.data); + const list = $('ul.articleList li') + .slice(0, 30) + .map((_, item) => { + item = $(item); + const a = item.find('a'); + + return { + title: a.text(), + link: `http:${a.attr('href')}`, + pubDate: new Date(item.find('span.postTime').text() + ' GMT+8').toUTCString(), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const res = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(res.data); + + item.description = content('div.content').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('span.title_g').text()} - 直播吧`, + link: currentUrl, + item: items, + }; +};