From c4430e29f5c7aba58b46b74249713ee16203c0f7 Mon Sep 17 00:00:00 2001 From: Wenhu Date: Wed, 13 Mar 2019 11:57:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A5=BD=E5=A5=87=E5=BF=83=E6=97=A5?= =?UTF-8?q?=E6=8A=A5=E5=9B=BE=E7=89=87=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20(#1739)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 4 ++-- lib/routes/qdaily/category.js | 12 ++++++++++-- lib/routes/qdaily/column.js | 9 +++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 9f1afafa1b..2b62b08e83 100755 --- a/docs/README.md +++ b/docs/README.md @@ -656,9 +656,9 @@ RSSHub 提供下列 API 接口: ### 好奇心日报 - + - + ## 编程 diff --git a/lib/routes/qdaily/category.js b/lib/routes/qdaily/category.js index 82f5eb9384..b706344807 100644 --- a/lib/routes/qdaily/category.js +++ b/lib/routes/qdaily/category.js @@ -2,7 +2,7 @@ const cheerio = require('cheerio'); const axios = require('../../utils/axios'); module.exports = async (ctx) => { - const url = `http://www.qdaily.com/categories/${ctx.params.id}.html`; + const url = `https://www.qdaily.com/categories/${ctx.params.id}.html`; const res = await axios.get(url); const $ = cheerio.load(res.data); @@ -20,7 +20,7 @@ module.exports = async (ctx) => { title = $('.smart-dotdotdot').text(); } const itemUrl = $('a').attr('href'); - const allUrl = `http://www.qdaily.com${itemUrl}`; + const allUrl = `https://www.qdaily.com${itemUrl}`; const cache = await ctx.cache.get(allUrl); if (cache) { return Promise.resolve(JSON.parse(cache)); @@ -40,6 +40,14 @@ module.exports = async (ctx) => { for (let i = 0; i < responses.length; i++) { const res = responses[i]; const $ = cheerio.load(res.data); + $('img').each((index, item) => { + item = $(item); + item.attr('src', item.attr('data-src')); + item.attr('referrerpolicy', 'no-referrer'); + }); + $('.article-detail-bd .author-share').remove(); + $('.article-detail-ft').remove(); + out[indexList[i]].description = $('.main .com-article-detail').html(); ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); } diff --git a/lib/routes/qdaily/column.js b/lib/routes/qdaily/column.js index be2beb4229..da5ec82cbc 100644 --- a/lib/routes/qdaily/column.js +++ b/lib/routes/qdaily/column.js @@ -40,6 +40,15 @@ module.exports = async (ctx) => { for (let i = 0; i < responses.length; i++) { const res = responses[i]; const $ = cheerio.load(res.data); + + $('img').each((index, item) => { + item = $(item); + item.attr('src', item.attr('data-src')); + item.attr('referrerpolicy', 'no-referrer'); + }); + $('.article-detail-bd .author-share').remove(); + $('.article-detail-ft').remove(); + out[indexList[i]].description = $('.main .com-article-detail').html(); ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60); }