forked from l0o0/translators_CN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CNKI.js
1822 lines (1759 loc) · 74.2 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?://.*?(thinker\\.cnki)|(cnki\\.com)|/(kns8?s?|kcms2?|KXReader|KNavi|Kreader)",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-01-07 10:50:44"
}
/*
***** 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 *****
*/
/* A series of identifiers for item, used to request data from APIs. */
class ID {
constructor(doc, url) {
this.dbname = '';
this.filename = '';
this.dbcode = '';
this.url = '';
if (doc && url) {
this.commonId(doc, url);
}
// For cases where there is only one parameter, what is passed in is actually a URL
else if (doc) {
this.spaceId(doc);
}
}
/* ID initialization method suitable for CNKI space */
// e.g. https://www.cnki.com.cn/Article/CJFDTOTAL-CXKJ202311006.htm
spaceId(url) {
this.filename = tryMatch(url, /-([A-Z\d]+)\./, 1);
this.dbcode = tryMatch(url, /\/([A-Z]{4})TOTAL-/, 1);
this.dbname = `${this.dbcode}AUTO${tryMatch(this.filename, /[A-Z](\d{4})/, 1)}`;
this.url = 'https://kns.cnki.net/KCMS/detail/detail.aspx?'
+ `dbcode=${this.dbcode}`
+ `&dbname=${this.dbname}`
+ `&filename=${this.filename}`
+ `&v=`;
}
/* ID initialization method suitable for ordinary CNKI */
commonId(doc, url) {
let 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);
}
// geology version, space version
if (url.includes('inds.cnki.net')) {
this.dbcode = this.dbname.slice(6, 10);
this.dbname = this.dbname.slice(6);
}
else {
this.dbcode = this.dbcode || this.dbname.substring(0, 4).toUpperCase();
}
this.url = url;
}
toBoolean() {
return Boolean(this.dbname && this.filename);
}
toItemtype() {
let typeMap = {
// 学术辑刊 zh
CCJD: 'journalArticle',
// 学术期刊 journal zh
CJFQ: 'journalArticle',
// 学术期刊 journal en
WWJD: 'journalArticle',
// 特色期刊 journal
CJFN: 'journalArticle',
/* 余下journal未在页面找到,可能已经过时 */
CDMD: 'journalArticle',
CJFD: 'journalArticle',
CAPJ: 'journalArticle',
CJZK: 'journalArticle',
SJES: 'journalArticle',
SJPD: 'journalArticle',
SSJD: 'journalArticle',
// 博士 dissertation zh
CDFD: 'thesis',
// 硕士 dissertation zh
CMFD: 'thesis',
// 报纸 newspaper zh
CCND: 'newspaperArticle',
// 中国专利 patent zh
SCPD: 'patent',
// 境外专利 patent en
SOPD: 'patent',
SCOD: 'patent',
// 年鉴 almanac zh,无对应条目类型,以期刊记录
CYFD: 'journalArticle',
// 国内会议 conference zh
CPFD: 'conferencePaper',
// (国外)会议 en
WWPD: 'conferencePaper',
// 会议视频 video zh
CPVD: 'conferencePaper',
// 国际会议 conference en zh
CIPD: 'conferencePaper',
IPFD: 'conferencePaper',
// 视频 video zh
// CCVD
/* 实际上无法匹配到图书的dbcode */
// 中文图书 book zh
WBFD: 'book',
// 外文图书 book en
WWBD: 'book',
// 国家标准 standard zh
SCSF: 'standard',
// 行业标准 standard zh
SCHF: 'standard',
// 标准题录 standard zh
SCSD: 'standard',
// 标准题录 standard en
SOSD: 'standard',
// 成果 achievements
// SNAD
/* hospital */
// https://chkdx.cnki.net/kns8/#/
CLKM: 'thesis',
CHKJ: 'journalArticle',
PUBMED: 'journalArticle',
CDMH: 'thesis',
CHKP: 'conferencePaper',
CHKN: 'newspaperArticle'
};
return 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 ['WWJD', 'IPFD', 'WWPD', 'WWBD', 'SOSD'].includes(this.dbcode)
? 'en-US'
: 'zh-CN';
}
}
function detectWeb(doc, url) {
Z.debug("---------------- CNKI 2024-01-07 18:50:37 ------------------");
let ids = url.includes('www.cnki.com.cn')
// CNKI space
? new ID(url)
: 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/
https://inds.cnki.net/kns/search/index?dbCode=DKCTZK&kw=5g&korder=1
*/
/kns8?s?\/search\??/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,
/*
article/yearbook list in journal navigation page or CNKI thingker search page
https://navi.cnki.net/knavi/journals/ZGSK/detail?uniplatform=NZKPT
*/
/\/KNavi\//i,
/* https://kns.cnki.net/kns8s/defaultresult/index?korder=&kw= */
/kns8?s?\/defaultresult\/index/i,
/*
search page in CNKI space
https://search.cnki.com.cn/Search/Result?theme=%u6C34%u7A3B
*/
/search\.cnki\.com/i,
// seems outdated
/kns\/brief\/(default_)?result\.aspx/i,
// https://chkdx.cnki.net/kns8/#/
/kns8\/#\//i
];
// #ModuleSearchResult for commom CNKI,
// #contentPanel for journal/yearbook navigation,
// .main_sh for oldversion,
// .resault-cont for CNKI space
// #content for geology version
// .main.clearfix for hospital version
let searchResult = doc.querySelector('#ModuleSearchResult, #contentPanel, .main_sh, .resault-cont, #content, .main.clearfix');
if (searchResult) {
Z.monitorDOMChanges(searchResult, { childList: true, subtree: true });
}
if (ids.toBoolean()) {
return ids.toItemtype();
}
// e.g. https://thinker.cnki.net/bookstore/book/bookdetail?bookcode=9787111520269000&type=book
else if (url.includes('book/bookdetail')) {
// 知网心可图书馆,CNKI thingker
return 'book';
}
// e.g https://thinker.cnki.net/BookStore/chapter/chapterdetail?bookcode=9787111520269000_174&type=chapter#div6
else if (url.includes('chapter/chapterdetail')) {
// 知网心可图书馆,CNKI thingker
return 'bookSection';
}
else if (multiplePattern.some(element => element.test(url)) && getSearchResults(doc, url, true)) {
return 'multiple';
}
else {
return false;
}
}
function getSearchResults(doc, url, checkOnly) {
var items = {};
var found = false;
var searchTypes = [
/* journal navigation */
// https://navi.cnki.net/knavi/journals/ZGSK/detail?uniplatform=NZKPT
{
pattern: /\/journals\/.+\/detail/i,
rowSlector: '#rightCatalog dd',
aSlector: '.name > a'
},
/* thesis navigation */
// https://navi.cnki.net/knavi/degreeunits/GBEJU/detail?uniplatform=NZKPT
{
pattern: /\/degreeunits\/.+\/detail/i,
rowSlector: '#rightCatalog tbody > tr',
aSlector: '.name > a'
},
/* conference navigation */
// https://navi.cnki.net/knavi/conferences/030681/proceedings/IKJS202311001/detail?uniplatform=NZKPT
{
pattern: /\/proceedings\/.+\/detail/i,
rowSlector: '#rightCatalog tbody > tr',
aSlector: '.name > a'
},
/* newspaper navigation */
// https://navi.cnki.net/knavi/newspapers/RMRB/detail?uniplatform=NZKPT
{
pattern: /\/newspapers\/.+\/detail/i,
rowSlector: '#rightCatalog tbody > tr',
aSlector: '.name > a'
},
/* yearbook navigation */
{
pattern: /\/yearbooks\/.+\/detail/i,
rowSlector: '#rightCatalog .itemNav',
aSlector: 'a'
},
/* CNKISpace */
{
pattern: /search\.cnki\.com/i,
rowSlector: '#contentPanel .itemNav',
aSlector: 'p > a'
},
/* geology */
// https://dizhi.cnki.net/
{
pattern: /\/search\/index?/i,
rowSlector: '.s-single',
aSlector: 'h1 > a'
},
/* hospital */
// https://chkdx.cnki.net/kns8/#/
{
pattern: /chkdx\.cnki\.net/,
rowSlector: 'table.list_table tbody tr',
aSlector: 'td.seq+td > a'
},
/* commom */
{
pattern: /.*/i,
rowSlector: 'table.result-table-list tbody tr',
aSlector: 'td.name > a'
}
];
var type = searchTypes.find(element => element.pattern.test(url));
var rows = doc.querySelectorAll(type.rowSlector);
if (!rows.length) return false;
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
let header = row.querySelector(type.aSlector);
if (!header) continue;
let href = header.href;
let title = header.getAttribute('title') || ZU.trimInternal(header.textContent);
// Z.debug(`${href}\n${title}`);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
// Use the key to transmit some useful information.
items[JSON.stringify({
url: href,
/*
reference count
"td[align="center"]:nth-child(6):not([title])" for navigation page
https://navi.cnki.net/knavi/conferences/030681/proceedings/IKJS202311001/detail?uniplatform=NZKPT
*/
cite: text(row, 'td.quote, td[align="center"]:nth-child(6):not([title])'),
// Another identifier for requesting data from the API.
// In Chinese Mainland, it is usually dynamic,
// while overseas is composed of fixed ids.filename.
cookieName: attr(row, '[name="CookieName"]', 'value'),
downloadlink: attr(row, 'td.operat > a.downloadlink', 'href')
})] = `【${i + 1}】${title}`;
// Z.debug(items);
}
return found ? items : false;
}
async function doWeb(doc, url) {
// Because CNKI has different APIs inside and outside Chinese Mainland, it needs to be differentiated.
const inMainland = Boolean(!/oversea/i.test(url));
Z.debug(`inMainland: ${inMainland}`);
let ids = new ID(doc, url);
/*
For multiple items, prioritize trying to crawl them one by one, as documents always provide additional information;
If it is not possible to obtain the document, consider using bulk export API.
*/
if (detectWeb(doc, url) == "multiple") {
let items = await Z.selectItems(getSearchResults(doc, url, false));
if (!items) return;
for (let key in items) {
let itemKey = JSON.parse(key);
try {
// During debugging, may manually throw errors to guide the program to run inward
// throw ReferenceError;
let doc = await requestDocument(itemKey.url);
// CAPTCHA
if (doc.querySelector('#verify_pic')) {
Z.debug('Accessing single item page failed!');
throw new TypeError('❌打开页面过程中遇到验证码❌');
}
await scrape(doc, itemKey.url, itemKey, inMainland);
}
catch (erro1) {
Z.debug('Attempt to use bulk export API');
try {
if (Object.keys(items).some(element => JSON.parse(element).cookieName)) {
throw new TypeError('This page is not suitable for using bulk export API');
}
var itemKeys = Object.keys(items)
.map(element => JSON.parse(element))
.filter(element => element.cookieName);
await scrapeWithShowExport(itemKeys, inMainland);
// Bulk export API can request all data at once.
break;
}
/*
Some older versions of CNKI and industry customized versions may not support retrieving CookieName from search pages.
In these cases, CAPTCHA issue should be handled by the user.
*/
catch (erro2) {
let 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;
}
}
}
}
// CHKI thingker
else if (url.includes('thinker.cnki')) {
await scrapeZhBook(doc, url);
}
// scholar
else if (ids.dbcode == 'WWBD') {
await scrapeDoc(
doc,
ids,
{ url: '', cite: '', cookieName: '', downloadlink: '' }
);
}
else {
await scrape(
doc,
// The itemKey can only be obtained from the search page,
// and it is set to empty here to meet compatibility requirements.
url,
{ url: '', cite: '', cookieName: '', downloadlink: '' },
inMainland
);
}
}
async function scrape(doc, url = doc.location.href, itemKey, inMainland) {
const isSpace = /cnki\.com\.cn/.test(url);
let ids = isSpace ? new ID(url) : new ID(doc, url);
Z.debug('scrape single item with ids:');
Z.debug(ids);
try {
await scrapeWithGetExport(doc, ids, itemKey, inMainland);
}
catch (error) {
// Value return from API is invalid, scrape metadata from webpage.
if (!isSpace) await scrapeDoc(doc, ids, itemKey);
}
}
/* API from "cite" button */
async function scrapeWithGetExport(doc, ids, itemKey, inMainland) {
Z.debug('use API GetExport');
// To avoid triggering anti crawlers due to frequent requests,
// uncomment the expression below during debugging to test functionality unrelated to requests.
/*
referText = {
code: 1,
msg: "返回成功",
data: [
{
key: "GB/T 7714-2015 格式引文",
value: [
"[1]张福锁,王激清,张卫峰等.中国主要粮食作物肥料利用率现状与提高途径[J].土壤学报,2008(05):915-924."
]
},
{
key: "知网研学(原E-Study)",
value: [
"DataType: 1<br>Title-题名: 中国主要粮食作物肥料利用率现状与提高途径<br>Author-作者: 张福锁;王激清;张卫峰;崔振岭;马文奇;陈新平;江荣风;<br>Source-刊名: 土壤学报<br>Year-年: 2008<br>PubTime-出版时间: 2008-09-15<br>Keyword-关键词: 肥料农学效率;氮肥利用率;影响因素;提高途径<br>Summary-摘要: 总结了近年来在全国粮食主产区进行的1 333个田间试验结果,分析了目前条件下中国主要粮食作物水稻、小麦和玉米氮磷钾肥的偏生产力、农学效率、肥料利用率和生理利用率等,发现水稻、小麦和玉米的氮肥农学效率分别为10.4 kg kg-1、8.0 kg kg-1和9.8 kg kg-1,氮肥利用率分别为28.3%、28.2%和26.1%,远低于国际水平,与20世纪80年代相比呈下降趋势。造成肥料利用率低的主要原因包括高产农田过量施肥,忽视土壤和环境养分的利用,作物产量潜力未得到充分发挥以及养分损失未能得到有效阻控等。要大幅度提高肥料利用率就必须从植物营养学、土壤学、农学等多学科联合攻关入手,充分利用来自土壤和环境的养分资源,实现根层养分供应与高产作物需求在数量上匹配、时间上同步、空间上一致,同时提高作物产量和养分利用效率,协调作物高产与环境保护。<br>Period-期: 05<br>PageCount-页数: 10<br>Page-页码: 915-924<br>SrcDatabase-来源库: 期刊<br>Organ-机构: 农业部植物营养与养分循环重点实验室教育部植物-土壤相互作用重点实验室中国农业大学资源与环境学院;河北农业大学资源与环境学院;<br>Link-链接: https://kns.cnki.net/kcms2/article/abstract?v=2Wn7gbiy3W_uaYxWWHbfX6Eo_zqFxhUVFviONVwAOwGJb2qk1H2f2iCbMlOvOoP0DDONsYAP4T3EvRsDbBj1xyCMf7DOnq6aiLuQE42fefZ_sYdhZ4stRfXyaoK7TPbe&uniplatform=NZKPT&language=CHS<br>"
]
},
{
key: "EndNote",
value: [
"%0 Journal Article<br>%A 张福锁%A 王激清%A 张卫峰%A 崔振岭%A 马文奇%A 陈新平%A 江荣风<br>%+ 农业部植物营养与养分循环重点实验室教育部植物-土壤相互作用重点实验室中国农业大学资源与环境学院;河北农业大学资源与环境学院;<br>%T 中国主要粮食作物肥料利用率现状与提高途径<br>%J 土壤学报<br>%D 2008<br>%N 05<br>%K 肥料农学效率;氮肥利用率;影响因素;提高途径<br>%X 总结了近年来在全国粮食主产区进行的1 333个田间试验结果,分析了目前条件下中国主要粮食作物水稻、小麦和玉米氮磷钾肥的偏生产力、农学效率、肥料利用率和生理利用率等,发现水稻、小麦和玉米的氮肥农学效率分别为10.4 kg kg-1、8.0 kg kg-1和9.8 kg kg-1,氮肥利用率分别为28.3%、28.2%和26.1%,远低于国际水平,与20世纪80年代相比呈下降趋势。造成肥料利用率低的主要原因包括高产农田过量施肥,忽视土壤和环境养分的利用,作物产量潜力未得到充分发挥以及养分损失未能得到有效阻控等。要大幅度提高肥料利用率就必须从植物营养学、土壤学、农学等多学科联合攻关入手,充分利用来自土壤和环境的养分资源,实现根层养分供应与高产作物需求在数量上匹配、时间上同步、空间上一致,同时提高作物产量和养分利用效率,协调作物高产与环境保护。<br>%P 915-924<br>%@ 0564-3929<br>%L 32-1119/P<br>%W CNKI<br>"
]
}
],
traceid: "a7af1c2425ec49b5973f756b194256c6.191.17014617381526837"
};
*/
// During debugging, may manually throw errors to guide the program to run inward
// throw ReferenceError;
// e.g. https://ras.cdutcm.lib4s.com:7080/s/net/cnki/kns/G.https/dm/API/GetExport?uniplatform=NZKPT
let postUrl = inMainland
? `${/https?.*https?/.test(ids.url) ? tryMatch(ids.url, /https?.*https?/) : 'https://kns.cnki.net'}/dm/API/GetExport?uniplatform=NZKPT`
: ids.url.includes('//chn.')
// https://chn.oversea.cnki.net is an oversea CNKI site with Chinese language.
? 'https://chn.oversea.cnki.net/kns8/manage/APIGetExport'
: 'https://oversea.cnki.net/kns8/manage/APIGetExport';
let postData = `filename=${ids.dbname}!${ids.filename}!1!0`
// Although there are two data formats that are redundant,
// this can make the request more "ordinary" to the server.
+ `${inMainland ? '&uniplatform=NZKPT' : ''}`
+ '&displaymode=GBTREFER%2Celearning%2CEndNote';
Z.debug(postUrl);
Z.debug(postData);
if (!postUrl || !postData) throw new ReferenceError('未找到可用接口');
let referText = await requestJSON(
postUrl,
{
method: 'POST',
body: postData,
headers: {
// The server uses the refer parameter to verify whether the request it receives comes from its own client web page.
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');
}
referText = referText.data[2].value[0];
await parseRefer(referText, doc, ids, itemKey);
}
/* API from "Check - Export citations" */
async function scrapeWithShowExport(itemKeys, inMainland) {
var fileNames = itemKeys.map(element => element.cookieName);
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 errors to guide the program to run inward
// throw ReferenceError;
let postData = `FileName=${fileNames.join(',')}`
+ '&DisplayMode=EndNote'
+ '&OrderParam=0'
+ '&OrderType=desc'
+ '&SelectField='
+ `${inMainland ? '&PageIndex=1&PageSize=20&language=CHS&uniplatform=NZKPT' : ''}`
+ `&random=${Math.random()}`;
let postUrl = inMainland
? 'https://kns.cnki.net/dm8/api/ShowExport'
: [
'http://www.cnki.net/kns/manage/ShowExport',
'https://chn.oversea.cnki.net/kns/manage/ShowExport',
'https://oversea.cnki.net/kns/manage/ShowExport',
].find(element => element.includes(tryMatch(itemKeys[0].url, /\/\/.*?\//)));
let refer = inMainland
? 'https://kns.cnki.net/dm8/manage/export.html?'
: [
'http://www.cnki.net/kns/manage/export.html?displaymode=EndNote',
'https://chn.oversea.cnki.net/kns/manage/export.html?displaymode=EndNote',
].find(element => element.includes(tryMatch(itemKeys[0].url, /\/\/.*?\//)));
if (!postUrl || !postData) throw new ReferenceError('没有适合的接口可用');
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, '');
Z.debug(text);
await parseRefer(
text,
document.createElement('div'),
// This function is designed to be used when the item documents are unavailable,
// so passing an empty Element to meet compatibility requirements.
{
dbname: '',
filename: '',
dbcode: '',
url: ''
},
itemKeys[i]);
}
}
async function parseRefer(referText, doc, ids, itemKey) {
Z.debug('parsing referText:');
Z.debug(referText);
// Item without title is invalid.
if (!/%T /.test(referText)) throw TypeError;
Z.debug('Get referText from API successfuly!');
referText = referText
// breakline
.replace(/<br>\s*|\r/g, '\n')
// Sometimes, authors, contributors, or keywords may be mistakenly placed in the same tag.
.replace(/^%([KAYI]) .*/gm, function (match) {
let tag = match[1];
return match.replace(/[,;,;]\s?/g, `\n%${tag} `);
})
// Sometimes, authors, contributors, or keywords have their tags, but do not wrap before the tags.
.replace(/(%[KAYI]) /gm, '\n$1 ')
.replace(/^%R /m, '%U ')
// Custom tag "9" corresponds to the degree of the graduation thesis,
//and tag "~" corresponds standard type (national standard or industry standard).
.replace(/^%[9~] /m, '%R ')
.replace(/^%V 0*/m, '%V ')
.replace(/^%N 0*/m, '%N ')
// \t in abstract
.replace(/\t/g, '')
.replace(/(\n\s*)+/g, '\n');
Z.debug(referText);
var translator = Zotero.loadTranslator("import");
// Refer/BibIX
translator.setTranslator('881f60f2-0802-411a-9228-ce5f47b64c7d');
translator.setString(referText);
translator.setHandler('itemDone', (_obj, newItem) => {
// Record the yearbook as a journal article.
if (newItem.type == '年鉴') {
newItem.itemType = 'journalArticle';
}
switch (newItem.itemType) {
case 'journalArticle':
delete newItem.callNumber;
newItem.ISSN = tryMatch(referText, /^%@ (.*)/m, 1);
break;
case 'statute':
newItem.itemType = 'standard';
newItem.number = newItem.volume;
delete newItem.volume;
delete newItem.publisher;
break;
case 'thesis':
newItem.university = newItem.publisher;
delete newItem.publisher;
if (newItem.type) {
newItem.thesisType = `${newItem.type}学位论文`;
delete newItem.type;
}
newItem.creators.forEach((element) => {
if (element.creatorType == 'translator') {
element.creatorType = 'contributor';
}
});
break;
case 'newspaperArticle':
delete newItem.callNumber;
newItem.ISSN = tryMatch(referText, /^%@ (.*)/m, 1);
break;
case 'conferencePaper':
newItem.conferenceName = newItem.publicationTitle;
delete newItem.publicationTitle;
break;
case 'patent':
newItem.issueDate = newItem.date;
delete newItem.date;
newItem.extra += addExtra('Genre', newItem.type);
delete newItem.type;
break;
default:
break;
}
delete newItem.archiveLocation;
newItem = Object.assign(newItem, fixItem(newItem, doc, ids, itemKey));
Z.debug(newItem);
newItem.complete();
});
await translator.translate();
}
/* TODO: Compatible with English labels in English version of CNKI. */
async function scrapeDoc(doc, ids, itemKey) {
Z.debug('scraping from document...');
var newItem = new Zotero.Item(ids.toItemtype());
newItem.extra = newItem.extra ? newItem.extra : '';
// "#content p, .summary li.pdfN" only found on geology version
// in normal page, ".row", ".row_1"
let labels = new LabelsX(doc, 'div.doc div[class^="row"], li.top-space, #content .summary > p, .summary li.pdfN, [class^="content"] p');
/* title */
newItem.title = pureText(doc.querySelector('div.doc h1, .h1-scholar, #chTitle'));
if (newItem.title.includes('\n')) {
newItem.extra += addExtra('original-title', newItem.title.split('\n')[1]);
newItem.title = newItem.title.split('\n')[0];
}
newItem.title = newItem.title.replace(/MT翻译$/, '');
/* creators */
var creators = [
// Do not use comma separated selector, as there may be duplicate code that is difficult to filter
Array.from(doc.querySelectorAll('#authorpart a'))
.map(element => element.textContent.trim().replace(/[\d,;,;]/g, '')),
Array.from(doc.querySelectorAll('#authorpart span'))
// Clear footnote labels ([\d,,]*), email ((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*), saperator ([;;]*) for author names
.map(element => element.textContent.trim().replace(/[\d,,]*(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*[;;]*$/g, '')),
// For oversea CNKI.
text(doc, '.brief h3').split(/[,.,;\d]\s*/).filter(element => element),
labels.getWith(['主编单位', '作者']).split(/[,;,;]\s*/),
].find(element => element.length);
newItem.creators = creators.map(element => ZU.cleanAuthor(element, 'author'));
let mentor = labels.getWith('导师').split(/[,;,;\d]\s*/);
if (mentor.length) {
mentor.forEach(element => newItem.creators.push(ZU.cleanAuthor(element, 'contributor')));
}
/* publication information */
let pubInfo = innerText(doc, 'div.top-tip')
+ pureText(doc.querySelector('.summary .detailLink'))
+ labels.getWith(['作者基本信息', '出版信息']);
Z.debug(`puinfo:${pubInfo}`);
newItem.publicationTitle = tryMatch(pubInfo, /(.*?)[.,]/, 1)
|| labels.getWith('报纸网站')
|| '';
newItem.date = tryMatch(pubInfo, /(\d+),/, 1)
|| tryMatch(pubInfo, /(\d{4})年?/, 1)
|| labels.getWith(['发布日期', '发布单位', '报纸日期']);
newItem.volume = tryMatch(pubInfo, /(\d*)\s*\(/, 1) || tryMatch(pubInfo, /0?(\d+)卷/, 1);
newItem.issue = tryMatch(pubInfo, /\(0?(\d+)\)/, 1) || tryMatch(pubInfo, /0?(\d+)期/, 1);
newItem.university = tryMatch(pubInfo, /.*?(大学|university|school)/i);
newItem.thesisType = {
CMFD: '硕士学位论文',
CDFD: '博士学位论文',
CDMH: '硕士学位论文'
}[ids.dbcode] || (tryMatch(pubInfo, /(硕士|博士)/) ? `${tryMatch(pubInfo, /(硕士|博士)/)}学位论文` : '');
newItem.ISBN = labels.getWith('ISBN');
/* else fields */
newItem.pages = tryMatch(text(doc, 'div.doc p.total-inform span:nth-child(2)'), /[\d+,~-]+/).replace('+', ',').replace('~', '-')
|| labels.getWith(['Pages', '版号'])
|| '';
newItem.extra += addExtra('Genre', labels.getWith('专利类型'));
newItem = Object.assign(newItem, fixItem(newItem, doc, ids, itemKey));
Z.debug(newItem);
newItem.complete();
}
/* TODO: Compatible with English labels in English version of CNKI. */
function fixItem(newItem, doc, ids, itemKey) {
Z.debug('fixing item...');
// ".row", ".row_1" for normal version
// "#content p, .summary li.pdfN" for geology version
// "[class^="content"] p" for space version
let labels = new LabelsX(doc, 'div.doc div[class^="row"], li.top-space, #content .summary > p, .summary li.pdfN, [class^="content"] p');
Z.debug('get labels:');
Z.debug(labels.innerData.map(element => [element[0], ZU.trimInternal(element[1].textContent)]));
newItem.extra = newItem.extra ? newItem.extra : '';
switch (newItem.itemType) {
case 'journalArticle':
break;
case 'thesis':
break;
case 'patent':
// newItem.place = labels.getWith('地址');
newItem.place = labels.getWith('国省代码');
newItem.country = labels.getWith('国省代码');
newItem.patentNumber = labels.getWith('申请(专利)号');
newItem.filingDate = labels.getWith('申请日');
newItem.applicationNumber = labels.getWith('申请(专利)号');
newItem.issueDate = labels.getWith('授权公告日');
newItem.rights = text(doc, '.claim > h5 + div');
break;
case 'conferencePaper':
newItem.proceedingsTitle = labels.getWith('会议录名称');
newItem.conferenceName = labels.getWith('会议名称');
newItem.date = labels.getWith('会议时间');
newItem.place = labels.getWith('会议地点');
break;
case 'standard':
newItem.number = labels.getWith('标准号').replace('-', '—');
newItem.creators = [ZU.cleanAuthor(labels.getWith('标准技术委员会'), 'author')];
newItem.extra += addExtra('applyDate', labels.getWith('实施日期'));
newItem.status = text(doc, '.type');
break;
case 'newspaperArticle':
break;
default:
break;
}
/* Click to get a full abstract in a single article page */
let detailBtn = doc.querySelector('a[id*="ChDivSummaryMore"]');
if (detailBtn) detailBtn.click();
// 'div.abstract-text' is usually found on old versions of CNKI or oversea CNKI.
// "#abstract_text": scoolar
newItem.abstractNote = attr(doc, '#abstract_text', 'value')
|| text(doc, 'span#ChDivSummary, div.abstract-text')
|| labels.getWith('摘要')
|| newItem.abstractNote
|| '';
newItem.abstractNote = newItem.abstractNote
.replace(/\s*[\r\n]\s*/g, '\n')
.replace(/<.*?>/g, '')
.replace(/^<正>/, '');
newItem.extra += addExtra('CNKICite', itemKey.cite);
// Build a shorter url
let url = itemKey.url || ids.url || '';
newItem.url = /kcms2/i.test(url)
? 'https://kns.cnki.net/KCMS/detail/detail.aspx?'
+ `dbcode=${ids.dbcode}`
+ `&dbname=${ids.dbname}`
+ `&filename=${ids.filename}`
+ `&v=`
: url;
// CNKI DOI
if (!newItem.DOI) newItem.DOI = labels.getWith('DOI');
newItem.creators.forEach((element) => {
if (/[\u4e00-\u9fa5]/.test(element.lastName)) {
element.fieldMode = 1;
}
});
if (doc.querySelector('.icon-shoufa')) {
newItem.extra += 'status: advance online publication\n';
newItem.extra += addExtra('available-date', newItem.data);
// delete newItem.date;
newItem.date = tryMatch(innerText(doc, '.head-time, .head-tag'), /:([\d-]*)/, 1);
}
newItem.language = ids.toLanguage();
if (newItem.pages) {
newItem.pages = newItem.pages.replace(/0*([1-9]\d*)/g, '$1').replace(/[+]/g, ', ').replace(/~/g, '-');
}
/* tags */
// "#keyword_cn a": scholar
let tags = Array.from(doc.querySelectorAll('div.doc p.keywords a, #ChDivKeyWord > a, #keyword_cn a'))
.map(element => ZU.trimInternal(element.innerText).replace(/[,;,;]$/, ''));
// Keywords sometimes appear as a whole paragraph
if (!tags.length) {
tags = text(doc, 'div.doc p.keywords') || labels.getWith('Keywords');
tags = tags.split(/[,;,;n]\s*/g);
}
newItem.tags = tags.map(element => ({ tag: element }));
/* add PDF/CAJ attachment */
// If you want CAJ instead of PDF, set keepPDF = false
// 如果你想将PDF文件替换为CAJ文件,将下面一行 keepPDF 设为 false
var keepPDF = Z.getHiddenPref('CNKIPDF');
if (keepPDF === undefined) keepPDF = true;
if (ids.url.includes('KXReader/Detail')) {
newItem.attachments.push({
title: 'Snapshot',
document: doc
});
}
else {
getAttachments(doc, keepPDF, itemKey).forEach((attachment) => {
newItem.attachments.push(attachment);
});
}
return newItem;
}
/* A dedicated scrape scheme for Chinese books in CNKI thingker. */
async function scrapeZhBook(doc, url) {
var bookItem = new Z.Item(detectWeb(doc, url));
bookItem.title = text(doc, '#b-name, .art-title > h1');
bookItem.abstractNote = text(doc, '[name="contentDesc"], .desc-content').replace(/\n+/, '\n');
bookItem.creators = text(doc, '.xqy_b_mid li:nth-child(2), .art-title > .art-name')
.replace(/^责任者:/, '')
.replace(/\s+/, ' ')
.split(/\s/)
.map(element => ZU.cleanAuthor(element, 'author'));
bookItem.creators.forEach(element => element.fieldMode = 1);
// ".bc_a > li" for book, and ".desc-info > p" for chapter
let labels = new LabelsX(doc, '.bc_a > li, .desc-info > p');
Z.debug('get labels:');
Z.debug(labels.innerData.map(element => [element[0], ZU.trimInternal(element[1].textContent)]));
bookItem.edition = labels.getWith('版次');
bookItem.numpages = labels.getWith('页数');
bookItem.pages = labels.getWith('页码');
bookItem.publisher = text(doc, '.xqy_g') || labels.getWith('出版社');
bookItem.date = labels.getWith('出版时间')
.replace(/(\d{4})(0?\d{1,2})(\d{1,2})/, '$1-$2-$3')
.replace(/-$/, '');
bookItem.language = 'zh-CN';
bookItem.ISBN = labels.getWith('国际标准书号ISBN');
bookItem.libraryCatalog = labels.getWith('所属分类');
bookItem.extra = addExtra('CNKICite', text(doc, '.book_zb_yy span:last-child'));
bookItem.complete();
}
// add pdf or caj to attachments, default is pdf
function getAttachments(doc, keepPDF, itemKey) {
// attr() can't get full link
var attachments = [];
let pdfLink = strChild(doc, 'a[id^="pdfDown"]', 'href')
// industry ver
|| strChild(doc, 'a[href*="pdfdown"]', 'href')
|| strChild(doc, '.operate-btn a[href*="Download"]', 'href')
// CNKI space
|| strChild(doc, '.down_button#ty_pdf', 'href');
Z.debug(`get PDF Link:\n${pdfLink}`);
let cajLink = strChild(doc, 'a#cajDown', 'href')
// industry ver
|| strChild(doc, 'a[href*="cajdown"]', 'href')
|| itemKey.downloadlink
// CNKI space
|| strChild(doc, '.down_button#ty_caj', 'href');
Z.debug(`get CAJ link:\n${cajLink}`);
if (keepPDF && pdfLink) {
attachments.push({
title: 'Full Text PDF',
mimeType: 'application/pdf',
url: pdfLink
});
}
else if (cajLink) {
attachments.push({
title: 'Full Text CAJ',
mimeType: 'application/caj',
url: cajLink
});
}
else {
attachments = [];
}
return attachments;
}
/* Util */
class LabelsX {
constructor(doc, selector) {
this.innerData = [];
Array.from(doc.querySelectorAll(selector))
// avoid nesting
.filter(element => !element.querySelector(selector))
// avoid empty
.filter(element => !/^\s*$/.test(element.textContent))
.forEach((element) => {
let elementCopy = element.cloneNode(true);
// avoid empty text
while (!elementCopy.firstChild.textContent.replace(/\s/g, '')) {
// Z.debug(elementCopy.firstChild.textContent);
elementCopy.removeChild(elementCopy.firstChild);
// Z.debug(elementCopy.firstChild.textContent);
}
if (elementCopy.childNodes.length > 1) {
let key = elementCopy.removeChild(elementCopy.firstChild).textContent.replace(/\s/g, '');
this.innerData.push([key, elementCopy]);
}
else {
let text = ZU.trimInternal(elementCopy.textContent);
let key = tryMatch(text, /^[[【]?[\s\S]+?[】\]::]/).replace(/\s/g, '');
elementCopy.textContent = tryMatch(text, /^[[【]?[\s\S]+?[】\]::]\s*(.+)/, 1);
this.innerData.push([key, elementCopy]);
}
});
}
getWith(label, element = false) {
if (Array.isArray(label)) {
let result = label
.map(aLabel => this.getWith(aLabel, element))
.filter(element => element);
result = element
? result.find(element => element.childNodes.length)
: result.find(element => element);
return result
? result
: element
? document.createElement('div')
: '';
}
let pattern = new RegExp(label);
let keyValPair = this.innerData.find(element => pattern.test(element[0]));
if (element) return keyValPair ? keyValPair[1] : document.createElement('div');
return keyValPair
? ZU.trimInternal(keyValPair[1].textContent)
: '';
}
}
function tryMatch(string, pattern, index = 0) {