-
Notifications
You must be signed in to change notification settings - Fork 524
/
chaoxingqikan.js
360 lines (344 loc) · 11.1 KB
/
chaoxingqikan.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
{
"translatorID": "f7c9342d-3672-4899-b315-3d09ac1b38a8",
"label": "chaoxingqikan",
"creator": "jiaojiaodubai23",
"target": "^https?://qikan\\.chaoxing\\.com",
"minVersion": "5.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-12-14 17:18:27"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2022 YOUR_NAME <- TODO
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 *****
*/
function detectWeb(doc, url) {
if (url.includes('/detail_')) {
return 'journalArticle';
}
else if (getSearchResults(doc, true)) {
return 'multiple';
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('#zhaiyaoDivId > div > dl > dt > a');
for (let row of rows) {
let href = row.href;
let title = ZU.trimInternal(row.title);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
async function doWeb(doc, url) {
if (detectWeb(doc, url) == 'multiple') {
let items = await Zotero.selectItems(getSearchResults(doc, false));
if (!items) return;
for (let url of Object.keys(items)) {
await scrape(await requestDocument(url));
}
}
else {
await scrape(doc, url);
}
}
async function scrape(doc, url = doc.location.href) {
var newItem = new Z.Item('journalArticle');
newItem.extra = '';
newItem.title = attr(doc, '#articleTitle', 'value');
newItem.abstractNote = text(doc, '#generateCatalog_0');
newItem.publicationTitle = text(doc, 'a.jourName').replace(/^《|》$/g, '');
let labels = new Labels(doc, '[class^="Fmian"] tr, #generateCatalog_1, #other > p');
Z.debug(labels.data.map(arr => [arr[0], arr[1].innerText]));
let pubInfo = labels.get('来源');
Z.debug(pubInfo);
newItem.volume = tryMatch(attr(doc, '#GBTInputId', 'value'), /第(\d+)卷/, 1);
newItem.issue = tryMatch(pubInfo, /(\d+)期/, 1);
newItem.pages = tryMatch(pubInfo, /([\d-,+]*)$/, 1);
newItem.date = tryMatch(pubInfo, /(\d+)年/, 1);
newItem.DOI = labels.get('DOI');
newItem.url = url;
let creators = text(doc, 'p.F_name').split(/[\d,;,;]\s*/);
creators.forEach((creator) => {
newItem.creators.push(ZU.cleanAuthor(creator, 'author'));
});
newItem.creators.forEach((element) => {
if (/[\u4e00-\u9fa5]/.test(element.lastName)) {
element.fieldMode = 1;
}
});
let tags = labels.get('关键词').split(/[,;,;]/);
tags.forEach((tag) => {
newItem.tags.push(tag);
});
newItem.extra = addExtra('titleTranslation', text(doc, '.title_translate'));
try {
let journalDoc = await requestDocument(doc.querySelector('div[class^="sTopImg"] > p:first-of-type > a').href);
let labels = new Labels(journalDoc, '.FbPcon > p, .FbPcon > div > div');
newItem.language = {
中文: 'zh-CN',
英文: 'en-US'
}[labels.get('语言')];
newItem.ISSN = labels.get('ISSN');
}
catch (error) {
Z.debug('some error occured while geting journalDoc');
}
let pdfLink = doc.querySelector('a[class*="pdf-down"]');
Z.debug(pdfLink);
if (pdfLink) {
newItem.attachments.push({
url: pdfLink.href,
title: 'Full Text PDF',
mimeType: 'application/pdf'
});
}
newItem.attachments.push({
title: 'Snapshot',
document: doc
});
newItem.complete();
}
/* Util */
class Labels {
constructor(doc, selector) {
this.data = [];
this.emptyElm = doc.createElement('div');
Array.from(doc.querySelectorAll(selector))
// avoid nesting
.filter(element => !element.querySelector(selector))
// avoid empty
.filter(element => !/^\s*$/.test(element.textContent))
.forEach((element) => {
const elmCopy = element.cloneNode(true);
// avoid empty text
while (/^\s*$/.test(elmCopy.firstChild.textContent)) {
// Z.debug(elementCopy.firstChild.textContent);
elmCopy.removeChild(elmCopy.firstChild);
// Z.debug(elementCopy.firstChild.textContent);
}
if (elmCopy.childNodes.length > 1) {
const key = elmCopy.removeChild(elmCopy.firstChild).textContent.replace(/\s/g, '');
this.data.push([key, elmCopy]);
}
else {
const text = ZU.trimInternal(elmCopy.textContent);
const key = tryMatch(text, /^[[【]?.+?[】\]::]/).replace(/\s/g, '');
elmCopy.textContent = tryMatch(text, /^[[【]?.+?[】\]::]\s*(.+)/, 1);
this.data.push([key, elmCopy]);
}
});
}
get(label, element = false) {
if (Array.isArray(label)) {
const results = label
.map(aLabel => this.get(aLabel, element));
const keyVal = element
? results.find(element => !/^\s*$/.test(element.textContent))
: results.find(string => string);
return keyVal
? keyVal
: element
? this.emptyElm
: '';
}
const pattern = new RegExp(label, 'i');
const keyVal = this.data.find(arr => pattern.test(arr[0]));
return keyVal
? element
? keyVal[1]
: ZU.trimInternal(keyVal[1].textContent)
: element
? this.emptyElm
: '';
}
}
function tryMatch(string, pattern, index = 0) {
if (!string) return '';
let match = string.match(pattern);
return (match && match[index])
? match[index]
: '';
}
function addExtra(key, value) {
return value
? `${key}: ${value}\n`
: '';
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://qikan.chaoxing.com/searchjour?sw=%E9%87%8F%E5%AD%90%E5%8A%9B%E5%AD%A6&size=50&x=0_646",
"items": "multiple"
},
{
"type": "web",
"url": "https://qikan.chaoxing.com/detail_38502727e7500f263a85bd7ab02fcce7f45d0936666427011921b0a3ea255101fc1cf1fbb4666ae6b3d8bb7c40980615f75d1dedbca8bf1556c8add879a320654132304f5496fb7010bc92a6ec065159",
"items": [
{
"itemType": "journalArticle",
"title": "410 t/h燃煤电站高温除尘技术试验研究",
"creators": [
{
"firstName": "",
"lastName": "司桐",
"creatorType": "author",
"fieldMode": 1
},
{
"firstName": "",
"lastName": "王春波",
"creatorType": "author",
"fieldMode": 1
},
{
"firstName": "",
"lastName": "陈亮",
"creatorType": "author",
"fieldMode": 1
},
{
"firstName": "",
"lastName": "任育杰",
"creatorType": "author",
"fieldMode": 1
},
{
"firstName": "",
"lastName": "任福春",
"creatorType": "author",
"fieldMode": 1
}
],
"date": "2023",
"DOI": "10.19805/j.cnki.jcspe.2023.07.003",
"ISSN": "1674-7607",
"abstractNote": "摘 要:针对燃煤电站SCR脱硝技术中高浓度飞灰造成的催化剂使用寿命缩短、大量氨逃逸及空气预热器堵灰的问题,将高温除尘器布置在SCR反应器之前。在410 t/h燃煤锅炉上对高温除尘技术进行了工程示范研究,分析了高温除尘器的除尘特性对下游脱硝单元和空气预热器性能的影响。结果表明:在70%和90%锅炉负荷下,高温除尘器出口烟尘平均质量浓度均小于8 mg/m3;90%负荷下,烟气流经高温除尘器的压降仅为500 Pa左右,大幅低于传统布袋除尘器的烟气压降;与典型的超低排放烟气后处理技术相比,应用高温除尘器能实现在相同脱硝效率下显著降低SCR反应器的烟气压降,并能减少相应的气氨消耗量与氨逃逸量;与常规布置布袋除尘器的锅炉环保岛相比,高温除尘器+SCR脱硝单元+空气预热器的模块的烟气压降可降低约500 Pa。",
"extra": "titleTranslation: Experimental Research of High Temperature Dust Removal Technology in a 410 t/h Coal-fired Power Station",
"issue": "7",
"language": "zh-CN",
"libraryCatalog": "chaoxingqikan",
"pages": "829-834",
"publicationTitle": "动力工程学报",
"url": "https://qikan.chaoxing.com/detail_38502727e7500f263a85bd7ab02fcce7f45d0936666427011921b0a3ea255101fc1cf1fbb4666ae6b3d8bb7c40980615f75d1dedbca8bf1556c8add879a320654132304f5496fb7010bc92a6ec065159",
"volume": "43",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
},
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [
{
"tag": " 压降"
},
{
"tag": " 烟尘"
},
{
"tag": " 能耗"
},
{
"tag": " 高温除尘"
},
{
"tag": "空气预热器"
}
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://qikan.chaoxing.com/detail_38502727e7500f26ca0861a3adbe5e606a145e816f7b417b1921b0a3ea255101fc1cf1fbb4666ae63e6eb506682179a64e4da1f03d3b11a394230ac99639719849c21da7b26113148a360c694190388d",
"items": [
{
"itemType": "journalArticle",
"title": "重庆市小水电退出机制研究",
"creators": [
{
"firstName": "",
"lastName": "肖妮",
"creatorType": "author",
"fieldMode": 1
},
{
"firstName": "",
"lastName": "金华频",
"creatorType": "author",
"fieldMode": 1
}
],
"date": "2023",
"DOI": "10.16232/j.cnki.1001-4179.2023.04.005",
"ISSN": "1001-4179",
"abstractNote": "摘要:为引导重庆市部分老旧或有用水纠纷的小水电有序退出,缓解水资源利用矛盾,开展了小水电退出机制研究。在总结国内外小水电退出现状的基础上,基于重庆市老旧小水电调研成果,结合该市实际情况,提出了小水电退出衡量指标、退出方式、奖补标准(市场法、收益法、重置成本法、推荐测算法)、退出程序等。分析认为小水电退出工作应做好科学论证、综合评估,社会风险防控,宣传指导,后评估等4个方面工作,从而确保退出工作平稳有序推进。研究成果可为重庆市小水电退出政策制定提供参考。",
"extra": "titleTranslation: Withdrawal mechanism of small hydropower in Chongqing City",
"issue": "4",
"language": "zh-CN",
"libraryCatalog": "chaoxingqikan",
"pages": "30-35",
"publicationTitle": "人民长江",
"url": "https://qikan.chaoxing.com/detail_38502727e7500f26ca0861a3adbe5e606a145e816f7b417b1921b0a3ea255101fc1cf1fbb4666ae63e6eb506682179a64e4da1f03d3b11a394230ac99639719849c21da7b26113148a360c694190388d",
"volume": "54",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
},
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [
{
"tag": " 奖补标准"
},
{
"tag": " 报废退出"
},
{
"tag": " 退出机制"
},
{
"tag": " 重庆市"
},
{
"tag": "小水电"
}
],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/