rsshub 1.0.0-master.d251822 → 1.0.0-master.d3a9b3a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/lib/router.js +6 -15
  2. package/lib/routes/fanxinzhui/latest.js +53 -0
  3. package/lib/routes/universities/fzu/news.js +15 -18
  4. package/lib/routes/universities/fzu/news_min.js +44 -0
  5. package/lib/routes/wenku8/volume.js +52 -0
  6. package/lib/v2/distill/index.js +64 -0
  7. package/lib/v2/distill/maintainer.js +3 -0
  8. package/lib/v2/distill/radar.js +13 -0
  9. package/lib/v2/distill/router.js +3 -0
  10. package/lib/v2/eastday/find.js +49 -0
  11. package/lib/v2/eastday/maintainer.js +4 -0
  12. package/lib/v2/eastday/portrait.js +47 -0
  13. package/lib/v2/eastday/radar.js +19 -0
  14. package/lib/v2/eastday/router.js +4 -0
  15. package/lib/v2/heu/gx/card.js +47 -0
  16. package/lib/v2/heu/gx/list.js +73 -0
  17. package/lib/v2/heu/job/bigemploy.js +42 -0
  18. package/lib/v2/heu/job/calendar.js +54 -0
  19. package/lib/v2/heu/job/list.js +70 -0
  20. package/lib/v2/heu/maintainer.js +8 -0
  21. package/lib/v2/heu/radar.js +73 -0
  22. package/lib/v2/heu/router.js +9 -0
  23. package/lib/v2/heu/uae/list.js +62 -0
  24. package/lib/v2/heu/yjsy/list.js +65 -0
  25. package/lib/v2/mygopen/index.js +29 -0
  26. package/lib/v2/mygopen/maintainer.js +3 -0
  27. package/lib/v2/mygopen/radar.js +13 -0
  28. package/lib/v2/mygopen/router.js +3 -0
  29. package/lib/v2/netease/maintainer.js +1 -0
  30. package/lib/v2/netease/radar.js +9 -1
  31. package/lib/v2/netease/renjian.js +74 -0
  32. package/lib/v2/netease/router.js +1 -0
  33. package/lib/v2/newsmarket/index.js +63 -0
  34. package/lib/v2/newsmarket/maintainer.js +3 -0
  35. package/lib/v2/newsmarket/radar.js +13 -0
  36. package/lib/v2/newsmarket/router.js +3 -0
  37. package/lib/v2/subhd/index.js +79 -0
  38. package/lib/v2/subhd/maintainer.js +4 -0
  39. package/lib/v2/subhd/radar.js +19 -0
  40. package/lib/v2/subhd/router.js +3 -0
  41. package/lib/v2/watchout/index.js +51 -0
  42. package/lib/v2/watchout/maintainer.js +3 -0
  43. package/lib/v2/watchout/radar.js +13 -0
  44. package/lib/v2/watchout/router.js +3 -0
  45. package/lib/v2/wzu/maintainer.js +3 -0
  46. package/lib/v2/wzu/news.js +84 -0
  47. package/lib/v2/wzu/radar.js +11 -0
  48. package/lib/v2/wzu/router.js +3 -0
  49. package/package.json +1 -1
  50. package/lib/routes/subhd/newest.js +0 -29
  51. package/lib/routes/universities/heu/job.js +0 -80
  52. package/lib/routes/universities/heu/news.js +0 -80
  53. package/lib/routes/universities/heu/uae.js +0 -84
  54. package/lib/routes/universities/heu/ugs/news.js +0 -122
  55. package/lib/routes/universities/heu/yjsy.js +0 -92
  56. package/lib/routes/universities/wzu/news.js +0 -25
