Files
RSSHub/lib/routes/cssn/iolaw.ts
T
Tony a5e2e295dc refactor: fix all get to toArray (#19000)
* refactor: fix all get

* fix(utils/common-config): charset case compare

* Revert "fix(utils/common-config): charset case compare"

This reverts commit 3c1880f2fad53ad2cafddcee7741390fd46fa3d2.

* fix: nga

* fix: notateslaapp

* fix: ps

* fix: xjtu

* fix: enforce error on restricted syntax for get calls

* fix: eslint

* fix: more eslint
2025-05-04 05:24:53 +08:00

58 lines
1.7 KiB
TypeScript

import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/iolaw/:section?',
categories: ['study'],
example: '/cssn/iolaw/zxzp',
parameters: { section: 'Section ID, can be found in the URL. For example, the Section ID of URL `http://iolaw.cssn.cn/zxzp/` is `zxzp`. The default value is `zxzp`' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Institute of Law',
maintainers: ['HankChow'],
handler,
};
async function handler(ctx) {
const section = ctx.req.param('section') ?? 'zxzp';
const domain = 'iolaw.cssn.cn';
const response = await got(`http://${domain}/${section}/`);
const data = response.data;
const $ = load(data);
const list = $('div.notice_right ul li')
.toArray()
.map((item) => {
item = $(item);
const url = `http://${domain}` + item.find('a').attr('href').slice(1);
const title = item.find('a div.title').text();
const publish_time = parseDate(item.find('a p').text());
return {
title,
link: url,
author: '中国法学网',
pubtime: publish_time,
};
});
return {
title: '中国法学网',
url: `http://${domain}/${section}/`,
description: '中国法学网',
item: list.map((item) => ({
title: item.title,
pubDate: item.pubtime,
link: item.link,
author: item.author,
})),
};
}