Skip to content

Commit

Permalink
fix(route): zaobao (#15685)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored May 24, 2024
1 parent 249cedc commit 41e8bcd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 38 deletions.
13 changes: 2 additions & 11 deletions lib/routes/zaobao/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 2 additions & 10 deletions lib/routes/zaobao/index.ts → lib/routes/zaobao/other.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions lib/routes/zaobao/realtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 13 additions & 9 deletions lib/routes/zaobao/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 41e8bcd

Please sign in to comment.