Skip to content

Commit

Permalink
Merge pull request #810 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Feb 14, 2023
2 parents dda2a04 + 022a947 commit 62cc1d6
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 54 deletions.
2 changes: 2 additions & 0 deletions docs/en/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pageClass: routes

## 591 Rental house

### Rental house

<RouteEn author="Yukaii" example="/591/tw/rent/order=posttime&orderType=desc" path="/591/:country/rent/:query?" :paramsDesc="['Country code. Only tw is supported now', 'Query Parameters']">

::: tip Tip
Expand Down
2 changes: 2 additions & 0 deletions docs/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pageClass: routes

## 591 租屋網

### 租屋

<Route author="Yukaii" example="/591/tw/rent/order=posttime&orderType=desc" path="/591/:country/rent/:query?" :paramsDesc="['網址國碼,目前僅支援 tw', '查詢參數']">

::: tip 提示
Expand Down
10 changes: 5 additions & 5 deletions docs/university.md
Original file line number Diff line number Diff line change
Expand Up @@ -1274,13 +1274,13 @@ category 列表:

## 哈尔滨工业大学(深圳)

### 哈尔滨工业大学(深圳) - 新闻中心
### 新闻中心

<Route author="xandery-geek" example="/hitsz/article/id-74" path="/hitsz/article/:category?" :paramsDesc="['分类名,默认为通知公告']" >
<Route author="xandery-geek" example="/hitsz/article/id-74" path="/hitsz/article/:category?" :paramsDesc="['分类名,默认为校园动态']" radar="1">

| 校区要闻 | 媒体报道 | 通知公告 | 综合新闻 | 校园动态 | 讲座论坛 | 热点专题 |
| ------ | ----- | ----- | ----- | ----- | ----- | ----- |
| 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 |

</Route>

Expand Down
2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
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;
})
)
);

