From db4e8ed8f1f887d07c838c65a419e831cba6f55e Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 6 Feb 2023 07:57:40 -0500 Subject: [PATCH] feat(route): add kimlaw (#11786) --- docs/en/study.md | 6 +++++ docs/study.md | 6 +++++ lib/v2/kimlaw/maintainer.js | 3 +++ lib/v2/kimlaw/radar.js | 13 +++++++++++ lib/v2/kimlaw/router.js | 3 +++ lib/v2/kimlaw/thesis.js | 44 +++++++++++++++++++++++++++++++++++++ 6 files changed, 75 insertions(+) create mode 100644 lib/v2/kimlaw/maintainer.js create mode 100644 lib/v2/kimlaw/radar.js create mode 100644 lib/v2/kimlaw/router.js create mode 100644 lib/v2/kimlaw/thesis.js diff --git a/docs/en/study.md b/docs/en/study.md index 2e5367d93d..65f2236bb7 100644 --- a/docs/en/study.md +++ b/docs/en/study.md @@ -114,6 +114,12 @@ pageClass: routes +## The Korea Institute of Marine Law + +### Thesis + + + ## X-MOL ### News diff --git a/docs/study.md b/docs/study.md index 027f002494..bb6ed73896 100644 --- a/docs/study.md +++ b/docs/study.md @@ -314,6 +314,12 @@ path="/ctfhub/upcoming/:limit?" +## 韓國海事法學會 + +### 学术论文 + + + ## 杭州市国家普通话测试网报信息 ### 考试信息 diff --git a/lib/v2/kimlaw/maintainer.js b/lib/v2/kimlaw/maintainer.js new file mode 100644 index 0000000000..9a5de98735 --- /dev/null +++ b/lib/v2/kimlaw/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/thesis': ['TonyRL'], +}; diff --git a/lib/v2/kimlaw/radar.js b/lib/v2/kimlaw/radar.js new file mode 100644 index 0000000000..9594081872 --- /dev/null +++ b/lib/v2/kimlaw/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/kimlaw/router.js b/lib/v2/kimlaw/router.js new file mode 100644 index 0000000000..f50b19dd8e --- /dev/null +++ b/lib/v2/kimlaw/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/thesis', require('./thesis')); +}; diff --git a/lib/v2/kimlaw/thesis.js b/lib/v2/kimlaw/thesis.js new file mode 100644 index 0000000000..d4facb381e --- /dev/null +++ b/lib/v2/kimlaw/thesis.js @@ -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, + }; +};