修复多闻图集新闻 (#953)

This commit is contained in:
Henry Wang
2018-10-24 00:10:58 +08:00
committed by DIYgod
parent c2c812955e
commit c5ae090080
2 changed files with 33 additions and 11 deletions
+1 -2
View File
@@ -38,11 +38,10 @@ module.exports = async (ctx) => {
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
item.url = 'http://news.dwnews.com/global/news/2018-10-08/60089463.html';
const response = await axios.get(item.url.replace('.html', '_all.html'));
const $ = cheerio.load(response.data);
const result = utils.ProcessRank($, item);
const result = utils.ProcessRank($, ctx.params.type);
const single = {
title: item.title,
+32 -9
View File
@@ -1,3 +1,5 @@
const cheerio = require('cheerio');
const ProcessFeed = ($, item) => {
let content;
if (item.filetype === 'TJ') {
@@ -19,25 +21,46 @@ const ProcessFeed = ($, item) => {
return content.html();
};
const ProcessRank = ($) => {
const ProcessRank = ($, type) => {
let content, author;
const pubDate = new Date($('div.time').text());
pubDate.setHours(pubDate.getHours() - 8);
content = $('div.dia-lead-one');
if (type === 'news') {
if (content.length === 0) {
content = $('div.container');
if (content.length === 0) {
content = $('div.container');
author = $('div.author').text();
} else {
author = $('div.nw').text();
}
author = $('div.author').text();
ProcessQuote($, content);
ProcessImage($, content);
Clean($, content);
} else {
author = $('div.nw').text();
}
let images = $('div#slider_component_4_0 > img');
if ($('div#slider_component_4_0 > img').length > 0) {
$('div.captions > p').each((i, e) => {
$(images[i]).insertBefore(e);
});
content = $('div.captions');
} else {
images = $('div#component_4_0 .sd-page > img');
ProcessQuote($, content);
ProcessImage($, content);
Clean($, content);
content = cheerio.load('<div></div>');
content = content('div');
$('.sqbtnbox > .tzbox')
.slice(1)
.each((i, e) => {
$(images[i]).appendTo(content);
$(e).appendTo(content);
});
}
}
return {
description: content.html(),