diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 44604df2d..e643c2b6e 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -282,6 +282,14 @@ category 对应的关键词有 +## 路透社 + +### 实时资讯 + + + + + ## 每经网 ### 重磅原创 diff --git a/lib/router.js b/lib/router.js index 33ad4ceb4..d42909b5d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2902,6 +2902,9 @@ router.get('/erbingapp/news', require('./routes/erbingapp/news')); // 电商报 router.get('/dsb/area/:area', require('./routes/dsb/area')); +// Reuters +router.get('/reuters/theWire', require('./routes/reuters/theWire')); + // 格隆汇 router.get('/gelonghui/user/:id', require('./routes/gelonghui/user')); router.get('/gelonghui/subject/:id', require('./routes/gelonghui/subject')); diff --git a/lib/routes/reuters/theWire.js b/lib/routes/reuters/theWire.js new file mode 100644 index 000000000..870e682a3 --- /dev/null +++ b/lib/routes/reuters/theWire.js @@ -0,0 +1,45 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const date = require('@/utils/date'); + +module.exports = async (ctx) => { + const url = `https://cn.reuters.com/assets/jsonWireNews`; + const response = await got({ + method: 'get', + url: url, + }); + + const data = response.data; + const list_item = data.headlines.map((item) => { + const info = { + title: item.headline, + link: 'https://cn.reuters.com' + item.url, + pubDate: date(item.formattedDate), + }; + return info; + }); + + function getDescription(items) { + return Promise.all( + items.map(async function (currentValue) { + currentValue.description = await ctx.cache.tryGet(currentValue.link, async () => { + const r = await got({ + url: currentValue.link, + method: 'get', + }); + const $ = cheerio.load(r.data); + return $('.StandardArticle_content').html(); + }); + return currentValue; + }) + ); + } + + await getDescription(list_item).then(function () { + ctx.state.data = { + title: '路透社 - 实时资讯', + link: `https://cn.reuters.com/theWire`, + item: list_item, + }; + }); +};