diff --git a/docs/journal.md b/docs/journal.md index 42ada50ca..4d743bb31 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -505,6 +505,12 @@ You can get all short name of a journal from +## 环球法律评论 + +### 期刊 + + + ## 中国知网 ### 期刊 diff --git a/lib/v2/globallawreview/index.js b/lib/v2/globallawreview/index.js new file mode 100644 index 000000000..4b5ffab6d --- /dev/null +++ b/lib/v2/globallawreview/index.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30; + + const rootUrl = 'http://www.globallawreview.org'; + + const { data: firstResponse } = await got(rootUrl); + + let $ = cheerio.load(firstResponse); + + const currentUrl = new URL($('p.tabBtn span a').prop('href'), rootUrl).href; + + const { data: response } = await got(currentUrl); + + $ = cheerio.load(response); + + const items = $('ul.digest li') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const a = item.find('p.p1 a'); + const link = new URL(a.prop('href'), rootUrl).href; + + return { + title: a.text(), + link, + description: item.find('p.p2').html(), + author: item.find('p.p3 span').text() || a.text().split(':')[0], + category: [ + item + .find('p.p4') + .text() + .match(/] (\d+\.\d+);/)[1], + ], + enclosure_url: link, + enclosure_length: + item + .find('p.p4') + .text() + .match(/(\d+(\.\d+)?)\sKB/)[1] * 1000, + }; + }); + + ctx.state.data = { + item: items, + title: $('title').text(), + link: currentUrl, + language: 'zh-cn', + author: '中国社会科学院法学研究所', + }; +}; diff --git a/lib/v2/globallawreview/maintainer.js b/lib/v2/globallawreview/maintainer.js new file mode 100644 index 000000000..ca7cf1eb1 --- /dev/null +++ b/lib/v2/globallawreview/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['nczitzk'], +}; diff --git a/lib/v2/globallawreview/radar.js b/lib/v2/globallawreview/radar.js new file mode 100644 index 000000000..8360882d0 --- /dev/null +++ b/lib/v2/globallawreview/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'globallawreview.org': { + _name: '环球法律评论', + '.': [ + { + title: '期刊', + docs: 'https://docs.rsshub.app/journal.html#huan-qiu-fa-lu-ping-lun', + source: ['/Magazine/GetIssueContentList', '/'], + target: '/globallawreview', + }, + ], + }, +}; diff --git a/lib/v2/globallawreview/router.js b/lib/v2/globallawreview/router.js new file mode 100644 index 000000000..6952a50b4 --- /dev/null +++ b/lib/v2/globallawreview/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./')); +};