Skip to content

Commit 19c4525

Browse files
authored
Merge pull request #626 from DIYgod/master
[pull] master from diygod:master
2 parents 1d70ec8 + 90d8455 commit 19c4525

File tree

11 files changed

+165
-6
lines changed

11 files changed

+165
-6
lines changed

docs/new-media.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,12 @@ others = 热点新闻 + 滚动新闻
23102310

23112311
<Route author="Jeason0228" example="/guancha/personalpage/243983" path="/guancha/personalpage/:uid" :paramsDesc="['用户id, 可在URL中找到']" />
23122312

2313+
## 观海新闻
2314+
2315+
### 首页
2316+
2317+
<Route author="TonyRL" example="/guanhai" path="/guanhai" radar="1" rssbud="1"/>
2318+
23132319
## 广告门
23142320

23152321
### 板块

docs/university.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,14 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
23662366
| ---- | ---- |
23672367
| jwgg | jwxw |
23682368

2369+
### 数字平台
2370+
2371+
<Route author="imbytecat" example="/shmtu/portal/bmtzgg" path="/shmtu/portal/:type" :paramsDesc="['类型名称']"/>
2372+
2373+
| 部门通知公告 |
2374+
| ------ |
2375+
| bmtzgg |
2376+
23692377
## 上海海洋大学
23702378

23712379
### 官网信息

lib/v2/gcores/category.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,26 @@ module.exports = async (ctx) => {
1212
const $ = cheerio.load(data);
1313
const feedTitle = $('title').text();
1414

15-
const list = $('.original.am_card.original-normal')
16-
.map(function () {
15+
let list;
16+
if (category === 'news') {
17+
list = $('a.news').map(function () {
18+
const item = {
19+
url: $(this).attr('href'),
20+
title: $(this).find('.news_content>h3').text(),
21+
};
22+
return item;
23+
});
24+
} else {
25+
list = $('.original.am_card.original-normal').map(function () {
1726
const item = {
1827
url: $(this).find('.am_card_inner>a').attr('href'),
1928
title: $(this).find('h3.am_card_title').text(),
2029
category: $(this).find('span.original_category>a').text(),
2130
};
2231
return item;
23-
})
24-
.get();
32+
});
33+
}
34+
list = list.get();
2535

2636
if (list.length > 0 && list.every((item) => item.url === undefined)) {
2737
throw new Error('Article URL not found! Please submit an issue on GitHub.');
@@ -85,13 +95,13 @@ module.exports = async (ctx) => {
8595
$('.story_hidden').replaceWith('');
8696

8797
const content = $('.story.story-show').html();
88-
return {
98+
const basicItem = {
8999
title: item.title,
90100
description: cover + content,
91-
category: item.category,
92101
link: articleUrl,
93102
guid: articleUrl,
94103
};
104+
return category === 'news' ? basicItem : { ...basicItem, category: item.category };
95105
});
96106
})
97107
);

lib/v2/guanhai/index.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
const { parseDate } = require('@/utils/parse-date');
4+
const timezone = require('@/utils/timezone');
5+
6+
module.exports = async (ctx) => {
7+
const { data: response } = await got('https://www.guanhai.com.cn');
8+
const $ = cheerio.load(response);
9+
10+
const imgBox = $('.img-box');
11+
const recommand = {
12+
title: imgBox.find('a').first().attr('title'),
13+
link: imgBox.find('a').first().attr('href'),
14+
pubDate: timezone(parseDate(imgBox.find('time').text()), 8),
15+
};
16+
const list = $('.pic-summary .title')
17+
.toArray()
18+
.map((item) => {
19+
item = $(item);
20+
return {
21+
title: item.find('a').attr('title'),
22+
link: item.find('a').attr('href'),
23+
pubDate: timezone(parseDate(item.find('time').text()), 8),
24+
};
25+
})
26+
.concat(recommand);
27+
28+
const items = await Promise.all(
29+
list.map((item) =>
30+
ctx.cache.tryGet(item.link, async () => {
31+
const { data: response } = await got(item.link);
32+
const $ = cheerio.load(response);
33+
item.author = $('.source').text();
34+
item.description = $('.article-content').html();
35+
return item;
36+
})
37+
)
38+
);
39+
40+
ctx.state.data = {
41+
title: $('head title').text(),
42+
description: $('head meta[name=description]').text(),
43+
image: 'https://www.guanhai.com.cn/favicon.ico',
44+
link: 'https://www.guanhai.com.cn',
45+
item: items,
46+
};
47+
};

