fix(route/zaobao): zaobao sg (#21080)
This commit is contained in:
+10
-15
@@ -59,28 +59,23 @@ export const parseList = async (
|
||||
let $1 = load(response._data);
|
||||
|
||||
let title, pubDate, category, images;
|
||||
const jsonText = $1('head script[type="application/ld+json"]')
|
||||
const jsonText = $1('script[type="application/ld+json"]')
|
||||
.text()
|
||||
.replaceAll(/[\u0000-\u001F\u007F-\u009F]/g, '');
|
||||
const ldJson = JSON.parse(jsonText);
|
||||
|
||||
const isSingapore = response.url.startsWith('https://www.zaobao.com.sg/');
|
||||
if (isSingapore) {
|
||||
const hydrationData = JSON.parse(
|
||||
JSON.parse(
|
||||
`"${
|
||||
$1('script:contains("__staticRouterHydrationData")')
|
||||
.text()
|
||||
.match(/__staticRouterHydrationData = JSON.parse\("(.*)"\);/)?.[1]
|
||||
}"`
|
||||
)
|
||||
);
|
||||
const article = hydrationData.loaderData['0-0'].context.payload.article;
|
||||
const ldJson = JSON.parse($1('#seo-article-page').text());
|
||||
const article = ldJson['@graph'].find((item) => item['@type'] === 'NewsArticle');
|
||||
title = article.headline;
|
||||
pubDate = parseDate(article.create_time, 'X');
|
||||
category = article.tags.map((t) => t.name);
|
||||
$1 = load(article.body_cn, null, false);
|
||||
images = article.images;
|
||||
pubDate = parseDate(article.datePublished);
|
||||
category = $1('meta[name="keywords"]')
|
||||
.attr('content')
|
||||
?.split(',')
|
||||
.map((s) => s.trim());
|
||||
$1 = load($1('.articleBody').html(), null, false);
|
||||
images = [{ url: article.image.url }];
|
||||
} else {
|
||||
title = ldJson.headline;
|
||||
pubDate = parseDate(ldJson.datePublished);
|
||||
|
||||
Reference in New Issue
Block a user