mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 12:15:32 +08:00
fix(route/zaobao): Adapt to new SG layout (#17902)
* fix(route/zaobao): Replace `got` while fetching article list * . * Update util.ts * Update util.ts
This commit is contained in:
@@ -86,16 +86,22 @@ const parseList = async (
|
||||
const article = await got_ins.get(link);
|
||||
const $1 = load(article.data);
|
||||
|
||||
const time = (() =>
|
||||
$1("head script[type='application/json']").text() === ''
|
||||
? new Date(JSON.parse($1("head script[type='application/ld+json']").eq(1).text())?.datePublished) // HK
|
||||
: new Date(Number(JSON.parse($1("head script[type='application/json']").text())?.articleDetails?.created) * 1000))(); // SG
|
||||
let title, time;
|
||||
if ($1('#seo-article-page').text() === '') {
|
||||
// HK
|
||||
title = $1('h1.article-title').text();
|
||||
time = new Date(JSON.parse($1("head script[type='application/ld+json']").eq(1).text())?.datePublished);
|
||||
} else {
|
||||
// SG
|
||||
title = JSON.parse($1('#seo-article-page').text())['@graph'][0]?.headline;
|
||||
time = new Date(JSON.parse($1('#seo-article-page').text())['@graph'][0]?.datePublished);
|
||||
}
|
||||
|
||||
$1('.overlay-microtransaction').remove();
|
||||
$1('#video-freemium-player').remove();
|
||||
$1('script').remove();
|
||||
|
||||
let articleBodyNode = $1('.article-content-rawhtml');
|
||||
let articleBodyNode = $1('.articleBody');
|
||||
if (articleBodyNode.length === 0) {
|
||||
// for HK version
|
||||
orderContent($1('.article-body'));
|
||||
@@ -107,8 +113,8 @@ const parseList = async (
|
||||
const imageDataArray = processImageData($1);
|
||||
|
||||
return {
|
||||
// <- for SG version -> for HK version
|
||||
title: $1('h1', '.content').text().trim() || $1('h1.article-title').text(),
|
||||
// <- for HK version -> for SG version
|
||||
title,
|
||||
description: art(path.join(__dirname, 'templates/zaobao.art'), {
|
||||
articleBody,
|
||||
imageDataArray,
|
||||
|
||||
Reference in New Issue
Block a user