lib/v2/guanhai/maintainer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
'': ['TonyRL'],
3+
'/': ['TonyRL'],
4+
};

lib/v2/guanhai/radar.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
'guanhai.com.cn': {
3+
_name: '观海新闻',
4+
'.': [
5+
{
6+
title: '首页',
7+
docs: 'https://docs.rsshub.app/new-media.html#guan-hai-xin-wen',
8+
source: ['/'],
9+
target: '/guanhai',
10+
},
11+
],
12+
},
13+
};

lib/v2/guanhai/router.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (router) => {
2+
router.get('/', require('./index'));
3+
};

lib/v2/shmtu/maintainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
22
'/jwc/:type': ['simonsmh'],
3+
'/portal/:type': ['imbytecat'],
34
'/www/:type': ['simonsmh'],
45
};

lib/v2/shmtu/portal.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
const { parseDate } = require('@/utils/parse-date');
4+
const timezone = require('@/utils/timezone');
5+
const bootstrapHost = 'https://weixin.shmtu.edu.cn/dynamic/shmtuHttps';
6+
const host = 'https://portal.shmtu.edu.cn/api';
7+
8+
const loadDetail = async (link) => {
9+
const response = await got.post(bootstrapHost, {
10+
form: {
11+
interfaceUrl: link,
12+
},
13+
https: { rejectUnauthorized: false },
14+
});
15+
16+
return JSON.parse(response.data);
17+
};
18+
19+
const processFeed = (list, caches) =>
20+
Promise.all(
21+
list.map((item) =>
22+
caches.tryGet(item.link, async () => {
23+
const detail = await loadDetail(item.link);
24+
item.description = detail.body.und[0].safe_value;
25+
item.link = detail.path;
26+
return item;
27+
})
28+
)
29+
);
30+
31+
module.exports = async (ctx) => {
32+
const type = ctx.params.type;
33+
const info = type === 'bmtzgg' ? '部门通知公告' : '未知';
34+
35+
const response = await got.post(bootstrapHost, {
36+
form: {
37+
interfaceUrl: `${host}/${type}.json?page=0`,
38+
},
39+
https: { rejectUnauthorized: false },
40+
});
41+
42+
const list = JSON.parse(response.data).map((item) => ({
43+
title: cheerio.load(item.title).text(),
44+
link: `${host}/node/${item.nid}.json`,
45+
pubDate: timezone(parseDate(item.created), 8),
46+
category: item.field_department[0],
47+
author: item.field_department[0],
48+
}));
49+
50+
const result = await processFeed(list, ctx.cache);
51+
52+
ctx.state.data = {
53+
title: `上海海事大学 ${info}`,
54+
link: 'https://portal.shmtu.edu.cn/bumentongzhigonggao',
55+
description: '上海海事大学 数字平台',
56+
item: result,
57+
};
58+
};

lib/v2/shmtu/radar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ module.exports = {
99
target: '/shmtu/jwc/:type',
1010
},
1111
],
12+
portal: [
13+
{
14+
title: '数字平台',
15+
docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
16+
source: ['/:type'],
17+
target: '/shmtu/portal/:type',
18+
},
19+
],
1220
www: [
1321
{
1422
title: '官网信息',

0 commit comments

Comments
 (0)