fix: zhengce-zuixin (#2382)

This commit is contained in:
凉凉
2019-06-12 17:37:49 +08:00
committed by DIYgod
parent 9565774cfe
commit 77ac67e2b0
+5 -3
View File
@@ -14,14 +14,15 @@ module.exports = async (ctx) => {
const $el = $list(el);
const $a = $el.find('h4 a');
const href = $a.attr('href');
const key = `gov_zhengce: ${href}`;
const link = href.startsWith('/zhengce') ? `http://www.gov.cn${href}` : href;
const key = `gov_zhengce_zuixin: ${link}`;
let description;
const value = await ctx.cache.get(key);
if (value) {
description = value;
} else {
const contentData = await got.get(href.startsWith('/zhengce') ? `http://www.gov.cn${href}` : href);
const contentData = await got.get(link);
const $content = cheerio.load(contentData.data);
description = $content('#UCAP-CONTENT').html();
ctx.cache.set(key, description);
@@ -30,7 +31,8 @@ module.exports = async (ctx) => {
return {
title: $a.text(),
description,
link: $a.attr('href'),
guid: href,
link,
pubDate: new Date($el.find('.date').text()).toUTCString(),
};
})