forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(routes/hrbust): add 'cs' 'gzc' 'lib' routes, unified code style (D…
- Loading branch information
Showing
6 changed files
with
316 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Route, ViewType } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import { load } from 'cheerio'; | ||
import { ofetch } from 'ofetch'; | ||
|
||
export const route: Route = { | ||
path: '/cs/:category?', | ||
name: '计算机学院', | ||
url: 'cs.hrbust.edu.cn', | ||
maintainers: ['cscnk52'], | ||
handler, | ||
example: '/hrbust/cs', | ||
parameters: { category: '栏目标识,默认为 3709(学院要闻)' }, | ||
description: `| 通知公告 | 学院要闻 | 常用下载 | 博士后流动站 | 学生指导 | 科研动态 | 科技成果 | 党建理论 | 党建学习 | 党建活动 | 党建风采 | 团学组织 | 学生党建 | 学生活动 | 心理健康 | 青春榜样 | 就业工作 | 校友风采 | 校庆专栏 | 专业介绍 | 本科生培养方案 | 硕士生培养方案 | 能力作风建设 | 博士生培养方案 | 省级实验教学示范中心 | 喜迎二十大系列活动 | 学习贯彻省十三次党代会精神 | | ||
|----------|----------|----------|--------------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------------|----------------|--------------|----------------|----------------------|--------------------|----------------------------| | ||
| 3708 | 3709 | 3710 | 3725 | 3729 | 3732 | 3733 | 3740 | 3741 | 3742 | 3743 | 3744 | 3745 | 3746 | 3747 | 3748 | 3751 | 3752 | 3753 | 3755 | 3756 | 3759 | nlzfjs | pyfa | sjsyjxsfzx | srxxgcddesdjs | xxgcssscddhjs |`, | ||
categories: ['university'], | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
supportRadar: true, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['cs.hrbust.edu.cn/:category/list.htm'], | ||
target: '/cs/:category', | ||
}, | ||
{ | ||
source: ['cs.hrbust.edu.cn'], | ||
target: '/cs', | ||
}, | ||
], | ||
view: ViewType.Notifications, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const rootUrl = 'https://cs.hrbust.edu.cn/'; | ||
const { category = 3709 } = ctx.req.param(); | ||
const columnUrl = `${rootUrl}${category}/list.htm`; | ||
const response = await ofetch(columnUrl); | ||
const $ = load(response); | ||
const bigTitle = $('li.col_title').text(); | ||
|
||
const list = $('div.col_news_con li.news') | ||
.toArray() | ||
.map((item) => { | ||
const element = $(item); | ||
const link = new URL(element.find('a').attr('href'), rootUrl).href; | ||
const pubDateText = element.find('span.news_meta').text().trim(); | ||
const pubDate = pubDateText ? timezone(parseDate(pubDateText), +8) : null; | ||
return { | ||
title: element.find('a').text().trim(), | ||
pubDate, | ||
link, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
if (!item.link.startsWith(rootUrl)) { | ||
item.description = '本文需跳转,请点击原文链接后阅读'; | ||
return item; | ||
} | ||
|
||
const response = await ofetch(item.link); | ||
const $ = load(response); | ||
const content = $('div.wp_articlecontent'); | ||
|
||
content.find('[style]').removeAttr('style'); | ||
content.find('font').contents().unwrap(); | ||
content.html(content.html()?.replaceAll(' ', '')); | ||
content.find('[align]').removeAttr('align'); | ||
|
||
const author = $('span.arti_publisher').text().replace('发布者:', '').trim(); | ||
|
||
return { | ||
title: item.title, | ||
link: item.link, | ||
pubDate: item.pubDate, | ||
description: content.html(), | ||
author, | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: `${bigTitle} - 哈尔滨理工大学计算机学院`, | ||
link: columnUrl, | ||
language: 'zh-CN', | ||
item: items, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { Route, ViewType } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import { load } from 'cheerio'; | ||
import { ofetch } from 'ofetch'; | ||
|
||
export const route: Route = { | ||
path: '/gzc/:category?', | ||
name: '国有资产管理处', | ||
url: 'gzc.hrbust.edu.cn', | ||
maintainers: ['cscnk52'], | ||
handler, | ||
example: '/hrbust/gzc', | ||
parameters: { category: '栏目标识,默认为 1305(热点新闻)' }, | ||
description: `| 政策规章 | 资料下载 | 处务公开 | 招标信息 | 岗位职责 | 管理办法 | 物资处理 | 工作动态 | 热点新闻 | | ||
|----------|----------|----------|----------|----------|----------|----------|----------|----------| | ||
| 1287 | 1288 | 1289 | 1291 | 1300 | 1301 | 1302 | 1304 | 1305 |`, | ||
categories: ['university'], | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
supportRadar: true, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['gzc.hrbust.edu.cn/:category/list.htm'], | ||
target: '/gzc/:category', | ||
}, | ||
{ | ||
source: ['gzc.hrbust.edu.cn'], | ||
target: '/gzc', | ||
}, | ||
], | ||
view: ViewType.Notifications, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const rootUrl = 'https://gzc.hrbust.edu.cn/'; | ||
const { category = 1305 } = ctx.req.param(); | ||
const columnUrl = `${rootUrl}${category}/list.htm`; | ||
const response = await ofetch(columnUrl); | ||
const $ = load(response); | ||
const bigTitle = $('li.col-title').text(); | ||
|
||
const list = $('ul.wp_article_list li.list_item') | ||
.toArray() | ||
.map((item) => { | ||
const element = $(item); | ||
const link = new URL(element.find('a').attr('href'), rootUrl).href; | ||
const pubDateText = element.find('span.Article_PublishDate').text().trim(); | ||
const pubDate = pubDateText ? timezone(parseDate(pubDateText), +8) : null; | ||
return { | ||
title: element.find('a').text().trim(), | ||
pubDate, | ||
link, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
if (!item.link.startsWith(rootUrl)) { | ||
item.description = '本文需跳转,请点击原文链接后阅读'; | ||
return item; | ||
} | ||
|
||
const response = await ofetch(item.link); | ||
const $ = load(response); | ||
const content = $('div.wp_articlecontent'); | ||
|
||
content.find('[style]').removeAttr('style'); | ||
content.find('font').contents().unwrap(); | ||
content.html(content.html()?.replaceAll(' ', '')); | ||
content.find('[align]').removeAttr('align'); | ||
|
||
return { | ||
title: item.title, | ||
link: item.link, | ||
pubDate: item.pubDate, | ||
description: content.html(), | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: `${bigTitle} - 哈尔滨理工大学国有资产管理处`, | ||
link: columnUrl, | ||
language: 'zh-CN', | ||
item: items, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { Route, ViewType } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import timezone from '@/utils/timezone'; | ||
import { load } from 'cheerio'; | ||
import { ofetch } from 'ofetch'; | ||
|
||
export const route: Route = { | ||
path: '/lib/:category?', | ||
name: '图书馆', | ||
url: 'lib.hrbust.edu.cn', | ||
maintainers: ['cscnk52'], | ||
handler, | ||
example: '/hrbust/lib', | ||
parameters: { category: '栏目标识,默认为 3421(公告消息)' }, | ||
description: `| 公告消息 | 资源动态 | 参考中心 | 常用工具 | 外借服务 | 报告厅及研讨间服务 | 外文引进数据库 | 外文电子图书 | 外文试用数据库 | 中文引进数据库 | 中文电子图书 | 中文试用数据库 | | ||
|----------|----------|----------|----------|----------|--------------------|----------------|--------------|----------------|----------------|--------------|----------------| | ||
| 3421 | 3422 | ckzx | cygj | wjfw | ytjfw | yw | yw_3392 | yw_3395 | zw | zw_3391 | zw_3394 |`, | ||
categories: ['university'], | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
supportRadar: true, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['lib.hrbust.edu.cn/:category/list.htm'], | ||
target: '/lib/:category', | ||
}, | ||
{ | ||
source: ['lib.hrbust.edu.cn'], | ||
target: '/lib', | ||
}, | ||
], | ||
view: ViewType.Notifications, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const rootUrl = 'https://lib.hrbust.edu.cn/'; | ||
const { category = 3421 } = ctx.req.param(); | ||
const columnUrl = `${rootUrl}${category}/list.htm`; | ||
const response = await ofetch(columnUrl); | ||
const $ = load(response); | ||
const bigTitle = $('span.Column_Anchor').text(); | ||
|
||
const list = $('ul.tu_b3 li:not([class])') | ||
.toArray() | ||
.map((item) => { | ||
const element = $(item); | ||
const link = new URL(element.find('a').attr('href'), rootUrl).href; | ||
const pubDateText = element.find('span').text().trim(); | ||
const pubDate = pubDateText ? timezone(parseDate(pubDateText), +8) : null; | ||
return { | ||
title: element.find('a').text().trim(), | ||
pubDate, | ||
link, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
if (!item.link.startsWith(rootUrl)) { | ||
item.description = '本文需跳转,请点击原文链接后阅读'; | ||
return item; | ||
} | ||
|
||
const response = await ofetch(item.link); | ||
const $ = load(response); | ||
const content = $('div.wp_articlecontent'); | ||
|
||
content.find('[style]').removeAttr('style'); | ||
content.find('font').contents().unwrap(); | ||
content.html(content.html()?.replaceAll(' ', '')); | ||
content.find('[align]').removeAttr('align'); | ||
|
||
return { | ||
title: item.title, | ||
link: item.link, | ||
pubDate: item.pubDate, | ||
description: content.html(), | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: `${bigTitle} - 哈尔滨理工大学图书馆`, | ||
link: columnUrl, | ||
language: 'zh-CN', | ||
item: items, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.