feat(route): add kimlaw (#11786)

This commit is contained in:
Tony
2023-02-06 07:57:40 -05:00
committed by GitHub
parent 36fe2e1d06
commit db4e8ed8f1
6 changed files with 75 additions and 0 deletions

View File

@@ -114,6 +114,12 @@ pageClass: routes
<RouteEn author="nczitzk" example="/researchgate/publications/Somsak-Panha" path="/researchgate/publications/:username" :paramsDesc="['Username, can be found in URL']" puppeteer="1" anticrawler="1"/> <RouteEn author="nczitzk" example="/researchgate/publications/Somsak-Panha" path="/researchgate/publications/:username" :paramsDesc="['Username, can be found in URL']" puppeteer="1" anticrawler="1"/>
## The Korea Institute of Marine Law
### Thesis
<RouteEn author="TonyRL" example="/kimlaw/thesis" path="/kimlaw/thesis" radar="1"/>
## X-MOL ## X-MOL
### News ### News

View File

@@ -314,6 +314,12 @@ path="/ctfhub/upcoming/:limit?"
</Route> </Route>
## 韓國海事法學會
### 学术论文
<Route author="TonyRL" example="/kimlaw/thesis" path="/kimlaw/thesis" radar="1"/>
## 杭州市国家普通话测试网报信息 ## 杭州市国家普通话测试网报信息
### 考试信息 ### 考试信息

View File

@@ -0,0 +1,3 @@
module.exports = {
'/thesis': ['TonyRL'],
};

13
lib/v2/kimlaw/radar.js Normal file
View File

@@ -0,0 +1,13 @@
module.exports = {
'kimlaw.or.kr': {
_name: '韓國海事法學會',
'.': [
{
title: '学术论文',
docs: 'https://docs.rsshub.app/study.html#han-guo-hai-shi-fa-xue-hui',
source: ['/67', '/'],
target: '/kimlaw/thesis',
},
],
},
};

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

@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/thesis', require('./thesis'));
};

44
lib/v2/kimlaw/thesis.js Normal file
View File

@@ -0,0 +1,44 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const baseUrl = 'https://www.kimlaw.or.kr';
module.exports = async (ctx) => {
const link = `${baseUrl}/67`;
const { data: response } = await got(link);
const $ = cheerio.load(response);
const list = $('.li_body')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a.list_text_title');
return {
title: a.text(),
link: `${baseUrl}${a.attr('href')}`,
author: item.find('.name').text(),
pubDate: timezone(parseDate(item.find('.time').attr('title')), 9),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
item.description = $('.board_txt_area').html();
return item;
})
)
);
ctx.state.data = {
title: `${$('.widget_menu_title').text()} - ${$('head title').text()}`,
link,
image: 'https://cdn.imweb.me/upload/S20210819f9dd86d20e7d7/9aec17c4e98a5.ico',
item: items,
};
};