mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
feat: add 南京理工大学电光学院; fix: 南京理工大学研究生院 (#4298)
This commit is contained in:
@@ -774,6 +774,24 @@ category 列表:
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 南京理工大学电光学院
|
||||||
|
|
||||||
|
<Route author="jasongzy" example="/njust/eo/17/tz" path="/njust/eo/:grade?/:type?" :paramsDesc="['年级默认为 `17`', '类别默认为 `tz`']">
|
||||||
|
|
||||||
|
grade 列表:
|
||||||
|
|
||||||
|
| 本科 2016 级 | 本科 2017 级 | 本科 2018 级 | 本科 2019 级 |
|
||||||
|
| ------------ | ------------ | ------------ | ------------ |
|
||||||
|
| 16 | 17 | 18 | 19 |
|
||||||
|
|
||||||
|
type 列表:
|
||||||
|
|
||||||
|
| 年级通知(通知公告) | 每日动态(主任寄语) |
|
||||||
|
| -------------------- | -------------------- |
|
||||||
|
| tz | dt |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 南京林业大学
|
## 南京林业大学
|
||||||
|
|
||||||
### 教务处
|
### 教务处
|
||||||
|
|||||||
@@ -663,6 +663,7 @@ router.get('/cczu/news/:category?', require('./routes/universities/cczu/news'));
|
|||||||
router.get('/njust/jwc/:type', require('./routes/universities/njust/jwc'));
|
router.get('/njust/jwc/:type', require('./routes/universities/njust/jwc'));
|
||||||
router.get('/njust/cwc/:type', require('./routes/universities/njust/cwc'));
|
router.get('/njust/cwc/:type', require('./routes/universities/njust/cwc'));
|
||||||
router.get('/njust/gs/:type', require('./routes/universities/njust/gs'));
|
router.get('/njust/gs/:type', require('./routes/universities/njust/gs'));
|
||||||
|
router.get('/njust/eo/:grade?/:type?', require('./routes/universities/njust/eo'));
|
||||||
|
|
||||||
// 四川旅游学院
|
// 四川旅游学院
|
||||||
router.get('/sctu/xgxy', require('./routes/universities/sctu/information-engineer-faculty/index'));
|
router.get('/sctu/xgxy', require('./routes/universities/sctu/information-engineer-faculty/index'));
|
||||||
|
|||||||
50
lib/routes/universities/njust/eo/index.js
Normal file
50
lib/routes/universities/njust/eo/index.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
const date = require('@/utils/date');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { getContent } = require('@/routes/universities/njust/eo/util');
|
||||||
|
|
||||||
|
const map = new Map([
|
||||||
|
['16tz', { title: '南京理工大学电光16 -- 通知公告', id: '/_t217/tzgg/list.htm' }],
|
||||||
|
['16dt', { title: '南京理工大学电光16 -- 主任寄语', id: '/_t217/zrjy/list.htm' }],
|
||||||
|
['17tz', { title: '南京理工大学电光17 -- 年级通知', id: '/_t689/njtz/list.htm' }],
|
||||||
|
['17dt', { title: '南京理工大学电光17 -- 每日动态', id: '/_t689/mrdt/list.htm' }],
|
||||||
|
['18tz', { title: '南京理工大学电光18 -- 年级通知', id: '/_t900/njtz_10234/list.htm' }],
|
||||||
|
['18dt', { title: '南京理工大学电光18 -- 主任寄语', id: '/_t900/zrjy_10251/list.htm' }],
|
||||||
|
['19tz', { title: '南京理工大学电光19 -- 通知公告', id: '/_t1163/tzgg_11606/list.htm' }],
|
||||||
|
['19dt', { title: '南京理工大学电光19 -- 每日动态', id: '/_t1163/mrdt_11608/list.htm' }],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const baseUrl = 'http://dgxg.njust.edu.cn';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const grade = ctx.params.grade || '17';
|
||||||
|
const type = ctx.params.type || 'tz';
|
||||||
|
const category = grade + type;
|
||||||
|
const id = map.get(category).id;
|
||||||
|
|
||||||
|
const html = await getContent(baseUrl + id);
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
const list = $('li.list_item');
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: map.get(category).title,
|
||||||
|
link: baseUrl + '/' + id.split('/')[1] + '/main.htm',
|
||||||
|
item:
|
||||||
|
list &&
|
||||||
|
list
|
||||||
|
.map((index, item) => ({
|
||||||
|
title: $(item)
|
||||||
|
.find('a')
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
pubDate: date(
|
||||||
|
$(item)
|
||||||
|
.find('span.Article_PublishDate')
|
||||||
|
.text()
|
||||||
|
),
|
||||||
|
link: $(item)
|
||||||
|
.find('a')
|
||||||
|
.attr('href'),
|
||||||
|
}))
|
||||||
|
.get(),
|
||||||
|
};
|
||||||
|
};
|
||||||
28
lib/routes/universities/njust/eo/util.js
Normal file
28
lib/routes/universities/njust/eo/util.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const delay = (timeout = 1000) => new Promise((resolve) => setTimeout(resolve, timeout));
|
||||||
|
|
||||||
|
async function getContent(url) {
|
||||||
|
const browser = await require('@/utils/puppeteer')();
|
||||||
|
try {
|
||||||
|
const page = await browser.newPage();
|
||||||
|
page.waitForNavigation({
|
||||||
|
timeout: 20000,
|
||||||
|
});
|
||||||
|
// 更改 window.navigator.webdriver 值以避开反爬
|
||||||
|
await page.evaluateOnNewDocument(() => {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
Object.defineProperty(navigator, 'webdriver', {
|
||||||
|
get: () => undefined,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await page.goto(url);
|
||||||
|
await delay(1000);
|
||||||
|
const content = await page.content();
|
||||||
|
return content;
|
||||||
|
} finally {
|
||||||
|
browser.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getContent,
|
||||||
|
};
|
||||||
@@ -1,40 +1,42 @@
|
|||||||
const got = require('@/utils/got');
|
const date = require('@/utils/date');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
const { getContent } = require('@/routes/universities/njust/eo/util');
|
||||||
|
|
||||||
const map = new Map([
|
const map = new Map([
|
||||||
[1, { title: '南京理工大学研究生院 -- 通知公告', id: '/sytzgg_4568' }],
|
[1, { title: '南京理工大学研究生院 -- 通知公告', id: '/sytzgg_4568' }],
|
||||||
[2, { title: '南京理工大学研究生院 -- 学术公告', id: '/xshdggl' }],
|
[2, { title: '南京理工大学研究生院 -- 学术公告', id: '/xshdggl' }],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const baseUrl = 'http://gs.njust.edu.cn';
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const type = Number.parseInt(ctx.params.type);
|
const type = Number.parseInt(ctx.params.type);
|
||||||
const id = map.get(type).id;
|
const id = map.get(type).id;
|
||||||
const baseUrl = 'http://gs.njust.edu.cn';
|
|
||||||
const res = await got({
|
const html = await getContent(baseUrl + id + '/list.htm');
|
||||||
method: 'get',
|
const $ = cheerio.load(html);
|
||||||
url: baseUrl + id + '/list.htm',
|
const list = $('li.list_item');
|
||||||
headers: {
|
|
||||||
Referer: 'https://gs.njust.edu.cn/',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const $ = cheerio.load(res.data);
|
|
||||||
const list = $('.wp_article_list li').slice(0, 10);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: map.get(type).title,
|
title: map.get(type).title,
|
||||||
link: 'https://gs.njust.edu.cn',
|
link: 'http://gs.njust.edu.cn',
|
||||||
item:
|
item:
|
||||||
list &&
|
list &&
|
||||||
list
|
list
|
||||||
.map((index, item) => {
|
.map((index, item) => ({
|
||||||
item = $(item);
|
title: $(item)
|
||||||
|
.find('a')
|
||||||
return {
|
.text()
|
||||||
title: item.find('a').text(),
|
.trim(),
|
||||||
link: `${baseUrl + $(item.find('a')).attr('href')}`,
|
pubDate: date(
|
||||||
pubDate: new Date(item.find('.Article_PublishDate').text()).toUTCString(),
|
$(item)
|
||||||
};
|
.find('span.Article_PublishDate')
|
||||||
})
|
.text()
|
||||||
|
),
|
||||||
|
link: $(item)
|
||||||
|
.find('a')
|
||||||
|
.attr('href'),
|
||||||
|
}))
|
||||||
.get(),
|
.get(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user