-
Notifications
You must be signed in to change notification settings - Fork 526
/
CNKI.js
2972 lines (2880 loc) · 115 KB
/
CNKI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"translatorID": "5c95b67b-41c5-4f55-b71a-48d5d7183063",
"label": "CNKI",
"creator": "Aurimas Vinckevicius, Xingzhong Lin, jiaojiaodubai",
"target": "https?://.*?(cnki\\.net)?/(kns8?s?|kcms2?|KNavi|xmlRead)/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 150,
"inRepository": true,
"translatorType": 12,
"browserSupport": "gcsibv",
"lastUpdated": "2024-10-04 22:36:27"
}
/*
***** BEGIN LICENSE BLOCK *****
CNKI(China National Knowledge Infrastructure) Translator
Copyright © 2013 Aurimas Vinckevicius
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
// Whether user ip is in Chinese Mainland, default is true.
let inMainland = true;
// Platform of CNKI, default to the National Zong Ku Ping Tai(pin yin of "Total Database Platform").
// It may be modified when this Translator called by other translators.
const platform = 'NZKPT';
/*********************
* search translator *
*********************/
function detectSearch(items) {
return (filterQuery(items).length > 0);
}
/**
* @param {*} items items or string.
* @returns an array of DOIs.
*/
function filterQuery(items) {
Z.debug('input items:');
Z.debug(items);
if (!items) return [];
if (typeof items == 'string' || !items.length) items = [items];
// filter out invalid queries
let dois = [], doi;
for (let i = 0, n = items.length; i < n; i++) {
if (items[i].DOI && /(\/j\.issn|\/[a-z]\.cnki)/i.test(items[i].DOI) && (doi = ZU.cleanDOI(items[i].DOI))) {
dois.push(doi);
}
else if (typeof items[i] == 'string' && /(\/j\.issn|\/[a-z]\.cnki)/i.test(items[i]) && (doi = ZU.cleanDOI(items[i]))) {
dois.push(doi);
}
}
Z.debug('return dois:');
Z.debug(dois);
return dois;
}
async function doSearch(items) {
const respond = await fetch('https://chn.oversea.cnki.net/kns');
Z.debug(respond);
if (respond.ok) {
inMainland = false;
}
Z.debug(`inMainland: ${inMainland}`);
for (const doi of filterQuery(items)) {
const url = `https://doi.org/${encodeURIComponent(doi)}`;
Z.debug(`search url: ${url}`);
let doc = await requestDocument(url);
const mainlandLink = doc.querySelector('.feedbackresult tr:last-child a[href*="link.cnki.net"]');
Z.debug(`mainlandLink: ${!!mainlandLink}`);
const overseaLinnk = doc.querySelector('.feedbackresult tr:last-child a[href*="link.oversea.cnki.net"]');
Z.debug(`overseaLink: ${!!overseaLinnk}`);
if (mainlandLink && overseaLinnk) {
if (inMainland) {
doc = await requestDocument(mainlandLink.href);
}
else {
doc = await requestDocument(overseaLinnk.href);
}
}
Z.debug(doc.body);
await doWeb(doc, url);
}
}
/******************
* web translator *
******************/
/**
* A mapping table of database code to item type.
* It may be modified when this Translator called by other translators.
*/
const typeMap = {
/*
In the following comments,
"wai wen" indicates the pinyin of Chinese word "外文", meaning "foreign language",
"zong ku" indicates the pinyin of Chinese word "总库", meaning "total database".
*/
// 中国学术期刊全文数据库(China Academic Journal Full-text Database, AKA CAJD, CJZK)
CJFD: 'journalArticle',
CJFQ: 'journalArticle',
// 中国预出版期刊全文数据库(China Advance Publish Journal Full-text Database)
CAPJ: 'journalArticle',
// 外文学术期刊数据库(Wai Wen Journal Database)
WWJD: 'journalArticle',
// 特色期刊 journal
CJFN: 'journalArticle',
// 中国学术辑刊全文数据库(China Collected Journal Database)
CCJD: 'journalArticle',
/* thesis */
// 中国博硕士学位论文全文数据库(China Doctoral Dissertations and Master’s Theses Full-text Database)
CDMD: 'thesis',
// 中国博士学位论文全文数据库(China Doctoral Dissertations Full-text Database)
CDFD: 'thesis',
// 中国优秀硕士学位论文全文数据库(China Master’s Theses Full-text Database)
CMFD: 'thesis',
// 中国重要报纸全文数据库(China Core Newspapers Full-text Database)
CCND: 'newspaperArticle',
/* patent */
// 境内外专利全文数据库(China & Outbound Patent Full-text Database)
SCOD: 'patent',
// 中国专利全文数据库(China Patent Full-text Database)
SCPD: 'patent',
// 境外专利全文数据库(Outbound Patent Full-text Database)
SOPD: 'patent',
// 中国年鉴全文数据库(China Yearbook Full-text Database)
CYFD: 'bookSection',
/* conference paper */
// 国际及国内会议论文全文数据库(Cina & International Important Proceeding Full-text Database)
CIPD: 'conferencePaper',
// 中国会议论文全文数据库(Cina Proceeding Full-text Database)
CPFD: 'conferencePaper',
// 国际会议论文全文数据库(International Proceeding Full-text Database)
IPFD: 'conferencePaper',
// 国外会议全文数据库(Wai Wen Proceeding Full-text Database)
WWPD: 'conferencePaper',
// 会议视频(China Proceeding Video Database)
CPVD: 'conferencePaper',
// 视频(China Conference Video Database)
CCVD: 'videoRecording',
/* book */
// Book Datab 总库
BDZK: 'book',
// 中文图书 book, zh
WBFD: 'book',
// 外文图书数据库(wai wen Book Database)
WWBD: 'book',
/* Standard */
// 标准数据总库(Cina & International Stand Database)
CISD: 'standard',
// 中国标准全文数据库(China Standard Full-text Database)
SCSF: 'standard',
// 中国行业标准全文数据库(China Hang Ye Standard Full-text Database)
SCHF: 'standard',
// 中国标准题录数据库(China Standard Full-text Database)
SCSD: 'standard',
// 国外标准全文数据库(Outbound Standard Full-text Database)
SOSD: 'standard',
/* report */
// 中国科技项目创新成果鉴定意见数据库(National Science and Technology Project Innovation Achievement Appraisal Opinion Database)
SNAD: 'report',
// 科技报告(Chinese pinyin "Ke Ji Bao Gao", means "Science & Technology Report")
KJBG: 'report',
/* statute */
// 中国政报公报期刊文献总库
// GWKT: 'statute',
// 中国法律知识总库(Cina Law Knowledge Database)
// CLKD: 'statute',
/* Rare dbcode migrations from previous code or from user-reported cases. */
CJZK: 'journalArticle',
// legacy, see sample on https://www.52pojie.cn/thread-1231722-1-1.html
SJES: 'journalArticle',
SJPD: 'journalArticle',
SSJD: 'journalArticle'
};
// A list of databases containing only English literature for language determination.
// It may be modified when this Translator called by other translators.
const enDatabase = ['WWJD', 'IPFD', 'WWPD', 'WWBD', 'SOSD'];
// A list of databases that look like CNKI Scholar.
// It may be modified when this Translator called by other translators.
const scholarLike = ['WWJD', 'WWBD'];
/**
* A series of identifiers for item, used to request data from APIs.
*/
class ID {
constructor(doc, url) {
const frame = {
dbname: {
selector: 'input#paramdbname',
pattern: /[?&](?:db|table)[nN]ame=([^&#/]*)/i
},
filename: {
selector: 'input#paramfilename',
pattern: /[?&]filename=([^&#/]*)/i
},
dbcode: {
selector: 'input#paramdbcode',
pattern: /[?&]dbcode=([^&#/]*)/i
}
};
for (const key in frame) {
this[key] = attr(doc, frame[key].selector, 'value')
|| tryMatch(url, frame[key].pattern, 1);
}
this.dbcode = this.dbcode || this.dbname.substring(0, 4).toUpperCase();
this.url = url;
}
/**
* @returns true when both necessary dbcode and filename are available.
*/
toBoolean() {
return Boolean(this.dbname && this.filename);
}
toItemtype() {
return exports.typeMap[this.dbcode];
}
toLanguage() {
// zh database code: CJFQ,CDFD,CMFD,CPFD,IPFD,CPVD,CCND,WBFD,SCSF,SCHF,SCSD,SNAD,CCJD,CJFN,CCVD
// en database code: WWJD,IPFD,WWPD,WWBD,SOSD
return exports.enDatabase.includes(this.dbcode)
? 'en-US'
: 'zh-CN';
}
}
function detectWeb(doc, url) {
const ids = new ID(doc, url);
Z.debug('detect ids:');
Z.debug(ids);
const multiplePattern = [
/*
search
https://kns.cnki.net/kns/search?dbcode=SCDB
https://kns.cnki.net/kns8s/
*/
/kns8?s?\/search\??/i,
/* https://kns.cnki.net/kns8s/defaultresult/index?korder=&kw= */
/kns8?s?\/defaultresult\/index/i,
/*
advanced search
old version: https://kns.cnki.net/kns/advsearch?dbcode=SCDB
new version: https://kns.cnki.net/kns8s/AdvSearch?classid=WD0FTY92
*/
/KNS8?s?\/AdvSearch\?/i,
/*
navigation page
https://navi.cnki.net/knavi/journals/ZGSK/detail?uniplatform=NZKPT
*/
/\/KNavi\//i
];
// #ModuleSearchResult for commom CNKI,
// #contentPanel for journal/yearbook navigation,
// .main_sh for old version
const searchResult = doc.querySelector('#ModuleSearchResult, #contentPanel, .main_sh');
if (searchResult) {
Z.monitorDOMChanges(searchResult, { childList: true, subtree: true });
}
if (ids.toBoolean()) {
// Sometimes dbcode is not a known type, and the itmType cannot be determined by dbcode.
// But the itemType does not affect the api request, and we can get its real item type later,
// so it appears temporarily as a journal article.
return ids.toItemtype() || 'journalArticle';
}
else if (multiplePattern.some(element => element.test(url)) && getSearchResults(doc, url, true)) {
return 'multiple';
}
return false;
}
function getSearchResults(doc, url, checkOnly) {
const items = {};
let found = false;
const multiplePage = [
/*
journal navigation
https://navi.cnki.net/knavi/journals/ZGSK/detail?uniplatform=NZKPT
*/
{
isMatch: /\/journals\/.+\/detail/i.test(url),
// 过刊浏览,栏目浏览
row: '#rightCatalog dd, .searchresult-list tbody > tr',
a: '.name > a',
cite: 'td[align="center"]:nth-last-child(2)',
download: 'td[align="center"]:last-child'
},
/*
thesis navigation
https://navi.cnki.net/knavi/degreeunits/GBEJU/detail?uniplatform=NZKPT
*/
{
isMatch: /\/degreeunits\/.+\/detail/i.test(url),
row: '#rightCatalog tbody > tr',
a: '.name > a',
cite: 'td[align="center"]:nth-last-child(2)',
download: 'td[align="center"]:last-child'
},
/*
conference navigation
https://navi.cnki.net/knavi/conferences/030681/proceedings/IKJS202311001/detail?uniplatform=NZKPT
*/
{
isMatch: /\/proceedings\/.+\/detail/i.test(url),
row: '#rightCatalog tbody > tr',
a: '.name > a',
cite: 'td[align="center"]:nth-last-child(2)',
download: 'td[align="center"]:last-child'
},
/*
newspaper navigation
https://navi.cnki.net/knavi/newspapers/RMRB/detail?uniplatform=NZKPT
*/
{
isMatch: /\/newspapers\/.+\/detail/i.test(url),
row: '#rightCatalog tbody > tr',
a: '.name > a'
},
/*
yearbook navigation
https://kns.cnki.net/knavi/yearbooks/YHYNJ/detail?uniplatform=NZKPT
*/
{
isMatch: /\/yearbooks\/.+\/detail/i.test(url),
row: '#rightCatalog .itemNav',
a: 'a'
},
/*
yearbook search result
https://kns.cnki.net/kns8s/defaultresult/index?classid=HHCPM1F8&korder=SU&kw=%E7%85%A4%E7%82%AD
*/
{
isMatch: doc.querySelector('.yearbook-title > a'),
row: 'table.result-table-list tbody tr',
a: '.yearbook-title > a',
download: 'td.download'
},
/* Search page */
{
isMatch: true,
row: 'table.result-table-list tbody tr',
a: 'td.name a',
cite: 'td.quote',
download: 'td.download'
}
].find(page => page.isMatch);
const rows = doc.querySelectorAll(multiplePage.row);
if (!rows.length) return false;
for (let i = 0; i < rows.length; i++) {
const itemKey = {};
const header = rows[i].querySelector(multiplePage.a);
if (!header) continue;
itemKey.url = header.href;
const title = header.getAttribute('title') || ZU.trimInternal(header.textContent);
// Z.debug(`${href}\n${title}`);
if (!itemKey.url || !title) continue;
if (checkOnly) return true;
found = true;
// Identifier used for batch export, the format is different for homeland and oversea versions.
itemKey.cookieName = attr(rows[i], '[name="CookieName"]', 'value');
// attachment download link.
itemKey.downloadlink = attr(rows[i], 'td.operat > a.downloadlink', 'href');
try {
// citation counts.
itemKey.cite = text(rows[i], multiplePage.cite);
// download counts.
itemKey.download = text(rows[i], multiplePage.download);
}
catch (error) {
Z.debug('Failed to get CNKIcite or download.');
}
/* Use the item key to store some useful information */
items[JSON.stringify(itemKey)] = `【${i + 1}】${title}`;
// Z.debug(items);
}
return found ? items : false;
}
// Css selectors for CNKI Scholar like page, to change the default behavior of CNKI Scholar translator.
// It may be modified when this Translator called by other translators.
const csSelectors = {
labels: '.brief h3, .row-scholar',
title: '.h1-scholar',
abstractNote: '#ChDivSummary',
publicationTitle: '.top-tip-scholar > span >a',
pubInfo: '.top-tip-scholar',
publisher: '.all-source a',
DOI: 'no-selector-available',
creators: '.author-scholar > a',
tags: '[id*="doc-keyword"] a',
hightlights: 'no-selector-available',
bookUrl: 'no-selector-available'
};
async function doWeb(doc, url) {
// for inside and outside Chinese Mainland IP, CNKI uses different APIs.
inMainland = !/oversea/i.test(url);
Z.debug(`inMainland: ${inMainland}`);
if (detectWeb(doc, url) == 'multiple') {
let items = await Z.selectItems(getSearchResults(doc, url, false));
if (!items) return;
await scrapeMulti(items, doc);
}
else {
await scrape(doc);
}
}
/**
* For multiple items, prioritize trying to scrape them one by one, as documents always provide more information;
* if it is not possible to obtain item's document, consider using batch export API.
* @param {Object} items, items from Zotero.selectedItems().
*/
async function scrapeMulti(items, doc) {
for (const key in items) {
const itemKey = JSON.parse(key);
try {
// During debugging, may manually throw an error to guide the program to run inward
// throw new Error('debug');
let doc = await requestDocument(itemKey.url);
// CAPTCHA
if (doc.querySelector('#verify_pic')) {
doc = await requestDocument(`https://kns.cnki.net/kcms2/newLink?${tryMatch(itemKey.url, /v=[^&/]+/)}`);
}
await scrape(doc, itemKey);
}
catch (erro1) {
Z.debug('Error encountered while scraping one by one:');
Z.debug(erro1);
try {
if (!Object.keys(items).some(itemKey => JSON.parse(itemKey).cookieName)) {
throw new Error('This page is not suitable for using batch export API');
}
const itemKeys = Object.keys(items)
.map(element => JSON.parse(element))
.filter(element => element.cookieName);
await scrapeWithShowExport(itemKeys, doc);
// batch export API can request all data at once.
break;
}
/*
Some older versions of CNKI may not support retrieving CookieName from search pages.
In these cases, CAPTCHA issue should be handled by the user.
*/
catch (erro2) {
Z.debug(erro2);
const debugItem = new Z.Item('webpage');
debugItem.title = `❌验证码错误!(CAPTCHA Erro!)❌`;
debugItem.url = itemKey.url;
debugItem.abstractNote
= '原始条目在批量抓取过程中遇到验证码,这通常是您向知网请求过于频繁导致的。原始条目的链接已经保存到本条目中,请考虑随后打开这个链接并重新抓取。\n'
+ 'Encountered CAPTCHA during batch scrape process with original item, which is usually caused by your frequent requests to CNKI. The link to original item has been saved to this entry. Please consider opening this link later and re scrap.';
debugItem.complete();
continue;
}
}
}
}
async function scrape(doc, itemKey = { url: '', cite: '', cookieName: '', downloadlink: '' }) {
const url = doc.location.href;
const ids = new ID(doc, url);
Z.debug('scrape single item with ids:');
Z.debug(ids);
if (exports.scholarLike.includes(ids.dbcode)) {
let translator = Zotero.loadTranslator('web');
// CNKI Scholar
translator.setTranslator('b9b97a32-a8aa-4688-bd81-491bec21b1de');
translator.setDocument(doc);
translator.setHandler('itemDone', (_obj, item) => {
item.attachments.push({
title: 'Snapshot',
document: doc
});
item.complete();
});
const cs = await translator.getTranslatorObject();
cs.selectors = exports.csSelectors;
cs.typeKey = text(doc, '.top-tip-scholar > span:first-child');
await cs.scrape(doc, url);
}
else if (ids.toItemtype() == 'videoRecording') {
await scrapeDoc(doc, itemKey);
}
else if (url.includes('thinker.cnki')) {
let translator = Zotero.loadTranslator('web');
// CNKI thinker
translator.setTranslator('5393921c-d543-4b3a-a874-070b5d73b03a');
translator.setDocument(doc);
translator.setHandler('itemDone', (_obj, item) => {
item.complete();
});
await translator.translate();
}
else {
if (/\/xmlRead\//i.test(url)) {
doc = await requestDocument(strChild(doc, 'a.details', 'href'));
}
try {
// During debugging, may manually throw an error to guide the program to run inward
// throw new Error('debug');
await scrapeWithGetExport(doc, ids, itemKey);
}
catch (error1) {
Z.debug('An error was encountered while using GetExport API:');
Z.debug(error1);
try {
// During debugging, may manually throw an error to guide the program to run inward
// throw new Error('debug');
itemKey.cookieName = `${ids.dbname}!${ids.filename}!1!0`;
await scrapeWithShowExport([itemKey], doc);
}
catch (error2) {
Z.debug('An error was encountered while using ShowExport API:');
Z.debug(error2);
await scrapeDoc(doc, itemKey);
}
}
}
}
/**
* API from the "cite" button of the page.
* @param {Element} doc
* @param {ID} ids
* @param {*} itemKey some extra information from "multiple" page.
*/
async function scrapeWithGetExport(doc, ids, itemKey) {
Z.debug('use API: GetExport');
/*
To avoid triggering anti crawlers due to frequent requests,
uncomment the object below during debugging to test functionality unrelated to requests.
*/
/*
referText = {
"code": 1,
"msg": "返回成功",
"data": [
{
"key": "GB/T 7714-2015 格式引文",
"value": [
"[1]陶金, 健康教育与新闻出版 表彰全国九亿农民健康教育行动先进集体和先进工作者. 刘新明;刘益清,中国卫生年鉴,人民卫生出版社,2001,241-242,CHKD年鉴网络出版总库."
]
},
{
"key": "知网研学(原E-Study)",
"value": [
"DataType: 6<br>Title-题名: 健康教育与新闻出版 表彰全国九亿农民健康教育行动先进集体和先进工作者<br>Author-作者: 陶金<br>Source-文献来源: 中国卫生年鉴<br>Year-年鉴年份: 2001<br>PubTime-发表时间: 2001<br>Keyword-关键词: 表彰全国九亿农民健康教育行动先进集体和先进工作者<br>PageCount-页数: 2<br>Page-页码: 241-242<br>SrcDatabase-来源库: CHKD年鉴网络出版总库<br>Organ-出版者: 人民卫生出版社<br>Link-链接: https://kns.cnki.net/kcms2/detail?v=78ssZZiIu9aYur8TjixANLNB9wqzRDceLXMJjuCqyfxhh98oa9YMgKbWALMGlEL83g_zUCRcmBFFnNyzNcG9yhXWKxGVtFw64_2ieV3_sOq5RgLe_KKZfbU1nPWPoWK-2Xadr4yeP1U=&uniplatform=CHKD&language=CHS<br>"
]
},
{
"key": "EndNote",
"value": [
"%0 Legal Rule or Regulation<br>%T 健康教育与新闻出版 表彰全国九亿农民健康教育行动先进集体和先进工作者<br>%V 7-117-04544-2<br>%K 表彰全国九亿农民健康教育行动先进集体和先进工作者<br>%~ CHKD年鉴网络出版总库<br>%P 241-242<br>%W CNKI<br>"
]
}
],
"traceid": "a28ac92deccf46de8e2d1c7fc1b3d2cd.248.17074012330576441"
}
*/
// During debugging, may manually throw an error to guide the program to run inward.
// throw new Error('debug');
const postUrl = inMainland
? '/dm8/API/GetExport'
: '/kns8/manage/APIGetExport';
// "1": row's sequence in search result page, defualt 1; "0": index of page in search result pages, defualt 0.
let postData = inMainland
? `filename=${attr(doc, '#export-id', 'value')}&uniplatform=${exports.platform}`
: `filename=${ids.dbname}!${ids.filename}!1!0`;
// Although there are two data formats that are redundant,
// it can make the request more "ordinary" to server.
postData += '&displaymode=GBTREFER%2Celearning%2CEndNote';
Z.debug(postUrl);
Z.debug(postData);
let referText = await requestJSON(
postUrl,
{
method: 'POST',
body: postData,
headers: {
Referer: ids.url
}
}
);
Z.debug('get respond from API GetExport:');
Z.debug(referText);
if (!referText.data || !referText.data.length) {
throw new ReferenceError(`Failed to retrieve data from API: GetExport\n${JSON.stringify(ids)}\n${JSON.stringify(referText)}`);
}
referText = referText.data[2].value[0].replace(/<br>/g, '\n');
Z.debug(referText);
await parseRefer(referText, doc, ids.url, itemKey);
}
/**
* API from buulk-export button.
* @param {*} itemKey some extra information from "multiple" page.
*/
async function scrapeWithShowExport(itemKeys, doc) {
Z.debug('use API: showExport');
/*
To avoid triggering anti crawlers due to frequent requests,
uncomment the expression below during debugging to test functionality unrelated to requests.
*/
/*
let referText = {
status: 200,
headers: {
connection: "close",
"content-encoding": "br",
"content-type": "text/plain;charset=utf-8",
date: "Sun,03 Dec 2023 14: 56: 40 GMT",
"transfer-encoding": "chunked"
},
body: "<ul class='literature-list'><li> %0 Journal Article<br> %A 贾玲 <br> %+ 晋中市太谷区北洸乡人民政府;<br> %T 抗旱转基因小麦的研究进展<br> %J 种子科技<br> %D 2023<br> %V 41<br>%N 17<br> %K 小麦;抗旱;转基因<br> %X 受气候复杂多变的影响,小麦生长期间干旱胁迫成为影响其产量的主要因素之一,利用基因工程技术提高小麦抗旱性非常必要。目前,已鉴定出一部分与小麦抗旱性相关并可以提高产量的基因,但与水稻、玉米和其他粮食作物相比,对抗旱转基因小麦的开发研究较少。文章重点关注小麦耐旱性的评价标准以及转基因小麦品种在提高抗旱性方面的进展,讨论了当前在转基因小麦方面取得的一些成就和发展中存在的问题,以期为小麦抗旱性基因工程育种提供理论依据。<br>%P 11-14<br> %@ 1005-2690<br> %U https: //link.cnki.net/doi/10.19904/j.cnki.cn14-1160/s.2023.17.004<br> %R 10.19904/j.cnki.cn14-1160/s.2023.17.004<br> %W CNKI<br> </li><li> %0 Journal Article<br> %A 刘志宏<br> %A 田媛<br> %A 陈红娜<br> %A 周志豪<br> %A 郑洁<br> %A 杨晓怀 <br> %+深圳市农业科技促进中心;暨南大学食品科学与工程系;<br> %T 水稻转基因育种的研究进展与应用现状<br> %J 中国种业<br> %D 2023<br> %V <br> %N 09<br> %K 转基因育种;水稻;病虫害;除草剂<br> %X 随着生物技术发展的不断深入,我国水稻种业的发展也面临着全新的机遇和挑战。目前,改善水稻品种质量的主要方法有分子标记技术、基因编辑技术和转基因技术。其中,转基因水稻是利用生物技术手段将外源基因转入到目标水稻的基因组中,通过外源基因的表达,获得具有抗病、抗虫、抗除草剂等优良性状的水稻品种。近年来,国内外在采用转基因技术进行水稻育种,提升水稻产量、改善水稻品质方面具有较多的研究进展。在阐述转基因技术工作原理的基础上,概述国内外利用转基因技术在优质水稻育种方面的研究进展,进一步探究转基因技术在我国水稻育种领域的发展前景。<br>%P 11-17<br> %@ 1671-895X<br> %U https: //link.cnki.net/doi/10.19462/j.cnki.1671-895x.2023.09.038<br> %R10.19462/j.cnki.1671-895x.2023.09.038<br> %W CNKI<br> </li><li> %0 Journal Article<br> %A 孙萌<br> %A 李荣田 <br> %+ 黑龙江大学生命科学学院/黑龙江省普通高等学校分子生物学重点实验室;黑龙江大学农业微生物技术教育部工程研究中心;<br> %T 基于文献计量学的中国水稻转录组研究进展<br> %J 环境工程<br> %D 2023<br> %V 41<br> %N S2<br> %K 水稻转录组;文献计量学;VOSviewer<br> %X 为了探究水稻转录组(Ricetranscriptome)研究的热点与趋势,本研究基于CNKI数据库,基于文献计量学的方法,对中国的发文量、关键词、研究机构、作者、基金、学科方向,进行相关分析。发现水稻转录组的研究进展与趋势动态,旨在为水稻转录组等领域的研究人员提供一定量的数据进行参考。结果显示:2003—2021年水稻转录组的研究论文数量共1512篇;文献的数量逐年增加,其中在2020年的产出数量最高;发文量前3的作者分别是刘向东、吴锦文、梁五生;华中农业大学,南京农业大学,浙江大学,中国农业科学院,华南农业大学发表的水稻转录组文献数量居全国前5位;该领域主要研究学科是,农作物、植物保护、园艺、生物学和林业等;国家自然科学基金是支持水稻转录组研究的主要项目。综合来看,中国在研究水稻转录组领域处于优势地位。<br>%P 1016-1019<br> %@ 1000-8942<br> %U https://kns.cnki.net/kcms2/article/abstract?v=ebrKgZyeBkxImzDUXjcVU04XYh7-VuK-twxFNRUx7mIL4CLVOe5VfbRl0TM7H3f_mb78up_-AjT2Rwgo5xU0wbsknYXBxlrO6GG-wlfR5dIIK8MKL8g8Vmc4O-Q3_qdDWz1MlRhZmckhhPAGlFwAFQ==&uniplatform=NZKPT&language=CHS<br>%W CNKI<br> </li></ul><input id='hidMode' type='hidden' value='BATCH_DOWNLOAD,EXPORT,CLIPYBOARD,PRINT'><input id='traceid' type='hidden'value='27077cd0510c4c989a7ac58b5541a910.173062.17016154007783847'>"
};
*/
// During debugging, may manually throw an error to guide the program to run inward
// throw new Error('debug');
const postUrl = inMainland
? 'https://kns.cnki.net/dm8/api/ShowExport'
: `${doc.location.protocol}//${doc.location.host}/kns/manage/ShowExport`;
Z.debug(postUrl);
const postData = `FileName=${itemKeys.map(key => key.cookieName).join(',')}`
+ '&DisplayMode=EndNote'
+ '&OrderParam=0'
+ '&OrderType=desc'
+ '&SelectField='
+ `${inMainland ? `&PageIndex=1&PageSize=20&language=CHS&uniplatform=${exports.platform}` : ''}`
+ `&random=${Math.random()}`;
Z.debug(postData);
const refer = inMainland
? 'https://kns.cnki.net/dm8/manage/export.html?'
: `${doc.location.protocol}//${doc.location.host}/manage/export.html?displaymode=EndNote`;
let referText = await request(
postUrl,
{
method: 'POST',
body: postData,
headers: {
Referer: refer
}
}
);
Z.debug('get batch response from API ShowExport:');
Z.debug(`${JSON.stringify(referText)}`);
if (!referText.body || !referText.body.length) {
throw new ReferenceError('Failed to retrieve data from API: ShowExport');
}
referText = referText.body
// prefix
.replace(/^<ul class='literature-list'>/, '')
// suffix
.replace(/<\/ul><input.*>$/, '')
.match(/<li>.*?<\/li>/g);
for (let i = 0; i < referText.length; i++) {
let text = referText[i];
text = text.replace(/(^<li>\s*|\s*<\/li>$)/g, '').replace(/<br>/g, '\n');
Z.debug(text);
await parseRefer(
text,
doc,
itemKeys[i].url,
itemKeys[i]);
}
}
/**
* Alternative offline scrapping scheme.
* @param {Element} doc
* @param {*} itemKey some extra information from "multiple" page.
*/
async function scrapeDoc(doc, itemKey) {
Z.debug('scraping from document...');
const url = doc.location.href;
const ids = new ID(doc, url);
const newItem = new Zotero.Item(ids.toItemtype());
const labels = new Labels(doc, 'div.doc div[class^="row"], li.top-space, .total-inform > span');
const extra = new Extra();
Z.debug(labels.data.map(element => [element[0], ZU.trimInternal(element[1].textContent)]));
richTextTitle(newItem, doc);
newItem.abstractNote = attr(doc, '#abstract_text', 'value');
const doi = labels.get('DOI');
if (ZU.fieldIsValidForType('DOI', newItem.itemType)) {
newItem.DOI = doi;
}
else {
extra.set('DOI', doi, true);
}
/* URL */
if (!newItem.url || !/filename=/i.test(url)) {
if (doi) {
newItem.url = 'https://doi.org/' + doi;
}
else {
newItem.url = 'https://kns.cnki.net/KCMS/detail/detail.aspx?'
+ `dbcode=${ids.dbcode}`
+ `&dbname=${ids.dbname}`
+ `&filename=${ids.filename}`;
}
}
newItem.language = ids.toLanguage();
/* creators */
let creators = Array.from(doc.querySelectorAll('#authorpart > span > a[href*="/author/"]')).map(element => ZU.trimInternal(element.textContent).replace(/[\d,\s-]+$/, ''));
if (!creators.length && doc.querySelectorAll('#authorpart > span').length) {
creators = Array.from(doc.querySelectorAll('#authorpart > span')).map(element => ZU.trimInternal(element.textContent).replace(/[\d\s,;,;~-]*$/, ''));
}
if (!creators.length && doc.querySelector('h3 > span:only-child')) {
creators = ZU.trimInternal(doc.querySelector('h3 > span:only-child').textContent)
.replace(/\(.+?\)$/, '')
.replace(/([\u4e00-\u9fff]),\s?([\u4e00-\u9fff])/g, '$1;$2')
.split(/[;,;]/)
.filter(string => !(new RegExp([
'institute',
'institution',
'organization',
'company',
'corporation',
'firm',
'laboratory',
'lab',
'co\\.ltd',
'school',
'university',
'college'
].map(word => `\\b${word}\\b`)
.join('|'), 'i')
.test(string)))
.map(string => string.replace(/[\d\s,~-]*$/, ''));
}
creators.forEach((string) => {
newItem.creators.push(cleanName(string, 'author'));
});
/* tags */
const tags = [
Array.from(doc.querySelectorAll('.keywords > a')).map(element => ZU.trimInternal(element.textContent).replace(/[,;,;]$/, '')),
labels.get(['关键词', '關鍵詞', 'keywords']).split(/[;,;]\s*/)
].find(arr => arr.length);
if (tags) newItem.tags = tags;
/* specific Fields */
switch (newItem.itemType) {
case 'journalArticle': {
const pubInfo = ZU.trimInternal(innerText(doc, '.top-tip'));
newItem.publicationTitle = tryMatch(pubInfo, /^(.+?)\./, 1).trim().replace(/\(([\u4e00-\u9fff]*)\)$/, '($1)');
newItem.volume = tryMatch(pubInfo, /,\s?0*([1-9]\d*)\s*\(/, 1);
newItem.issue = tryMatch(pubInfo, /\(([A-Z]?\d*)\)/i, 1).replace(/0*(\d+)/, '$1');
newItem.pages = labels.get(['页码', '頁碼', 'Page$']);
newItem.date = tryMatch(pubInfo, /\.\s?(\d{4})/, 1);
break;
}
case 'thesis': {
newItem.university = text(doc, 'h3 >span > a[href*="/organ/"]').replace(/\(([\u4e00-\u9fff]*)\)$/, '($1)');
newItem.thesisType = inMainland
? {
CMFD: '硕士学位论文',
CDFD: '博士学位论文',
CDMH: '硕士学位论文'
}[ids.dbcode]
: {
CMFD: 'Master thesis',
CDFD: 'Doctoral dissertation',
CDMH: 'Master thesis'
}[ids.dbcode];
const pubInfo = labels.get('出版信息');
newItem.date = ZU.strToISO(pubInfo);
newItem.numPages = labels.get(['页数', '頁數', 'Page']);
labels.get(['导师', '導師', 'Tutor']).split(/[;,;]\s*/).forEach((supervisor) => {
newItem.creators.push(cleanName(ZU.trimInternal(supervisor), 'contributor'));
});
extra.set('major', labels.get(['学科专业', '學科專業', 'Retraction']));
break;
}
case 'conferencePaper': {
newItem.abstractNote = labels.get(['摘要', 'Abstract']).replace(/^[〈⟨<<]正[>>⟩〉]/, '');
newItem.date = ZU.strToISO(labels.get(['会议时间', '會議時間', 'ConferenceTime']));
newItem.proceedingsTitle = attr(doc, '.top-tip > :first-child', 'title');
newItem.conferenceName = labels.get(['会议名称', '會議名稱', 'ConferenceName']);
newItem.place = labels.get(['会议地点', '會議地點', 'ConferencePlace']);
newItem.pages = labels.get(['页码', '頁碼', 'Page$']);
break;
}
case 'newspaperArticle': {
const subTitle = labels.get(['副标题', '副標題', 'Subtitle']);
if (subTitle) {
newItem.shortTitle = newItem.title;
newItem.title = `${newItem.title}:${subTitle}`;
}
newItem.abstractNote = text(doc, '.abstract-text');
newItem.publicationTitle = text(doc, '.top-tip > a');
newItem.date = ZU.strToISO(labels.get(['报纸日期', '報紙日期', 'NewspaperDate']));
newItem.pages = labels.get(['版号', '版號', 'EditionCode']);
break;
}
case 'bookSection':
newItem.bookTitle = text(doc, '.book-info .book-tit');
newItem.date = tryMatch(labels.get(['来源年鉴', 'SourceYearbook']), /\d{4}/);
newItem.pages = labels.get(['页码', '頁碼', 'Page$']);
newItem.creators = labels.get(['责任说明', '責任說明', 'Statementofresponsibility'])
.replace(/\s*([主]?编|Editor)$/, '')
.split(/[,;,;]/)
.map(creator => cleanName(creator, 'author'));
break;
case 'report':
newItem.abstractNote = labels.get(['成果简介', '成果簡介']);
newItem.creators = labels.get('成果完成人').split(/[,;,;]/).map(creator => cleanName(creator, 'author'));
newItem.date = labels.get(['入库时间', '入庫時間']);
newItem.institution = labels.get(['第一完成单位', '第一完成單位']);
extra.set('achievementType', labels.get(['成果类别', '成果類別']));
extra.set('level', labels.get('成果水平'));
extra.set('evaluation', labels.get(['评价形式', '評價形式']));
break;
case 'standard':
newItem.number = labels.get(['标准号', '標準號', 'StandardNo']);
if (newItem.number.startsWith('GB')) {
newItem.number = newItem.number.replace('-', '——');
newItem.title = newItem.title.replace(/([\u4e00-\u9fff]) ([\u4e00-\u9fff])/, '$1 $2');
}
newItem.status = text(doc, 'h1 > .type');
newItem.date = labels.get(['发布日期', '發佈日期', 'IssuanceDate']);
newItem.numPages = labels.get(['总页数', '總頁數', 'TotalPages']);
extra.set('original-title', text(doc, 'h1 > span'));
newItem.creators = labels.get(['标准技术委员会', '归口单位', '技術標準委員會', '歸口單位', 'StandardTechnicalCommittee'])
.split(/[;,;、]/)
.map(creator => ({
firstName: '',
lastName: creator.replace(/\(.+?\)$/, ''),
creatorType: 'author',
fieldMode: 1
}));
extra.set('applyDate', labels.get(['实施日期', '實施日期']), true);
break;
case 'patent':
newItem.patentNumber = labels.get(['申请公布号', '申請公佈號', 'PublicationNo']);
newItem.applicationNumber = labels.get(['申请\\(专利\\)号', '申請\\(專利\\)號', 'ApplicationNumber']);
newItem.place = newItem.country = patentCountry(newItem.patentNumber || newItem.applicationNumber, newItem.language);
newItem.filingDate = labels.get(['申请日', '申請日', 'ApplicationDate']);
newItem.issueDate = labels.get(['授权公告日', '授權公告日', 'IssuanceDate']);
newItem.rights = text(doc, '.claim > h5 + div');
extra.set('Genre', labels.get(['专利类型', '專利類型']), true);
labels.get(['发明人', '發明人', 'Inventor'])
.split(/[;,;]\s*/)
.forEach((inventor) => {
newItem.creators.push(cleanName(ZU.trimInternal(inventor), 'inventor'));
});
break;
case 'videoRecording':
newItem.abstractNote = labels.get(['视频简介', '視頻簡介']).replace(/\s*更多还原$/, '');
newItem.runningTime = labels.get(['时长', '時長']);
newItem.date = ZU.strToISO(labels.get(['发布时间', '發佈時間']));
extra.set('organizer', labels.get(['主办单位', '主辦單位']), true);
doc.querySelectorAll('h3:first-of-type > span').forEach((element) => {
newItem.creators.push(cleanName(ZU.trimInternal(element.textContent), 'author'));
});
break;
}
/* pages */
if (ZU.fieldIsValidForType('pages', newItem.itemType) && newItem.pages) {
newItem.pages = newItem.pages
.replace(/\d+/g, match => match.replace(/0*([1-9]\d*)/, '$1'))
.replace(/~/g, '-').replace(/\+/g, ', ');
}
/* date, advance online */
if (doc.querySelector('.icon-shoufa')) {
extra.set('Status', 'advance online publication');
newItem.date = ZU.strToISO(text(doc, '.head-time'));
}
/* extra */
extra.set('foundation', labels.get('基金'));
extra.set('download', labels.get(['下载', '下載', 'Download']) || itemKey.download);
extra.set('album', labels.get(['专辑', '專輯', 'Series']));
extra.set('CLC', labels.get(['分类号', '分類號', 'ClassificationCode']));
extra.set('CNKICite', itemKey.cite || attr(doc, '#paramcitingtimes', 'value') || text(doc, '#citations+span').substring(1, -1));
extra.set('dbcode', ids.dbcode);
extra.set('dbname', ids.dbname);
extra.set('filename', ids.filename);
await addPubDetail(newItem, extra, ids, doc);
newItem.extra = extra.toString();
addAttachments(newItem, doc, url, itemKey);
newItem.complete();
}
/**
* Call CNKI Refer.js to parse the text returned by API and supplement some fields from doc elements and itemKey.
* @param {String} referText Refer/BibIX format text from API.
* @param {Element} doc
* @param {String} url
* @param {*} itemKey
*/
async function parseRefer(referText, doc, url, itemKey) {
let item = {};
const labels = new Labels(doc, 'div.doc div[class^="row"], li.top-space, .total-inform > span');
Z.debug('get labels:');
Z.debug(labels.data.map(element => [element[0], ZU.trimInternal(element[1].textContent)]));
const extra = new Extra();
const ids = new ID(doc, url);
const translator = Zotero.loadTranslator('import');
// CNKI Refer
translator.setTranslator('7b6b135a-ed39-4d90-8e38-65516671c5bc');
translator.setString(referText.replace(/<br>/g, '\n'));
translator.setHandler('itemDone', (_obj, patchItem) => {
item = patchItem;
});
await translator.translate();
/* title */
richTextTitle(item, doc);
/* url */
if (!item.url || /\/kcms2\//i.test(item.url)) {
item.url = 'https://kns.cnki.net/KCMS/detail/detail.aspx?'
+ `dbcode=${ids.dbcode}`
+ `&dbname=${ids.dbname}`
+ `&filename=${ids.filename}`;
}
/* specific fields */
switch (item.itemType) {
case 'journalArticle':
if (doc.querySelector('.icon-shoufa')) {
extra.set('Status', 'advance online publication');
item.date = ZU.strToISO(text(doc, '.head-time'));
}
break;
case 'thesis':
item.numPages = labels.get(['页数', '頁數', 'Page']);
extra.set('major', labels.get(['学科专业', '學科專業', 'Retraction']));
break;
case 'conferencePaper': {
item.proceedingsTitle = attr(doc, '.top-tip > :first-child', 'title');
item.conferenceName = labels.get(['会议名称', '會議名稱', 'ConferenceName']);
break;
}
case 'newspaperArticle': {
const subTitle = labels.get(['副标题', '副標題', 'Subtitle']);
if (subTitle) {