diff --git a/docs/university.md b/docs/university.md index c19ac4135..431fa6127 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1274,13 +1274,13 @@ category 列表: ## 哈尔滨工业大学(深圳) -### 哈尔滨工业大学(深圳) - 新闻中心 +### 新闻中心 - + -| 校区要闻 | 媒体报道 | 通知公告 | 综合新闻 | 校园动态 | 讲座论坛 | 热点专题 | -| ------ | ----- | ----- | ----- | ----- | ----- | ----- | -| id-116 | id-80 | id-74 | id-75 | id-77 | id-78 | id-79 | +| 校区要闻 | 媒体报道 | 综合新闻 | 校园动态 | 讲座论坛 | 热点专题 | 招标信息 | 重要关注 | +| ------ | ----- | ----- | ----- | ----- | ----- | ----- | ------ | +| id-116 | id-80 | id-75 | id-77 | id-78 | id-79 | id-81 | id-124 | diff --git a/lib/router.js b/lib/router.js index 0641a8b14..36c893fc5 100644 --- a/lib/router.js +++ b/lib/router.js @@ -531,7 +531,7 @@ router.get('/hhu/libNewsc', lazyloadRouteHandler('./routes/universities/hhu/libN // router.get('/hit/today/:category', lazyloadRouteHandler('./routes/universities/hit/today')); // 哈尔滨工业大学(深圳) -router.get('/hitsz/article/:category?', lazyloadRouteHandler('./routes/universities/hitsz/article')); +// router.get('/hitsz/article/:category?', lazyloadRouteHandler('./routes/universities/hitsz/article')); // 哈尔滨工业大学(威海) // router.get('/hitwh/today', lazyloadRouteHandler('./routes/universities/hitwh/today')); diff --git a/lib/routes/universities/hitsz/article.js b/lib/v2/hitsz/article.js similarity index 54% rename from lib/routes/universities/hitsz/article.js rename to lib/v2/hitsz/article.js index 5f7e30750..dd770d30b 100644 --- a/lib/routes/universities/hitsz/article.js +++ b/lib/v2/hitsz/article.js @@ -1,34 +1,32 @@ 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 host = 'http://www.hitsz.edu.cn'; - const category = ctx.params.category || 'id-74'; + const host = 'https://www.hitsz.edu.cn'; + const category = ctx.params.category ?? 'id-77'; + const link = `${host}/article/${category}.html`; - const response = await got.get(`${host}/article/${category}.html`); + const response = await got(link); const $ = cheerio.load(response.data); const category_name = $('div.title_page').text().trim(); const lists = $('.mainside_news ul li') - .map((_, el) => ({ + .toArray() + .map((el) => ({ title: $('a', el).text().trim(), link: `${host}${$('a', el).attr('href')}`, - pubDate: new Date($('span[class=date]', el).text()).toUTCString(), - })) - .get(); + pubDate: timezone(parseDate($('span[class=date]', el).text()), 8), + })); const items = await Promise.all( lists.map((item) => ctx.cache.tryGet(item.link, async () => { const response = await got.get(item.link); const $ = cheerio.load(response.data); - item.description = - $('div.detail').html() && - $('div.detail') - .html() - .replace(/src="\//g, `src="${new URL('.', host).toString()}"`) - .replace(/href="\//g, `href="${new URL('.', host).toString()}"`) - .trim(); + item.description = $('div.edittext').html().trim(); + item.pubDate = timezone(parseDate($('.item').first().text().replace('发布时间:', '')), 8); return item; }) ) @@ -36,7 +34,7 @@ module.exports = async (ctx) => { ctx.state.data = { title: '哈尔滨工业大学(深圳)-' + category_name, - link: `${host}/article/${category}.html`, + link, description: '哈尔滨工业大学(深圳)-' + category_name, item: items, }; diff --git a/lib/v2/hitsz/maintainer.js b/lib/v2/hitsz/maintainer.js new file mode 100644 index 000000000..a6d59e9c4 --- /dev/null +++ b/lib/v2/hitsz/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/article/:category?': ['xandery-geek'], +}; diff --git a/lib/v2/hitsz/radar.js b/lib/v2/hitsz/radar.js new file mode 100644 index 000000000..f7b82eb4d --- /dev/null +++ b/lib/v2/hitsz/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'hitsz.edu.cn': { + _name: '哈尔滨工业大学(深圳)', + '.': [ + { + title: '新闻中心', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-ye-da-xue-shen-zhen', + source: ['/article/:category?', '/subject/:category?'], + target: (params) => `/hitsz/article/${params.category.replace('.html', '')}`, + }, + ], + }, +}; diff --git a/lib/v2/hitsz/router.js b/lib/v2/hitsz/router.js new file mode 100644 index 000000000..f66c30589 --- /dev/null +++ b/lib/v2/hitsz/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/article/:category?', require('./article')); +};