feat(route): 中国法学网 (#12363)

* feat: css/iolaw

* feat(route): add cssn
This commit is contained in:
Hank Chow 2023-04-21 22:50:35 +08:00 committed by GitHub
parent f7add90bee
commit c64b62a85e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 0 deletions

View File

@ -18,6 +18,12 @@ pageClass: routes
</RouteEn>
## Chinese Social Science Net
### Institute of Law
<RouteEn author="HankChow" example="/cssn/iolaw/zxzp" path="/cssn/iolaw/:section?" :paramsDesc="['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`']"/>
## gradCafe
### gradCafe result

View File

@ -721,6 +721,12 @@ path="/ctfhub/upcoming/:limit?"
<Route author="nczitzk" example="/cpta/notice" path="/cpta/notice" />
## 中国社会科学网
### 中国法学网
<Route author="HankChow" example="/cssn/iolaw/zxzp" path="/cssn/iolaw/:section?" :paramsDesc="['板块 ID可在 URL 找到。例如页面 URL 为 `http://iolaw.cssn.cn/zxzp/`,则板块 ID 为 `zxzp`。若不填该参数,默认为 `zxzp`']"/>
## 中国研究生招生信息网
### 考研热点新闻

38
lib/v2/cssn/iolaw.js Normal file
View File

@ -0,0 +1,38 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const section = ctx.params.section ?? 'zxzp';
const domain = 'iolaw.cssn.cn';
const response = await got(`http://${domain}/${section}/`);
const data = response.data;
const $ = cheerio.load(data);
const list = $('div.notice_right ul li')
.map((_, item) => {
item = $(item);
const url = `http://${domain}` + item.find('a').attr('href').substr(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,
};
})
.get();
ctx.state.data = {
title: '中国法学网',
url: `http://${domain}/${section}/`,
description: '中国法学网',
item: list.map((item) => ({
title: item.title,
pubDate: item.pubtime,
link: item.link,
author: item.author,
})),
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/iolaw/:section?': ['HankChow'],
};

11
lib/v2/cssn/radar.js Normal file
View File

@ -0,0 +1,11 @@
module.exports = {
'cssn.cn': {
_name: '中国社会科学网',
iolaw: [
{
title: '中国法学网',
docs: 'https://docs.rsshub.app/study.html#zhong-guo-she-hui-ke-xue-wang',
},
],
},
};

3
lib/v2/cssn/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/iolaw/:section?', require('./iolaw'));
};