/
news.ts
484 lines (474 loc) · 16.7 KB
/
news.ts
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
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import iconv from 'iconv-lite';
import { parseDate } from '@/utils/parse-date';
// import logger from '@/utils/logger';
export const route: Route = {
path: '/yjsy/news/:type',
categories: ['university'],
example: '/ustb/yjsy/news/all',
parameters: { type: '文章类别' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['gs.ustb.edu.cn/:type'],
},
],
name: '研究生院',
maintainers: ['DA1Y1'],
handler,
description: `| 北京科技大学研究生院 | 土木与资源工程学院 | 能源与环境工程学院 | 冶金与生态工程学院 | 材料科学与工程学院 | 机械工程学院 | 自动化学院 | 计算机与通信工程学院 | 数理学院 | 化学与生物工程学院 | 经济管理学院 | 文法学院 | 马克思主义学院 | 外国语学院 | 国家材料服役安全科学中心 | 新金属材料国家重点实验室 | 工程技术研究院 | 钢铁共性技术协同创新中心 | 钢铁冶金新技术国家重点实验室 | 新材料技术研究院 | 科技史与文化遗产研究院 | 顺德研究生院 |
| -------------------- | ------------------ | ------------------ | ------------------ | ------------------ | ------------ | ---------- | -------------------- | -------- | ------------------ | ------------ | -------- | -------------- | ---------- | ------------------------ | ------------------------ | -------------- | ------------------------ | ---------------------------- | ---------------- | ---------------------- | ------------ |
| all | cres | seee | metall | mse | me | saee | scce | shuli | huasheng | sem | wenfa | marx | sfs | ncms | skl | iet | cicst | slam | adma | ihmm | sd |`,
};
async function handler(ctx) {
const type = ctx.req.param('type');
const struct = {
all: {
selector: {
list: '.plist li',
},
timeSelector: {
list: '.datatime',
},
titleSelector: {
list: '.adaptitle',
},
linkSelector: {
list: 'li a',
},
url: 'http://gs.ustb.edu.cn/index.php/cms/item-list-category-1049?role=3',
link: 'http://gs.ustb.edu.cn/index.php/cms/item-list-category-1049?role=3',
name: '最新通知 - 北京科技大学研究生院',
},
cres: {
selector: {
list: '.centerright_center li',
},
timeSelector: {
list: '.fright',
},
titleSelector: {
list: '.fleft',
},
linkSelector: {
list: 'li a',
},
url: 'http://cres.ustb.edu.cn/n44/n47/',
link: 'http://cres.ustb.edu.cn/n44/n47/',
name: '通知公告 - 土木与资源工程学院 - 北京科技大学研究生院',
},
seee: {
selector: {
list: '.list_left2 li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'http://seee.ustb.edu.cn/xinwengonggao/tongzhigonggao/',
link: 'http://seee.ustb.edu.cn/xinwengonggao/tongzhigonggao/',
name: '通知公告 - 能源与环境工程学院 - 北京科技大学研究生院',
},
metall: {
selector: {
list: '#news-list-title li',
},
timeSelector: {
list: '.date-size',
},
titleSelector: {
list: '.info-size',
},
linkSelector: {
list: 'li a',
},
url: 'https://metall.ustb.edu.cn/gg/index.htm',
link: 'https://metall.ustb.edu.cn/gg/index.htm',
name: '通知公告 - 冶金与生态工程学院 - 北京科技大学研究生院',
},
mse: {
selector: {
list: '.ky li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'http://mse.ustb.edu.cn/xueyuangonggao/',
link: 'http://mse.ustb.edu.cn/xueyuangonggao/',
name: '学院公告 - 材料科学与工程学院 - 北京科技大学研究生院',
},
me: {
selector: {
list: '.list li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'http://me.ustb.edu.cn/xinwengonggao/tongzhigonggao/',
link: 'http://me.ustb.edu.cn/xinwengonggao/tongzhigonggao/',
name: '通知公告 - 机械工程学院 -北京科技大学研究生院',
},
saee: {
selector: {
list: '.sidebar_b a:gt(1):lt(15)',
},
timeSelector: {
list: '.list_time',
},
titleSelector: {
list: '.list_timu',
},
linkSelector: {
list: 'a',
},
url: 'http://saee.ustb.edu.cn/gonggaogongshi/',
link: 'http://saee.ustb.edu.cn/gonggaogongshi/',
name: '通知公告 - 自动化学院 - 北京科技大学研究生院',
},
scce: {
selector: {
list: '.lead li',
},
timeSelector: {
list: '.practice_list_right',
},
titleSelector: {
list: '.practice_list_left',
},
linkSelector: {
list: 'li a',
},
url: 'http://scce.ustb.edu.cn/xinwentongzhi/tongzhigonggao/',
link: 'http://scce.ustb.edu.cn/xinwentongzhi/tongzhigonggao/',
name: '通知公告 - 计算机与通信工程学院 - 北京科技大学研究生院',
},
shuli: {
selector: {
list: '.jy-lb li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li p',
},
linkSelector: {
list: 'li a',
},
url: 'http://shuli.ustb.edu.cn/tongzhigonggao/',
link: 'http://shuli.ustb.edu.cn/tongzhigonggao/',
name: '通知公告 - 数理学院 - 北京科技大学研究生院',
},
huasheng: {
selector: {
list: '.main_r li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li p',
},
linkSelector: {
list: 'li a',
},
url: 'http://huasheng.ustb.edu.cn/tongzhigonggao/',
link: 'http://huasheng.ustb.edu.cn/tongzhigonggao/',
name: '通知公告 - 化学与生物工程学院 - 北京科技大学研究生院',
},
sem: {
selector: {
list: '.sub_002 li',
},
timeSelector: {
list: '.time',
},
titleSelector: {
list: '.title',
},
linkSelector: {
list: 'li a',
},
url: 'https://sem.ustb.edu.cn/xwzx/tzgg/index.htm',
link: 'https://sem.ustb.edu.cn/xwzx/tzgg/index.htm',
name: '通知公告 - 经济管理学院 - 北京科技大学研究生院',
},
wenfa: {
selector: {
list: '.list-content-box .specialDate_fontBox',
},
timeSelector: {
list: '.specialTime',
},
titleSelector: {
list: '.specialTime_a',
},
linkSelector: {
list: 'div a',
},
url: 'https://wenfa.ustb.edu.cn/tzgg2/tzgg/index.htm',
link: 'https://wenfa.ustb.edu.cn/tzgg2/tzgg/index.htm',
name: '通知公告 - 文法学院 - 北京科技大学研究生院',
},
marx: {
selector: {
list: '.list_l li',
},
timeSelector: {
list: '.time2',
},
titleSelector: {
list: '.list_title',
},
linkSelector: {
list: 'li a',
},
url: 'http://marx.ustb.edu.cn/tongzhigonggao/',
link: 'http://marx.ustb.edu.cn/tongzhigonggao/',
name: '通知公告 - 马克思主义学院 - 北京科技大学研究生院',
},
sfs: {
selector: {
list: '.list-unstyled li',
},
timeSelector: {
list: '',
},
titleSelector: {
list: '.text-overflow',
},
linkSelector: {
list: 'li a',
},
url: 'http://sfs.ustb.edu.cn/cn/xinwenzhongxin/tongzhigonggao1/',
link: 'http://sfs.ustb.edu.cn/cn/xinwenzhongxin/tongzhigonggao1/',
name: '通知公告 - 外国语学院 - 北京科技大学研究生院',
},
ncms: {
selector: {
list: '.list_l li',
},
timeSelector: {
list: '.right',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'http://ncms.ustb.edu.cn/tongzhigonggao/',
link: 'http://ncms.ustb.edu.cn/tongzhigonggao/',
name: '通知公告 - 国家材料服役安全科学中心 - 北京科技大学研究生院',
},
skl: {
selector: {
list: '.cultureStudent_top li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li p',
},
linkSelector: {
list: 'li a',
},
url: 'https://skl.ustb.edu.cn/xwzx/tzgg/index.htm',
link: 'https://skl.ustb.edu.cn/xwzx/tzgg/index.htm',
name: '通知公告 - 新金属材料国家重点实验室 - 北京科技大学研究生院',
},
iet: {
selector: {
list: 'table tr td table tr td .liststyle:lt(20)',
},
timeSelector: {
list: '.notestyle',
},
titleSelector: {
list: 'td a',
},
linkSelector: {
list: 'td a',
},
url: 'http://iet.ustb.edu.cn/articlelist.asp?cateID=1',
link: 'http://iet.ustb.edu.cn/articlelist.asp?cateID=1',
name: '通知公告 - 工程技术研究院 - 北京科技大学研究生院',
},
cicst: {
selector: {
list: '.h_newsbox li',
},
timeSelector: {
list: '.time',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'http://cicst.ustb.edu.cn/tongzhigonggao/',
link: 'http://cicst.ustb.edu.cn/tongzhigonggao/',
name: '通知公告 - 钢铁共性技术协同创新中心 - 北京科技大学研究生院',
},
slam: {
selector: {
list: '.list li',
},
timeSelector: {
list: 'li p',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'http://slam.ustb.edu.cn/slam//smvc/ListBs-articleList/SNM2015072600000000000011',
link: 'http://slam.ustb.edu.cn/slam//',
name: '通知公告 - 钢铁冶金新技术国家重点实验室 - 北京科技大学研究生院',
},
adma: {
selector: {
list: '.articleList li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'https://adma.ustb.edu.cn/tzgg/index.htm',
link: 'https://adma.ustb.edu.cn/tzgg/index.htm',
name: '通知公告 - 新材料技术研究院 - 北京科技大学研究生院',
},
ihmm: {
selector: {
list: '.listbox li',
},
timeSelector: {
list: '',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'https://ihmm.ustb.edu.cn/gg/index.htm',
link: 'https://ihmm.ustb.edu.cn/gg/index.htm',
name: '公告 - 科技史与文化遗产研究院 - 北京科技大学研究生院',
},
sd: {
selector: {
list: '.news_list li',
},
timeSelector: {
list: 'li span',
},
titleSelector: {
list: 'li a',
},
linkSelector: {
list: 'li a',
},
url: 'https://sd.ustb.edu.cn/tzgg/index.htm',
link: 'https://sd.ustb.edu.cn/tzgg/index.htm',
name: '通知公告 - 顺德研究生院 - 北京科技大学研究生院',
},
};
// 请求
const url = struct[type].url;
const response = await got({
method: 'get',
responseType: 'buffer', // 转码
url,
});
// 获取response
const data = type === 'iet' ? iconv.decode(response.data, 'gb2312') : response.data;
const $ = load(data);
// logger.info("data:" + data);
// 获取响应中有用的部分
const list = $(struct[type].selector.list);
// logger.info("list:" + list);
// 处理返回
return {
title: struct[type].name,
link: struct[type].link,
description: '北京科技大学研究生院',
item:
list &&
list
.map((index, item) => {
item = $(item);
// logger.info("item:" + item);
// time
let time = item.find($(struct[type].timeSelector.list)).text();
let date;
if (time !== '') {
if (time.includes('[')) {
time = time.slice(1, 11);
}
date = parseDate(time);
}
// logger.info("date:" + date);
// link
let link = item.find($(struct[type].linkSelector.list)).attr('href');
if (link === undefined) {
link = item.attr('href');
}
// logger.info("link:" + link);
// title
let title = item.find($(struct[type].titleSelector.list)).clone().children().remove().end().text();
if (title === '') {
title = item.find($(struct[type].titleSelector.list)).text();
}
// logger.info("title:" + title);
// logger.info("=====");
// return
return date === undefined
? {
title,
description: title,
link,
}
: {
title,
description: title,
link,
pubDate: date,
};
})
.get(),
};
}