ctx.state.data = {
title: '哈尔滨工业大学(深圳)-' + category_name,
link: `${host}/article/${category}.html`,
link,
description: '哈尔滨工业大学(深圳)-' + category_name,
item: items,
};
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/hitsz/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/article/:category?': ['xandery-geek'],
};
13 changes: 13 additions & 0 deletions lib/v2/hitsz/radar.js
Original file line number Diff line number Diff line change
@@ -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', '')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/hitsz/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/article/:category?', require('./article'));
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"dependencies": {
"@koa/router": "12.0.0",
"@postlight/parser": "2.2.3",
"@sentry/node": "7.37.1",
"@sentry/node": "7.37.2",
"aes-js": "3.1.2",
"art-template": "4.13.2",
"bbcodejs": "0.0.4",
Expand All @@ -112,7 +112,7 @@
"https-proxy-agent": "5.0.1",
"iconv-lite": "0.6.3",
"instagram-private-api": "1.45.3",
"ioredis": "5.3.0",
"ioredis": "5.3.1",
"ip-regex": "4.3.0",
"is-localhost-ip": "2.0.0",
"jsdom": "21.1.0",
Expand All @@ -135,7 +135,7 @@
"puppeteer-extra": "3.3.4",
"puppeteer-extra-plugin-stealth": "2.11.1",
"query-string": "7.1.3",
"rand-user-agent": "1.0.104",
"rand-user-agent": "1.0.105",
"re2": "1.18.0",
"require-all": "3.0.0",
"rss-parser": "3.12.0",
Expand Down
60 changes: 30 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1557,39 +1557,39 @@
domhandler "^5.0.3"
selderee "^0.10.0"

"@sentry/core@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.37.1.tgz#6d8d151b3d6ae0d6f81c7f4da92cd2e7cb5bf1fa"
integrity sha512-eS5hoFDjAOl7POZg6K77J0oiypiqR1782oVSB49UkjK+D8tCZzZ5PxPMv0b/O0310p7x4oZ3WGRJaWEN3vY4KQ==
"@sentry/core@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.37.2.tgz#959b2bf953f442b07f8377d90f4f7735cf260ae4"
integrity sha512-LjofMDSTyVeBErl9N7TTqlyEVuW1g6U4iuJtdZ75JohnvVxzWdpZfWfddwQ6h7nGWfe9dNg0fGs1wxKtMhY+MA==
dependencies:
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"
tslib "^1.9.3"

"@sentry/node@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.37.1.tgz#c234e8711090b7532358bb1d6ab3fcca75356e98"
integrity sha512-nGerngIo5JwinJgl7m0SaL/xI+YRBlhb53gbkuLSAAcnoitBFzbp7LjywsqYFTWuWDIyk7O2t124GNxtolBAgA==
"@sentry/node@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.37.2.tgz#7ce3b09c93112afca0eef0fd65ec87ea1cd1b7d2"
integrity sha512-aeJQ4oU3vF9zks8S/fvoLPVVhofmTjyMhZZIpSQWtfFqWxrXQsrqNlNUZZdXoqAUPNjA4QAzzOoXHhpUsa3Nxw==
dependencies:
"@sentry/core" "7.37.1"
"@sentry/types" "7.37.1"
"@sentry/utils" "7.37.1"
"@sentry/core" "7.37.2"
"@sentry/types" "7.37.2"
"@sentry/utils" "7.37.2"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/types@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.37.1.tgz#269da7da39c1a5243bf5f9a35370291b5cc205bb"
integrity sha512-c2HWyWSgVA0V4+DSW2qVb0yjftrb1X/q2CzCom+ayjGHO72qyWC+9Tc+7ZfotU1mapRjqUWBgkXkbGmao8N8Ug==
"@sentry/types@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.37.2.tgz#99fd76230d7c1d3c6901ed4c0bea35be7d6fe26d"
integrity sha512-SxKQOCX94ZaQM4C2ysNjHdJsjYapu/NYZCz1cnPyCdDvYfhwiVge1uq6ZHiQ/ARfxAAOmc3R4Mh3VvEz7WUOdw==

"@sentry/utils@7.37.1":
version "7.37.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.37.1.tgz#7695d6e30d6178723f3fa446a9553893bca85e96"
integrity sha512-/4mJOyDsfysx+5TXyJgSI+Ihw2/0EVJbrHjCyXPDXW5ADwbtU8VdBZ0unOmF0hk4QfftqwM9cyEu3BN4iBJsEA==
"@sentry/utils@7.37.2":
version "7.37.2"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.37.2.tgz#14dea644454e3df247fb113fc834f509c1f0e48c"
integrity sha512-5irN1nN/mtdOoWwsJiwBK0gPgNMkciUubEMbCaaXqJaGyGz8+yfDvXj7L+xGYiU57z+7+QkkSKxKEZ/IcBpjVQ==
dependencies:
"@sentry/types" "7.37.1"
"@sentry/types" "7.37.2"
tslib "^1.9.3"

"@sinclair/typebox@^0.25.16":
Expand Down Expand Up @@ -7613,10 +7613,10 @@ interpret@^1.0.0:
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==

ioredis@5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-5.3.0.tgz#b5469f0fd374648ef074840c00c1d8eed42fca3f"
integrity sha512-Id9jKHhsILuIZpHc61QkagfVdUj2Rag5GzG1TGEvRNeM7dtTOjICgjC+tvqYxi//PuX2wjQ+Xjva2ONBuf92Pw==
ioredis@5.3.1:
version "5.3.1"
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-5.3.1.tgz#55d394a51258cee3af9e96c21c863b1a97bf951f"
integrity sha512-C+IBcMysM6v52pTLItYMeV4Hz7uriGtoJdz7SSBDX6u+zwSYGirLdQh3L7t/OItWITcw3gTFMjJReYUwS4zihg==
dependencies:
"@ioredis/commands" "^1.1.1"
cluster-key-slot "^1.1.0"
Expand Down Expand Up @@ -11667,10 +11667,10 @@ ramda@^0.26.1:
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.26.1.tgz#8d41351eb8111c55353617fc3bbffad8e4d35d06"
integrity sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==

rand-user-agent@1.0.104:
version "1.0.104"
resolved "https://registry.yarnpkg.com/rand-user-agent/-/rand-user-agent-1.0.104.tgz#c2fbae69f458637a0e93c127239366aacdc5e3e2"
integrity sha512-iYQIzNbTFZxz4/ygG0dBpWt1PyZhqOIMfXIFQ4e8B6Uml1BZ/za1v6GRv1wGcnTHwiCGTx+NvxgFe25qSNBAWQ==
rand-user-agent@1.0.105:
version "1.0.105"
resolved "https://registry.yarnpkg.com/rand-user-agent/-/rand-user-agent-1.0.105.tgz#d4e171ebd6e8967c04b4db10fd701a6341a99b6c"
integrity sha512-fNIvgkrJ7bTU2P/fGVTOMFPxFLePK+erbwHu86PR889eXx+KJZolMylTAQEvYHCLP8tDN2T7W1foCV7ZRv2PxQ==

randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
version "2.1.0"
Expand Down

1 comment on commit 62cc1d6

@vercel
Copy link

@vercel vercel bot commented on 62cc1d6 Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.