feat(route): add 西安交通大学电气学院官网路由 (#7876)
This commit is contained in:
parent
ec40eaab74
commit
de03bc750d
|
|
@ -1940,6 +1940,10 @@ type 列表:
|
|||
| -------- | -------------- | ------------ | -------- | ---------- |
|
||||
| zxtg | xdsgwy | gjzzsx | xwzx | hdyjz |
|
||||
|
||||
### 电气学院
|
||||
|
||||
<Route author="DylanXie123" example="/xjtu/ee/1114" path="/xjtu/job/:id?" :paramsDesc="['栏目id,默认请求`1114`,可在 URL 中找到']" />
|
||||
|
||||
## 西北工业大学
|
||||
|
||||
### 翱翔门户
|
||||
|
|
|
|||
|
|
@ -2656,6 +2656,7 @@ router.get('/xjtu/gs/tzgg', require('./routes/universities/xjtu/gs/tzgg'));
|
|||
router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean'));
|
||||
router.get('/xjtu/international/:subpath+', require('./routes/universities/xjtu/international'));
|
||||
router.get('/xjtu/job/:subpath?', require('./routes/universities/xjtu/job'));
|
||||
router.get('/xjtu/ee/:id?', require('./routes/universities/xjtu/ee'));
|
||||
|
||||
// booksource
|
||||
router.get('/booksource', require('./routes/booksource/index'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id || '1124';
|
||||
const rootUrl = `http://ee.xjtu.edu.cn/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=${id}`;
|
||||
const baseUrl = 'http://ee.xjtu.edu.cn';
|
||||
|
||||
const list_response = await got.get(rootUrl);
|
||||
const $ = cheerio.load(list_response.data);
|
||||
|
||||
const feed_title = $('span.windowstyle67278', "div[class='list_right fr']").text().trim();
|
||||
|
||||
const list = $("div[class='list_right fr'] ul li")
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
const date = parseDate(item.find('span').text());
|
||||
return {
|
||||
title: a.text(),
|
||||
link: new URL(a.attr('href'), baseUrl),
|
||||
pubDate: timezone(date, +8),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `西安交通大学电气学院 - ${feed_title}`,
|
||||
link: baseUrl,
|
||||
item: await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got.get(item.link);
|
||||
const content = cheerio.load(res.data);
|
||||
item.description = content('td.contentstyle67362', 'form').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue