diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 243e070240..dc685f48f7 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -903,6 +903,10 @@ category 对应的关键词有 +### 央视网图片《镜象》 + + + ## 朝日新聞中文網(繁體中文版) ### 新聞分類 diff --git a/lib/router.js b/lib/router.js index 9738b84c2a..93c44176e7 100644 --- a/lib/router.js +++ b/lib/router.js @@ -382,8 +382,10 @@ router.get('/mihoyo/bh2/:type', require('./routes/mihoyo/bh2')); // 新闻联播 router.get('/cctv/xwlb', require('./routes/cctv/xwlb')); + // 央视新闻 router.get('/cctv/:category', require('./routes/cctv/category')); +router.get('/cctv/photo/jx', require('./routes/cctv/jx')); router.get('/cctv-special/:id?', require('./routes/cctv/special')); // 财新博客 diff --git a/lib/routes/cctv/jx.js b/lib/routes/cctv/jx.js new file mode 100644 index 0000000000..3534178cb8 --- /dev/null +++ b/lib/routes/cctv/jx.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = 'https://photo.cctv.com'; + const currentUrl = `${rootUrl}/jx/`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.textr a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: item.attr('href'), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('.tujitop').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '央视网图片《镜象》', + link: currentUrl, + item: items, + }; +};