diff --git a/lib/routes/reuters/channel.js b/lib/routes/reuters/channel.js index 5456ef953..cc5257100 100644 --- a/lib/routes/reuters/channel.js +++ b/lib/routes/reuters/channel.js @@ -4,7 +4,7 @@ const utils = require('./utils'); module.exports = async (ctx) => { const { site } = ctx.params || 'cn'; - const homePage = `https://${site === 'us' ? 'www' : site}.reuters.com/`; + const homePage = `https://${site === 'us' ? 'www' : site}.reuters.com`; let title = 'Reuters ', link = `https://${site === 'us' ? 'www' : site}.reuters.com/news/`, diff --git a/lib/routes/reuters/utils.js b/lib/routes/reuters/utils.js index a96034f62..1f834c721 100644 --- a/lib/routes/reuters/utils.js +++ b/lib/routes/reuters/utils.js @@ -9,8 +9,7 @@ const ProcessFeed = async (link) => { const title = $('meta[property="og:title"]')[0].attribs.content; const author = $('meta[property="og:article:author"]')[0].attribs.content; const cover = $('meta[property="og:image"]')[0].attribs.content; - const description = $('.StandardArticleBody_body'); - + const description = $('.ArticleBodyWrapper'); // if the article's cover photo is not the meaningless logo if (cover !== 'https://s4.reutersmedia.net/resources_v2/images/rcom-default.png') { const image = $('.PrimaryAsset_container img'); @@ -22,41 +21,48 @@ const ProcessFeed = async (link) => { // handle slideshows and videos const pageDataPattern = new RegExp(`(?<=)`); - const pageData = JSON.parse(response.data.match(pageDataPattern)[0]); + const pageDataFind = response.data.match(pageDataPattern); + if (pageDataFind) { + const pageData = JSON.parse(response.data.match(pageDataFind)[0]); - // keys of this json has random tails, so we have to iterate through them - Object.keys(pageData).forEach((key) => { - // videos and slideshow appear only in `article_list` - if (!key.startsWith('article_list')) { - return; - } + // keys of this json has random tails, so we have to iterate through them + Object.keys(pageData).forEach((key) => { + // videos and slideshow appear only in `article_list` + if (!key.startsWith('article_list')) { + return; + } - // add full-res pictures at the end - const slideshowData = pageData[key].first_article.images; - slideshowData && - slideshowData.forEach((imgData) => { - description.insertAfter(`
+ // add full-res pictures at the end + const slideshowData = pageData[key].first_article.images; + slideshowData && + slideshowData.forEach((imgData) => { + description.insertAfter(`
${imgData.title}
${imgData.caption}
`); - }); + }); - // add full-res pictures at the beginning - const videoData = pageData[key].first_article.videos; - videoData && - videoData.forEach((videoData) => { - description.insertBefore(`