mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix 好奇心日报图片无法显示 (#1739)
This commit is contained in:
+2
-2
@@ -656,9 +656,9 @@ RSSHub 提供下列 API 接口:
|
||||
|
||||
### 好奇心日报
|
||||
|
||||
<route name="分类" author="WenhuWee" example="/qdaily/category/5" path="/qdaily/category/:id?" :paramsDesc="['分类id,可在分类URL找到']"/>
|
||||
<route name="分类" author="WenhuWee" example="/qdaily/category/5" path="/qdaily/category/:id" :paramsDesc="['分类id,可在分类URL找到']"/>
|
||||
|
||||
<route name="栏目" author="WenhuWee" example="/qdaily/column/59" path="/qdaily/column/:id?" :paramsDesc="['栏目id,可在栏目URL找到']"/>
|
||||
<route name="栏目" author="WenhuWee" example="/qdaily/column/59" path="/qdaily/column/:id" :paramsDesc="['栏目id,可在栏目URL找到']"/>
|
||||
|
||||
## 编程
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user