feat(route): add 杭州电子科技大学 计算机学院 通知 (#8780)

* add hdu cs route

* add hdu cs route document

* add hdu cs radar rules

* add rssbud support

* trun to V2

* trun to V2

* (fix) hdu route cs spell check

* (add) hdu cs route add maintainer

* (fix) hdu cs route remove UA

* (fix) hdu cs route link concatenated approve

* (fix) hdu cs route add cache

* (fix) hdu cs route title fix

* (fix) hdu cs remove request header params

* fix: cached results

* fix: radar.js

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
Yuri Kiriyama 2022-03-03 22:46:39 +08:00 committed by GitHub
parent 99b50faa40
commit fee75c662e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 0 deletions

View File

@ -980,6 +980,12 @@ category 列表:
<Route author="OdinZhang" example="/hainanu/ssszs" path="hainanu/ssszs"/>
## 杭州电子科技大学
### 计算机学院 - 通知公告
<Route author="legr4ndk" example="/hdu/cs" path="/hdu/cs" radar="1" rssbud="1"/>
## 合肥工业大学
### 通知公告

57
lib/v2/hdu/cs/index.js Normal file
View File

@ -0,0 +1,57 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const link = 'https://computer.hdu.edu.cn';
const host = 'https://computer.hdu.edu.cn/6738/list.htm';
const getSingleRecord = async () => {
const res = await got({
method: 'get',
url: host,
});
const $ = cheerio.load(res.data);
const list = $('.posts-list').find('li');
return (
list &&
list
.map((index, item) => {
item = $(item);
const dateTxt = item.find('.date').text();
const date = dateTxt.slice(1, dateTxt.length - 1);
return {
title: item.find('a').text(),
pubDate: parseDate(date),
link: link + item.find('a').attr('href'),
};
})
.get()
);
};
module.exports = async (ctx) => {
const items = await getSingleRecord();
const out = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
return {
title: item.title,
link: item.link,
description: $('.wp_articlecontent').html(),
pubDate: item.pubDate,
};
})
)
);
ctx.state.data = {
title: '杭电计算机-通知公告',
description: '杭州电子科技大学计算机学院-通知公告',
link: host,
item: out,
};
};

3
lib/v2/hdu/maintainer.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
'/cs': ['legr4ndk'],
};

13
lib/v2/hdu/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'hdu.edu.cn': {
_name: '杭州电子科技大学',
computer: [
{
title: '计算机学院 - 通知公告',
docs: 'https://docs.rsshub.app/university.html#hang-zhou-dian-zi-ke-ji-da-xue',
source: '/6738/list.htm',
target: '/hdu/cs',
},
],
},
};

4
lib/v2/hdu/router.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = function (router) {
// 杭州电子科技大学
router.get('/cs', require('./cs'));
};