mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
fix: /coronavirus/qq/fact
This commit is contained in:
@@ -2,61 +2,41 @@ const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://vp.fact.qq.com/loadmore?artnum=0&page=0&callback=';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://vp.fact.qq.com/loadmore?artnum=0&page=0',
|
||||
headers: {
|
||||
Referer: 'https://vp.fact.qq.com/home',
|
||||
},
|
||||
});
|
||||
|
||||
const list_res = await got.get(url);
|
||||
const list = list_res.data.content;
|
||||
const data = response.data.content;
|
||||
|
||||
const parseContent = (htmlString) => {
|
||||
const $ = cheerio.load(htmlString);
|
||||
let content = cheerio.load('<div></div>');
|
||||
content = content('div');
|
||||
$('.subtitle.text').appendTo(content);
|
||||
$('.check_content.text').appendTo(content);
|
||||
$('.information').appendTo(content);
|
||||
content.find('.point_num').remove();
|
||||
content.find('.check_content_bottom').remove();
|
||||
content.find('li').removeAttr('style');
|
||||
return {
|
||||
description: content.html(),
|
||||
};
|
||||
};
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const title = `${item.result}/${item.explain} - ${item.title}`;
|
||||
const items = await Promise.all(
|
||||
(data || []).map(async (item) => {
|
||||
const link = `https://vp.fact.qq.com/article?id=${item.id}`;
|
||||
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const rssitem = {
|
||||
title: title,
|
||||
link: link,
|
||||
const simple = {
|
||||
title: `【${item.explain}】${item.title}`,
|
||||
description: `<img src="${item.cover}">${item.abstract}`,
|
||||
pubDate: new Date(item.date).toUTCString(),
|
||||
author: item.author,
|
||||
pubDate: new Date(item.date),
|
||||
link: link,
|
||||
};
|
||||
|
||||
try {
|
||||
const details = await ctx.cache.tryGet(link, async () => {
|
||||
const response = await got.get(link);
|
||||
const result = parseContent(response.data);
|
||||
if (!result.description) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
rssitem.description = result.description;
|
||||
} catch (err) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
ctx.cache.set(link, JSON.stringify(rssitem));
|
||||
return Promise.resolve(rssitem);
|
||||
const $ = cheerio.load(response.data);
|
||||
return {
|
||||
description: `<img src="${item.cover}">${$('.check_content_points').html()}`,
|
||||
};
|
||||
});
|
||||
return Promise.resolve(Object.assign({}, simple, details));
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '腾讯新闻较真查证平台',
|
||||
link: 'https://vp.fact.qq.com/',
|
||||
item: out.filter((item) => item !== ''),
|
||||
title: '较真查证平台-腾讯新闻',
|
||||
link: 'https://vp.fact.qq.com/home',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user