From d6478759ac001898805044406353af75c472eb4f Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 23 Jun 2023 15:51:59 +0400 Subject: [PATCH] fix(route): reuters (#12702) --- lib/v2/reuters/common.js | 13 +++++++++++++ lib/v2/reuters/investigates.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/v2/reuters/common.js b/lib/v2/reuters/common.js index 10aaf7c17..a888323b6 100644 --- a/lib/v2/reuters/common.js +++ b/lib/v2/reuters/common.js @@ -38,6 +38,19 @@ module.exports = async (ctx) => { const detailResponse = await got(item.link); const content = cheerio.load(detailResponse.data); + if (detailResponse.url.startsWith('https://www.reuters.com/investigates/')) { + const ldJson = JSON.parse(content('script[type="application/ld+json"]').text()); + content('.special-report-article-container .container, #slide-dek, #slide-end, .share-in-article-container').remove(); + + item.title = ldJson.headline; + item.pubDate = parseDate(ldJson.dateCreated); + item.author = ldJson.creator; + item.category = ldJson.keywords; + item.description = content('.special-report-article-container').html(); + + return item; + } + const data = JSON.parse( content('script#fusion-metadata') .text() diff --git a/lib/v2/reuters/investigates.js b/lib/v2/reuters/investigates.js index af9123fe0..f61016eb8 100644 --- a/lib/v2/reuters/investigates.js +++ b/lib/v2/reuters/investigates.js @@ -4,7 +4,7 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const rootUrl = 'https://www.reuters.com'; - const currentUrl = `${rootUrl}/investigates`; + const currentUrl = `${rootUrl}/investigates/`; const response = await got(currentUrl); const $ = cheerio.load(response.data);