mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 18:06:31 +08:00
fix(route): cnki/journals (#12949)
This commit is contained in:
+1
-1
@@ -515,7 +515,7 @@ You can get all short name of a journal from <https://www.nature.com/siteindex>
|
||||
|
||||
### 期刊
|
||||
|
||||
<Route author="Fatpandac" example="/cnki/journals/LKGP" path="/cnki/journals/:name" :paramsDesc="['期刊缩写,可以在网址中得到']"/>
|
||||
<Route author="Fatpandac Derekmini" example="/cnki/journals/LKGP" path="/cnki/journals/:name" :paramsDesc="['期刊缩写,可以在网址中得到']"/>
|
||||
|
||||
### 网络首发
|
||||
|
||||
|
||||
+25
-31
@@ -3,51 +3,45 @@ const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { ProcessItem } = require('./utils');
|
||||
|
||||
const rootUrl = 'https://chn.oversea.cnki.net';
|
||||
const rootUrl = 'https://navi.cnki.net';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { name } = ctx.params;
|
||||
const journalUrl = `${rootUrl}/knavi/JournalDetail?pcode=CjFD&pykm=${name}`;
|
||||
const journalUrl = `${rootUrl}/knavi/journals/${name}/detail`;
|
||||
const title = await got.get(journalUrl).then((res) => cheerio.load(res.data)('head > title').text());
|
||||
|
||||
const yaerListUrl = `${rootUrl}/knavi/JournalDetail/GetJournalYearList?pcode=CJFD&pykm=${name}&pIdx=0`;
|
||||
const journalsInfo = await got.get(yaerListUrl).then((res) => {
|
||||
const yearListUrl = `${rootUrl}/knavi/journals/${name}/yearList?pIdx=0`;
|
||||
|
||||
const { code, date } = await got.get(yearListUrl).then((res) => {
|
||||
const $ = cheerio.load(res.data);
|
||||
const date = $('dd').find('a').first().attr('id').replace('yq', '');
|
||||
const year = date.substring(0, 4);
|
||||
const issue = date.substring(4);
|
||||
const code = $('.yearissuepage').find('dl').first().find('dd').find('a').first().attr('value');
|
||||
const date = parseDate($('.yearissuepage').find('dl').first().find('dd').find('a').first().attr('id').replace('yq', ''), 'YYYYMM');
|
||||
return { code, date };
|
||||
});
|
||||
|
||||
const yearIssueUrl = `${rootUrl}/knavi/journals/${name}/papers?yearIssue=${code}&pageIdx=0&pcode=CJFD,CCJD`;
|
||||
const response = await got.post(yearIssueUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const publications = $('dd');
|
||||
|
||||
const list = publications.map((_, publication) => {
|
||||
const title = $(publication).find('a').first().text();
|
||||
const filename = $(publication).find('b').attr('id');
|
||||
const link = `https://cnki.net/kcms/detail/detail.aspx?filename=${filename}&dbcode=CJFD`;
|
||||
|
||||
return {
|
||||
year,
|
||||
issue,
|
||||
date,
|
||||
title,
|
||||
link,
|
||||
pubDate: date,
|
||||
};
|
||||
});
|
||||
|
||||
const papersUrl = `${rootUrl}/knavi/JournalDetail/GetArticleList?year=${journalsInfo.year}&issue=${journalsInfo.issue}&pykm=${name}&pageIdx=0&pcode=CjFD`;
|
||||
const list = await got.get(papersUrl).then((res) => {
|
||||
const $ = cheerio.load(res.data);
|
||||
const item = $('span.name')
|
||||
.map((_, item) => {
|
||||
const url = new URL(`${rootUrl}/${$(item).find('a').attr('href')}`);
|
||||
const urlParams = new URLSearchParams(url.search);
|
||||
|
||||
return {
|
||||
title: $(item).find('a').text().trim(),
|
||||
link: `${rootUrl}/kcms/detail/detail.aspx?dbcode=${urlParams.get('dbCode')}&filename=${urlParams.get('filename')}`,
|
||||
pubDate: parseDate(journalsInfo.date, 'YYYYMM'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
return item;
|
||||
});
|
||||
}).get();
|
||||
|
||||
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => ProcessItem(item))));
|
||||
|
||||
ctx.state.data = {
|
||||
title: String(title),
|
||||
link: `https://navi.cnki.net/knavi/journals/${name}/detail`,
|
||||
link: journalUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
'/journals/:name': ['Fatpandac'],
|
||||
'/journals/:name': ['Fatpandac', 'Derekmini'],
|
||||
'/journals/debut/:name': ['Fatpandac'],
|
||||
'/author/:code': ['harveyqiu', 'Derekmini'],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user