package/lib/router.js CHANGED
@@ -710,15 +710,6 @@ router.get('/njupt/jwc/:type?', lazyloadRouteHandler('./routes/universities/njup
710
710
  // 南昌航空大学
711
711
  router.get('/nchu/jwc/:type?', lazyloadRouteHandler('./routes/universities/nchu/jwc'));
712
712
 
713
- // 哈尔滨工程大学
714
- router.get('/heu/ugs/news/:author?/:category?', lazyloadRouteHandler('./routes/universities/heu/ugs/news'));
715
- router.get('/heu/yjsy/:type?', lazyloadRouteHandler('./routes/universities/heu/yjsy'));
716
- router.get('/heu/gongxue/:type?', lazyloadRouteHandler('./routes/universities/heu/news'));
717
- router.get('/heu/news/:type?', lazyloadRouteHandler('./routes/universities/heu/news'));
718
- router.get('/heu/shuisheng/:type?', lazyloadRouteHandler('./routes/universities/heu/uae'));
719
- router.get('/heu/uae/:type?', lazyloadRouteHandler('./routes/universities/heu/uae'));
720
- router.get('/heu/job/:type?', lazyloadRouteHandler('./routes/universities/heu/job'));
721
-
722
713
  // 重庆大学
723
714
  router.get('/cqu/jwc/:path*', lazyloadRouteHandler('./routes/universities/cqu/jwc/announcement'));
724
715
  router.get('/cqu/news/jzyg', lazyloadRouteHandler('./routes/universities/cqu/news/jzyg'));
@@ -910,6 +901,7 @@ router.get('/lyu/news/:type', lazyloadRouteHandler('./routes/universities/lyu/ne
910
901
 
911
902
  // 福州大学
912
903
  router.get('/fzu/:type', lazyloadRouteHandler('./routes/universities/fzu/news'));
904
+ router.get('/fzu_min/:type', lazyloadRouteHandler('./routes/universities/fzu/news_min'));
913
905
 
914
906
  // 厦门大学
915
907
  router.get('/xmu/aero/:type', lazyloadRouteHandler('./routes/universities/xmu/aero'));
@@ -1236,7 +1228,7 @@ router.get('/zimuzu/top/:range/:type', lazyloadRouteHandler('./routes/zimuzu/top
1236
1228
  router.get('/zimuku/:type?', lazyloadRouteHandler('./routes/zimuku/index'));
1237
1229
 
1238
1230
  // SubHD.tv
1239
- router.get('/subhd/newest', lazyloadRouteHandler('./routes/subhd/newest'));
1231
+ // router.get('/subhd/newest', lazyloadRouteHandler('./routes/subhd/newest'));
1240
1232
 
1241
1233
  // 虎嗅
1242
1234
  router.get('/huxiu/tag/:id', lazyloadRouteHandler('./routes/huxiu/tag'));
@@ -1433,6 +1425,7 @@ router.get('/gaoqing/latest', lazyloadRouteHandler('./routes/gaoqing/latest'));
1433
1425
 
1434
1426
  // 轻小说文库
1435
1427
  router.get('/wenku8/chapter/:id', lazyloadRouteHandler('./routes/wenku8/chapter'));
1428
+ router.get('/wenku8/volume/:id', lazyloadRouteHandler('./routes/wenku8/volume'));
1436
1429
 
1437
1430
  // 鲸跃汽车
1438
1431
  router.get('/whalegogo/home', lazyloadRouteHandler('./routes/whalegogo/home'));
@@ -2859,8 +2852,9 @@ router.get('/lntu/jwnews', lazyloadRouteHandler('./routes/universities/lntu/jwne
2859
2852
  // 51voa
2860
2853
  router.get('/51voa/:channel', lazyloadRouteHandler('./routes/51voa/channel'));
2861
2854
 
2862
- // zhuixinfan
2863
- router.get('/zhuixinfan/list', lazyloadRouteHandler('./routes/zhuixinfan/list'));
2855
+ // 追新番
2856
+ router.get('/fanxinzhui', lazyloadRouteHandler('./routes/fanxinzhui/latest'));
2857
+ router.get('/zhuixinfan/list', lazyloadRouteHandler('./routes/fanxinzhui/latest'));
2864
2858
 
2865
2859
  // scoresaber
2866
2860
  router.get('/scoresaber/user/:id', lazyloadRouteHandler('./routes/scoresaber/user'));
@@ -4165,9 +4159,6 @@ router.get('/harvard/health/blog', lazyloadRouteHandler('./routes/universities/h
4165
4159
  // yuzu emulator
4166
4160
  router.get('/yuzu-emu/entry', lazyloadRouteHandler('./routes/yuzu-emu/entry'));
4167
4161
 
4168
- // 温州大学
4169
- router.get('/wzu/news', lazyloadRouteHandler('./routes/universities/wzu/news'));
4170
-
4171
4162
  // Resources - The Partnership on AI
4172
4163
  router.get('/partnershiponai/resources', lazyloadRouteHandler('./routes/partnershiponai/resources'));
4173
4164
 
@@ -0,0 +1,53 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const date = require('@/utils/date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const rootUrl = 'http://www.fanxinzhui.com';
7
+ const currentUrl = `${rootUrl}/lastest`;
8
+ const response = await got({
9
+ method: 'get',
10
+ url: currentUrl,
11
+ });
12
+
13
+ const $ = cheerio.load(response.data);
14
+
15
+ const list = $('.la')
16
+ .slice(0, 10)
17
+ .map((_, item) => {
18
+ item = $(item);
19
+ const pubDate = item.find('.time');
20
+
21
+ pubDate.remove();
22
+
23
+ return {
24
+ title: item.text(),
25
+ pubDate: date(pubDate.text()),
26
+ link: `${rootUrl}${item.attr('href')}`,
27
+ };
28
+ })
29
+ .get();
30
+
31
+ const items = await Promise.all(
32
+ list.map(
33
+ async (item) =>
34
+ await ctx.cache.tryGet(item.link, async () => {
35
+ const detailResponse = await got({
36
+ method: 'get',
37
+ url: item.link,
38
+ });
39
+ const content = cheerio.load(detailResponse.data);
40
+
41
+ item.description = content('.middle_box').html();
42
+
43
+ return item;
44
+ })
45
+ )
46
+ );
47
+
48
+ ctx.state.data = {
49
+ title: '最近更新 - 追新番',
50
+ link: currentUrl,
51
+ item: items,
52
+ };
53
+ };
@@ -1,14 +1,6 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
3
 
4
- const url_map = {
5
- jxtz: '1804',
6
- zjjz: '1809',
7
- };
8
- const Referer_map = {
9
- jxtz: '/jxtz/',
10
- zjjz: '/zjjz/',
11
- };
12
4
  const title_map = {
13
5
  jxtz: '教学通知',
14
6
  zjjz: '专家讲座',
@@ -22,17 +14,22 @@ module.exports = async (ctx) => {
22
14
  const type = ctx.params.type || '';
23
15
  const response = await got({
24
16
  method: 'get',
25
- url: `http://jwch.fzu.edu.cn/plus/json.aspx?jid=J131925584886784703&classid=${url_map[type]}&page=1&column=infoid%2Cclassid%2Ctitle%2Cdefaultpic%2Cintro%2Cadddate%2Curl%2Cclassname`,
26
- headers: {
27
- Referer: `http://jwch.fzu.edu.cn${Referer_map[type]}`,
28
- },
17
+ url: `https://jwch.fzu.edu.cn/${type}.htm`,
29
18
  });
30
- const data = response.data.data;
19
+ const data = response.data; // 获取页面 html 数据
20
+
21
+ const $ = cheerio.load(data);
22
+ const list = $('ul.list-gl'); // <li>s
31
23
 
32
- const urls = new Array();
33
- for (let i = 0; i <= 9; i++) {
34
- urls[i] = data[i].url;
35
- }
24
+ const urls = [];
25
+
26
+ const url_head = 'https://jwch.fzu.edu.cn/';
27
+
28
+ list.find('a').each(function () {
29
+ const a = $(this);
30
+ const url_part = a.attr('href');
31
+ urls.push(url_head + url_part);
32
+ });
36
33
 
37
34
  const items = await Promise.all(
38
35
  urls.map((item) =>
@@ -57,7 +54,7 @@ module.exports = async (ctx) => {
57
54
 
58
55
  ctx.state.data = {
59
56
  title: `福州大学教务处${title_map[type]}`,
60
- link: `http://jwch.fzu.edu.cn/jxtz/`,
57
+ link: `http://jwch.fzu.edu.cn/${type}`,
61
58
  description: `福州大学教务处${description_map[type]}`,
62
59
  item: items,
63
60
  };
@@ -0,0 +1,44 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ const title_map = {
5
+ jxtz: '教学通知',
6
+ zjjz: '专家讲座',
7
+ };
8
+ const description_map = {
9
+ jxtz: '教学通知',
10
+ zjjz: '嘉锡讲坛/信息素养讲座通知',
11
+ };
12
+
13
+ module.exports = async (ctx) => {
14
+ const type = ctx.params.type || '';
15
+ const response = await got({
16
+ method: 'get',
17
+ url: `https://jwch.fzu.edu.cn/${type}.htm`,
18
+ });
19
+ const data = response.data; // 获取页面 html 数据
20
+
21
+ const $ = cheerio.load(data);
22
+ const list = $('ul.list-gl').find('li'); // <li>s
23
+
24
+ const url_head = 'https://jwch.fzu.edu.cn/';
25
+
26
+ ctx.state.data = {
27
+ title: `福州大学教务处${title_map[type]}`,
28
+ link: `http://jwch.fzu.edu.cn/${type}`,
29
+ description: `福州大学教务处${description_map[type]}`,
30
+ item:
31
+ list &&
32
+ list
33
+ .map((index, item) => {
34
+ item = $(item);
35
+ return {
36
+ title: item.find('a').attr('title'),
37
+ discription: item.find('a').attr('title'),
38
+ link: url_head + item.find('a').attr('href'),
39
+ pubDate: item.find('span').html(),
40
+ };
41
+ })
42
+ .get(),
43
+ };
44
+ };
@@ -0,0 +1,52 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const iconv = require('iconv-lite');
4
+
5
+ module.exports = async (ctx) => {
6
+ const aid = ctx.params.id;
7
+ const novel_url = `https://www.wenku8.net/novel/${parseInt(aid / 1000)}/${aid}/index.htm`;
8
+ const $ = cheerio.load(await get(novel_url));
9
+
10
+ const novel_name = $('#title').text();
11
+
12
+ const volume_list = $('.vcss');
13
+ const last_volume = $(volume_list[volume_list.length - 1]);
14
+ const vid = last_volume.parent().next().find('a')[0].attribs.href.replace('.htm', '');
15
+
16
+ const volume_url = `https://dl.wenku8.com/packtxt.php?aid=${aid}&vid=${vid}&charset=gbk`;
17
+ const item_list = await ctx.cache.tryGet(volume_url, async () => {
18
+ const result = await get(volume_url);
19
+ const chapter_list = [...result.matchAll(/ {2}(\S.*)\r\n([\S\s]+?)\r\n\r\n/g)];
20
+ return chapter_list
21
+ .filter((chapter) => chapter[2].trim())
22
+ .reverse()
23
+ .map((chapter) => ({
24
+ title: chapter[1],
25
+ description: format_description(chapter[2]),
26
+ guid: Buffer.from(`${vid}${chapter[1]}`).toString('base64'),
27
+ }));
28
+ });
29
+
30
+ ctx.state.data = {
31
+ title: `轻小说文库 ${novel_name} 最新卷`,
32
+ link: novel_url,
33
+ item: item_list,
34
+ };
35
+ };
36
+
37
+ const get = async (url) => {
38
+ const response = await got({
39
+ method: 'get',
40
+ url,
41
+ responseType: 'buffer',
42
+ });
43
+
44
+ return iconv.decode(response.data, 'gbk');
45
+ };
46
+
47
+ const format_description = (str) =>
48
+ str
49
+ .split('\r\n')
50
+ .filter((line) => line.trim())
51
+ .map((line) => `<p>${line.trim()}</p>`)
52
+ .join('');
@@ -0,0 +1,64 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const rootUrl = 'https://distill.pub';
7
+
8
+ const response = await got({
9
+ method: 'get',
10
+ url: rootUrl,
11
+ });
12
+
13
+ const $ = cheerio.load(response.data);
14
+
15
+ let items = $('.post-preview')
16
+ .toArray()
17
+ .map((item) => {
18
+ item = $(item);
19
+
20
+ return {
21
+ title: item.find('.title').text(),
22
+ link: `${rootUrl}/${item.children('a').attr('href')}`,
23
+ };
24
+ });
25
+
26
+ items = await Promise.all(
27
+ items.map((item) =>
28
+ ctx.cache.tryGet(item.link, async () => {
29
+ const detailResponse = await got({
30
+ method: 'get',
31
+ url: item.link,
32
+ });
33
+
34
+ const content = cheerio.load(detailResponse.data);
35
+
36
+ content('d-contents').remove();
37
+
38
+ content('img').each(function () {
39
+ content(this).attr('src', `${item.link}/${content(this).attr('src')}`);
40
+ });
41
+
42
+ item.doi = content('meta[name="citation_doi"]').attr('content');
43
+ item.pubDate = parseDate(content('meta[property="article:published"]').attr('content'));
44
+ item.description = content('d-article')
45
+ .children()
46
+ .toArray()
47
+ .map((c) => content(c).html())
48
+ .join('');
49
+ item.author = content('meta[property="article:author"]')
50
+ .toArray()
51
+ .map((author) => content(author).attr('content'))
52
+ .join(', ');
53
+
54
+ return item;
55
+ })
56
+ )
57
+ );
58
+
59
+ ctx.state.data = {
60
+ title: $('title').text(),
61
+ link: rootUrl,
62
+ item: items,
63
+ };
64
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/': ['nczitzk'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'distill.pub': {
3
+ _name: 'Distill',
4
+ '.': [
5
+ {
6
+ title: 'Latest',
7
+ docs: 'https://docs.rsshub.app/programming.html#distill',
8
+ source: ['/'],
9
+ target: '/distill',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/', require('./index'));
3
+ };
@@ -0,0 +1,49 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const timezone = require('@/utils/timezone');
4
+ const { parseDate } = require('@/utils/parse-date');
5
+
6
+ module.exports = async (ctx) => {
7
+ const rootUrl = 'https://apin.eastday.com';
8
+ const currentUrl = `${rootUrl}/api/news/Find`;
9
+
10
+ const response = await got({
11
+ method: 'post',
12
+ url: currentUrl,
13
+ json: {
14
+ currentPage: 1,
15
+ newsType: 1,
16
+ pageSize: 30,
17
+ query: '',
18
+ },
19
+ });
20
+
21
+ const list = response.data.newsList.list.map((item) => ({
22
+ link: item.url,
23
+ title: item.title,
24
+ pubDate: timezone(parseDate(item.time), +8),
25
+ }));
26
+
27
+ const items = await Promise.all(
28
+ list.map((item) =>
29
+ ctx.cache.tryGet(item.link, async () => {
30
+ const detailResponse = await got({
31
+ method: 'get',
32
+ url: item.link,
33
+ });
34
+
35
+ const content = cheerio.load(detailResponse.data);
36
+
37
+ item.description = content('.detail').html();
38
+
39
+ return item;
40
+ })
41
+ )
42
+ );
43
+
44
+ ctx.state.data = {
45
+ title: '热点搜索 - 东方网',
46
+ link: 'https://news.eastday.com/china/index_K43594.html',
47
+ item: items,
48
+ };
49
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '/find': ['nczitzk'],
3
+ '/portrait': ['nczitzk'],
4
+ };
@@ -0,0 +1,47 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const timezone = require('@/utils/timezone');
4
+ const { parseDate } = require('@/utils/parse-date');
5
+
6
+ module.exports = async (ctx) => {
7
+ const rootUrl = 'https://apin.eastday.com';
8
+ const currentUrl = `${rootUrl}/api/news/Portrait`;
9
+
10
+ const response = await got({
11
+ method: 'post',
12
+ url: currentUrl,
13
+ json: {
14
+ currentPage: 1,
15
+ pageSize: 30,
16
+ },
17
+ });
18
+
19
+ const list = response.data.list.map((item) => ({
20
+ link: item.url,
21
+ title: item.title,
22
+ pubDate: timezone(parseDate(item.time), +8),
23
+ }));
24
+
25
+ const items = await Promise.all(
26
+ list.map((item) =>
27
+ ctx.cache.tryGet(item.link, async () => {
28
+ const detailResponse = await got({
29
+ method: 'get',
30
+ url: item.link,
31
+ });
32
+
33
+ const content = cheerio.load(detailResponse.data);
34
+
35
+ item.description = content('.detail').html();
36
+
37
+ return item;
38
+ })
39
+ )
40
+ );
41
+
42
+ ctx.state.data = {
43
+ title: '原创 - 东方网',
44
+ link: 'https://www.eastday.com/eastday/shouye/07index/yc/index.html',
45
+ item: items,
46
+ };
47
+ };
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ 'eastday.com': {
3
+ _name: '东方网',
4
+ www: [
5
+ {
6
+ title: '热点搜索',
7
+ docs: 'https://docs.rsshub.app/traditional-media.html#dong-fang-wang-re-dian-sou-suo',
8
+ source: '/',
9
+ target: '/eastday/find',
10
+ },
11
+ {
12
+ title: '原创',
13
+ docs: 'https://docs.rsshub.app/traditional-media.html#dong-fang-wang-yuan-chuang',
14
+ source: '/',
15
+ target: '/eastday/portrait',
16
+ },
17
+ ],
18
+ },
19
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = function (router) {
2
+ router.get('/find', require('./find'));
3
+ router.get('/portrait', require('./portrait'));
4
+ };
@@ -0,0 +1,47 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ const rootUrl = 'http://news.hrbeu.edu.cn';
5
+
6
+ module.exports = async (ctx) => {
7
+ const date = new Date();
8
+ const hour = date.getHours();
9
+ const minute = date.getMinutes();
10
+ const column = ctx.params.column;
11
+ const id = ctx.params.id || '';
12
+ let toUrl;
13
+ if (id !== '') {
14
+ toUrl = rootUrl.concat('/', column, '/', id, '.htm');
15
+ } else {
16
+ toUrl = rootUrl.concat('/', column, '.htm');
17
+ }
18
+
19
+ const response = await got({
20
+ method: 'get',
21
+ url: toUrl,
22
+ headers: {
23
+ Referer: rootUrl,
24
+ },
25
+ });
26
+
27
+ const $ = cheerio.load(response.data);
28
+
29
+ const bigTitle = $('div.list-left-tt')
30
+ .text()
31
+ .replace(/[ ]|[\r\n]/g, '');
32
+
33
+ const card = $('li.clearfix')
34
+ .map((_, item) => ({
35
+ title: $(item).find('div.list-right-tt').text(),
36
+ pubDate: $(item).find('span').text() + ' ' + hour + ':' + minute,
37
+ link: $(item).find('a').attr('href'),
38
+ description: $(item).find('div.list-right-p').text(),
39
+ }))
40
+ .get();
41
+
42
+ ctx.state.data = {
43
+ title: '工学-' + bigTitle,
44
+ link: toUrl,
45
+ item: card,
46
+ };
47
+ };
@@ -0,0 +1,73 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ const rootUrl = 'http://news.hrbeu.edu.cn';
5
+
6
+ module.exports = async (ctx) => {
7
+ const date = new Date();
8
+ const hour = date.getHours();
9
+ const minute = date.getMinutes();
10
+ const column = ctx.params.column;
11
+ const id = ctx.params.id || '';
12
+ let toUrl;
13
+ if (id !== '') {
14
+ toUrl = rootUrl.concat('/', column, '/', id, '.htm');
15
+ } else {
16
+ toUrl = rootUrl.concat('/', column, '.htm');
17
+ }
18
+
19
+ const response = await got({
20
+ method: 'get',
21
+ url: toUrl,
22
+ headers: {
23
+ Referer: rootUrl,
24
+ },
25
+ });
26
+
27
+ const $ = cheerio.load(response.data);
28
+
29
+ const bigTitle = $('div.list-left-tt')
30
+ .text()
31
+ .replace(/[ ]|[\r\n]/g, '');
32
+
33
+ const list = $('li.txt-elise')
34
+ .map((_, item) => {
35
+ let link = $(item).find('a').attr('href');
36
+ if (link.indexOf('info') !== -1 && id !== '') {
37
+ link = rootUrl.concat(link.substring(2));
38
+ }
39
+ if (link.indexOf('info') !== -1 && id === '') {
40
+ link = rootUrl.concat('/', link);
41
+ }
42
+ return {
43
+ title: $(item).find('a').attr('title'),
44
+ pubDate: $(item).find('span').text() + ' ' + hour + ':' + minute,
45
+ link,
46
+ };
47
+ })
48
+ .get();
49
+
50
+ await Promise.all(
51
+ list.map((item) =>
52
+ ctx.cache.tryGet(item.link, async () => {
53
+ if (item.link.indexOf('info') !== -1) {
54
+ const detailResponse = await got({
55
+ method: 'get',
56
+ url: item.link,
57
+ });
58
+ const content = cheerio.load(detailResponse.data);
59
+ item.description = content('div.v_news_content').html();
60
+ } else {
61
+ item.description = item.title + '<br><br>' + '本文需跳转,请点击标题后阅读';
62
+ }
63
+ return item;
64
+ })
65
+ )
66
+ );
67
+
68
+ ctx.state.data = {
69
+ title: '工学-' + bigTitle,
70
+ link: toUrl,
71
+ item: list,
72
+ };
73
+ };
@@ -0,0 +1,42 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ module.exports = async (ctx) => {
5
+ const date = new Date();
6
+ const hour = date.getHours();
7
+ const minute = date.getMinutes();
8
+
9
+ const response = await got({
10
+ method: 'get',
11
+ url: 'http://job.hrbeu.edu.cn/HrbeuJY/web',
12
+ });
13
+
14
+ const $ = cheerio.load(response.data);
15
+
16
+ const list = $('div.articlecontent')
17
+ .map((_, item) => {
18
+ const link = $(item).find('a.bigTitle').attr('href');
19
+ return {
20
+ title: $(item).find('a.bigTitle').text(),
21
+ pubDate:
22
+ $(item)
23
+ .text()
24
+ .replace(/[ ]|[\r\n]/g, '')
25
+ .substr(-10) +
26
+ ' ' +
27
+ hour +
28
+ ':' +
29
+ minute,
30
+ description: $(item).find('a.bigTitle').text() + '<br><br>' + '点击标题,登录查看招聘详情',
31
+ link,
32
+ };
33
+ })
34
+ .get();
35
+
36
+ ctx.state.data = {
37
+ title: '大型招聘会',
38
+ link: 'http://job.hrbeu.edu.cn/HrbeuJY/web',
39
+ item: list,
40
+ allowEmpty: true,
41
+ };
42
+ };