feat: better compatibility fo AEON & NYTimes (#6054)
This commit is contained in:
parent
aed981c4ff
commit
4e31222c13
|
|
@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
|||
let bio;
|
||||
const authorInfo = '.article__body__author-details > p:nth-child(2)';
|
||||
if (capture(authorInfo).html() !== null) {
|
||||
bio = `<br><br><br><br><hr><br><b>` + author.trim() + '</b> ' + capture(authorInfo).html().trim() + `<p><hr>`;
|
||||
bio = `<br><br><hr><br><b>` + author.trim() + '</b> ' + capture(authorInfo).html().trim() + `<p></p><hr>`;
|
||||
capture('.article__inline-sidebar').remove();
|
||||
} else {
|
||||
bio = '';
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ module.exports = async (ctx) => {
|
|||
const ending = /感(谢|謝);.*?cn\.letters@nytimes\.com。/g;
|
||||
|
||||
const matching = '<div class="article-paragraph">';
|
||||
const formatted = '<p></p>' + matching;
|
||||
const formatted = '<br>' + matching;
|
||||
|
||||
single.description = result.description.replace(ending, '').split(matching).join(formatted);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ module.exports = async (ctx) => {
|
|||
const ending = /感(谢|謝);.*?cn\.letters@nytimes\.com。/g;
|
||||
|
||||
const matching = '<div class="article-paragraph">';
|
||||
const formatted = '<p></p>' + matching;
|
||||
const formatted = '<br>' + matching;
|
||||
|
||||
item.description = result.description.replace(ending, '').split(matching).join(formatted);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,19 +27,28 @@ module.exports = async function get_article(url) {
|
|||
let date = new Date(date_str);
|
||||
date.setHours(date.getHours() - 8);
|
||||
date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
|
||||
const title = $('div.block_m > div.ct_tittle > div.bg_htit > h2').text();
|
||||
const category = $('div.icon_float > a').attr('title');
|
||||
const author = $('div.talk_time > b')
|
||||
.text()
|
||||
.replace(/^来自(.*)部门$/g, '$1');
|
||||
$('div.ct_tittle').remove();
|
||||
$('div.talk_time').remove();
|
||||
const description = $('div.block_m')
|
||||
.html()
|
||||
.replace(/(href.*?)<u>(.*?)<\/u>/g, `$1$2`)
|
||||
.replace(/href="\//g, 'href="' + domain + '/')
|
||||
// Preserve the not extremely disturbing donation ad
|
||||
// to support the site.
|
||||
.replace(/(<img.*liiLIZF8Uh6yM.*?>)/g, `<br><br>$1`);
|
||||
|
||||
const item = {
|
||||
title: $('div.block_m > div.ct_tittle > div.bg_htit > h2').text(),
|
||||
title: title,
|
||||
pubDate: date.toUTCString(),
|
||||
author: $('div.talk_time > b')
|
||||
.text()
|
||||
.replace(/^来自(.*)部门$/g, '$1'),
|
||||
author: author,
|
||||
link: url,
|
||||
description: $('div.p_mainnew')
|
||||
.html()
|
||||
.replace(/(href.*?)<u>(.*?)<\/u>/g, `$1$2`)
|
||||
.replace(/href="\//g, 'href="' + domain + '/'),
|
||||
category: $('div.icon_float > a').attr('title'),
|
||||
description: description,
|
||||
category: category,
|
||||
};
|
||||
return item;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue