Skip to content

Commit

Permalink
fix(CNKI.js): 修复知网转换器因知网更新造成接口异常。目前恢复单个页面抓取
Browse files Browse the repository at this point in the history
  • Loading branch information
l0o0 committed Nov 19, 2023
1 parent d1e93e2 commit b5e3e07
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions CNKI.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-09-11 13:47:11"
"lastUpdated": "2023-11-18 15:18:49"
}

/*
Expand All @@ -36,10 +36,30 @@
async function getRefWorksByID(id) {
if (!id) return;
var { dbname, filename, url } = id;
let postData = "filename=" + filename +
"&displaymode=Refworks&orderparam=0&ordertype=desc&selectfield=&dbname=" +
dbname + "&random=0.2111567532240084";
let reftext = await requestText('https://kns.cnki.net/KNS8/manage/ShowExport?' + postData);
const postData = `FileName=${dbname}!${filename}!1!0&DisplayMode=Refworks&OrderParam=0&OrderType=desc&SelectField=&PageIndex=1&PageSize=20&language=&uniplatform=NZKPT&random=0.30585230060685187`;
const refer = `https://kns.cnki.net/dm/manage/export.html?filename=${dbname}!${filename}!1!0&displaymode=NEW&uniplatform=NZKPT`;
let reftext = await requestText(
'https://kns.cnki.net/dm/api/ShowExport',
{
method: "POST",
body: postData,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Host": "kns.cnki.net",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
"Accept": "text/plain, */*; q=0.01",
"Accept-Language": "zh-CN,en-US;q=0.7,en;q=0.3",
"Accept-Encoding": "gzip, deflate, br",
"X-Requested-With": "XMLHttpRequest",
"Content-Length": postData.length,
"Origin": "https://kns.cnki.net",
"Connection": "keep-alive",
"Referer": refer,
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin"
}
});
return reftext
.replace("<ul class='literature-list'><li>", "")
.replace("<br></li></ul>", "")
Expand Down

0 comments on commit b5e3e07

Please sign in to comment.