diff --git a/docs/finance.md b/docs/finance.md index 76d076992..b2d60331f 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -387,7 +387,7 @@ TokenInsight 官方亦有提供 RSS,可参考 + ### 可转换公司债券公告 diff --git a/docs/journal.md b/docs/journal.md index d306716dc..b1e8c4adc 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -383,3 +383,7 @@ You can get all short name of a journal from ### 网络首发 + +### 作者期刊文献 + + diff --git a/lib/v2/cnki/author.js b/lib/v2/cnki/author.js new file mode 100644 index 000000000..dd6f70e37 --- /dev/null +++ b/lib/v2/cnki/author.js @@ -0,0 +1,45 @@ +const utils = require('./utils'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'https://chn.oversea.cnki.net/kcms/detail/frame/knetlist.aspx?infotype=4&codetype=1&vl=&'; +const authorPageRootUrl = 'https://kns.cnki.net/kcms/detail/knetsearch.aspx?sfield=au&'; + +module.exports = async (ctx) => { + const { code } = ctx.params; + + const authorPageUrl = `${authorPageRootUrl}code=${code}`; + + const res = await got(authorPageUrl); + const $ = cheerio.load(res.data); + const authorName = $('#showname').text(); + const companyName = $('body > div.wrapper > div.main > div.container.full-screen > div > div:nth-child(3) > h3:nth-child(2) > span > a').text(); + + const url = `${rootUrl}code=${code}`; + + const list = await got + .get(url, { + headers: { + Referer: authorPageUrl, + }, + }) + .then((res) => { + const $ = cheerio.load(res.data); + const list = $('.bignum') + .children() + .map((_, e) => ({ + title: $(e).find('a').first().text().trim(), + link: 'https://chn.oversea.cnki.net' + $(e).find('a').first().attr('href'), + })) + .get(); + return list; + }); + + const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => utils.ProcessItem(item)))); + + ctx.state.data = { + title: `知网 ${authorName} ${companyName}`, + link: authorPageUrl, + item: items, + }; +}; diff --git a/lib/v2/cnki/journals.js b/lib/v2/cnki/journals.js index eca97d2d6..cad800887 100644 --- a/lib/v2/cnki/journals.js +++ b/lib/v2/cnki/journals.js @@ -1,8 +1,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); -const { art } = require('@/utils/render'); -const path = require('path'); +const { ProcessItem } = require('./utils'); const rootUrl = 'https://chn.oversea.cnki.net'; @@ -44,27 +43,7 @@ module.exports = async (ctx) => { return item; }); - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got.get(item.link); - const $ = cheerio.load(detailResponse.data); - item.description = art(path.join(__dirname, 'templates/desc.art'), { - author: $('h3.author > span') - .map((_, item) => $(item).text()) - .get() - .join(' '), - company: $('a.author') - .map((_, item) => $(item).text()) - .get() - .join(' '), - content: $('div.row > span.abstract-text').parent().text(), - }); - - return item; - }) - ) - ); + const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => ProcessItem(item)))); ctx.state.data = { title: String(title), diff --git a/lib/v2/cnki/maintainer.js b/lib/v2/cnki/maintainer.js index 952d141e4..5bf0a3e28 100644 --- a/lib/v2/cnki/maintainer.js +++ b/lib/v2/cnki/maintainer.js @@ -1,4 +1,5 @@ module.exports = { '/journals/:name': ['Fatpandac'], '/journals/debut/:name': ['Fatpandac'], + '/author/:code': ['harveyqiu'], }; diff --git a/lib/v2/cnki/radar.js b/lib/v2/cnki/radar.js index ed759578b..22dc9f4b3 100644 --- a/lib/v2/cnki/radar.js +++ b/lib/v2/cnki/radar.js @@ -15,5 +15,13 @@ module.exports = { target: '/cnki/journals/debut/:name', }, ], + kns: [ + { + title: '作者期刊文献', + docs: 'https://docs.rsshub.app/journal.html#zhong-guo-zhi-wang-zuo-zhe-qi-kan-wen-xian', + source: ['/kcms/detail/knetsearch.aspx', '/'], + target: (_, url) => `/cnki/author/${new URL(url).searchParams.get('code')}`, + }, + ], }, }; diff --git a/lib/v2/cnki/router.js b/lib/v2/cnki/router.js index 8248af621..9875efa6f 100644 --- a/lib/v2/cnki/router.js +++ b/lib/v2/cnki/router.js @@ -1,4 +1,5 @@ module.exports = function (router) { router.get('/journals/:name', require('./journals')); router.get('/journals/debut/:name', require('./debut')); + router.get('/author/:code', require('./author')); }; diff --git a/lib/v2/cnki/utils.js b/lib/v2/cnki/utils.js new file mode 100644 index 000000000..6619b4d88 --- /dev/null +++ b/lib/v2/cnki/utils.js @@ -0,0 +1,26 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const ProcessItem = async (item) => { + const detailResponse = await got(item.link); + const $ = cheerio.load(detailResponse.data); + item.description = art(path.join(__dirname, 'templates/desc.art'), { + author: $('h3.author > span') + .map((_, item) => $(item).text()) + .get() + .join(' '), + company: $('a.author') + .map((_, item) => $(item).text()) + .get() + .join(' '), + content: $('div.row > span.abstract-text').parent().text(), + }); + + return item; +}; + +module.exports = { + ProcessItem, +}; diff --git a/lib/v2/sse/maintainer.js b/lib/v2/sse/maintainer.js index aa2688b00..76b41676d 100644 --- a/lib/v2/sse/maintainer.js +++ b/lib/v2/sse/maintainer.js @@ -1,6 +1,6 @@ module.exports = { '/convert/:query?': ['kt286'], - '/disclosure/:query?': ['alienmao'], + '/disclosure/:query?': ['harveyqiu'], '/inquire': ['Jeason0228'], '/lawandrules/:slug?': ['nczitzk'], '/renewal': ['Jeason0228'],