fix: exclude datanews to prevent `pubDate` error (`/caixin/latest`) (#8068)

This commit is contained in:
Toby Tso 2021-11-27 15:30:58 +08:00 committed by GitHub
parent 26b39e23ef
commit e0d44f24cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -1,10 +1,13 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const li_r = await got({
method: 'get',
url: 'http://finance.caixin.com/2020-11-03/101622309.html',
url: 'https://www.caixin.com/2021-08-22/101758426.html',
});
const $ = cheerio.load(li_r.data);
@ -13,7 +16,7 @@ module.exports = async (ctx) => {
const tasks = [];
list.map((_index, li) => $(li).find('a').first().attr('href'))
.filter((_index, link) => link.indexOf('fm.caixin.com') === -1 && link.indexOf('video.caixin.com') === -1) // content filter
.filter((_index, link) => !link.includes('fm.caixin.com') && !link.includes('video.caixin.com') && !link.includes('datanews.caixin.com')) // content filter
.each((_index, link) => {
const entry = ctx.cache.tryGet(link, async () => {
const entry_r = await got.get(link);
@ -46,15 +49,16 @@ module.exports = async (ctx) => {
desc = `<blockquote><p>${subhead}</p></blockquote><img src="${pic_url}" alt="${pic_alt}">${content}`;
}
// time
/*
const [, year, month, day, hour, minute] = $('div#artInfo.artInfo')
.text()
.match(/(\d+)年(\d+)月(\d+)日 *(\d+):(\d+)/);
const time = new Date(`${year}-${month}-${day}T${hour}:${minute}:00+0800`).toUTCString();
*/
return {
title: h1,
description: desc,
pubDate: time,
pubDate: timezone(parseDate($('div#artInfo.artInfo').text(), 'YYYY年MM月DD日 HH:mm'), +8),
link,
};
});