fix(route): zaobao (#15685)

This commit is contained in:
Tony 2024-05-24 13:14:23 +08:00 committed by GitHub
parent 249cedc0d4
commit 41e8bcded8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 38 deletions

View File

@ -6,27 +6,18 @@ export const route: Route = {
path: '/interactive-graphics',
categories: ['traditional-media'],
example: '/zaobao/interactive-graphics',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '互动新闻',
maintainers: ['shunf4'],
handler,
};
async function handler(ctx) {
const sectionLink = `/interactive-graphics`;
const sectionLink = '/interactive-graphics';
const { resultList } = await parseList(ctx, sectionLink);
return {
title: `《联合早报》互动新闻`,
title: '《联合早报》互动新闻',
link: baseUrl + sectionLink,
description: '新加坡、中国、亚洲和国际的即时、评论、商业、体育、生活、科技与多媒体新闻,尽在联合早报。',
item: resultList,

View File

@ -3,18 +3,10 @@ import { parseList } from './util';
const baseUrl = 'https://www.zaobao.com';
export const route: Route = {
path: '/:type?/:section?',
path: '/other/:type?/:section?',
categories: ['traditional-media'],
example: '/zaobao/lifestyle/health',
example: '/zaobao/other/lifestyle/health',
parameters: { type: 'https://www.zaobao.com/**lifestyle**/health 中的 **lifestyle**', section: 'https://www.zaobao.com/lifestyle/**health** 中的 **health**' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '其他栏目',
maintainers: ['shunf4'],
handler,

View File

@ -7,14 +7,6 @@ export const route: Route = {
categories: ['traditional-media'],
example: '/zaobao/realtime/china',
parameters: { section: '分类,缺省为 china' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '即时新闻',
maintainers: ['shunf4'],
handler,

View File

@ -22,16 +22,20 @@ const got_ins = got.extend({
*
* @param {*} ctx RSSHub ctx
* @param {string} sectionUrl /realtime/china
* @returns {Promise<{
* title: string;
* resultList: {
* title: string;
* description: string;
* pubDate: string;
* link: string;
* }[];}>}
* @returns
*/
const parseList = async (ctx, sectionUrl) => {
const parseList = async (
ctx,
sectionUrl: string
): Promise<{
title: string;
resultList: {
title: string;
description: string;
pubDate: string;
link: string;
}[];
}> => {
const response = await got_ins.get(baseUrl + sectionUrl);
const $ = load(response.data);
let data = $('.article-list').find('.article-type');