mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: add 中国人事考试网通知公告 (#4691)
This commit is contained in:
@@ -281,3 +281,9 @@ pageClass: routes
|
||||
### 最新
|
||||
|
||||
<Route author="xyqfer" example="/icourse163/newest" path="/icourse163/newest" />
|
||||
|
||||
## 中国人事考试网
|
||||
|
||||
### 通知公告
|
||||
|
||||
<Route author="nczitzk" example="/cpta/notice" path="/cpta/notice" />
|
||||
|
||||
@@ -2644,6 +2644,9 @@ router.get('/slu/csggxy/:id', require('./routes/universities/slu/csggxy'));
|
||||
router.get('/ruby-china/topics/:type?', require('./routes/ruby-china/topics'));
|
||||
router.get('/ruby-china/jobs', require('./routes/ruby-china/jobs'));
|
||||
|
||||
// 中国人事考试网
|
||||
router.get('/cpta/notice', require('./routes/cpta/notice'));
|
||||
|
||||
// 广告网
|
||||
router.get('/adquan/:type?', require('./routes/adquan/index'));
|
||||
|
||||
|
||||
37
lib/routes/cpta/notice.js
Normal file
37
lib/routes/cpta/notice.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `http://www.cpta.com.cn/GB/360339/index.html`;
|
||||
const response = await got({ method: 'get', url: link, responseType: 'buffer' });
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||
const list = $('ul.list_14 li')
|
||||
.map((_, item) => {
|
||||
item = $(item).find('a');
|
||||
return {
|
||||
title: item.text(),
|
||||
link: url.resolve(`http://www.cpta.com.cn/`, item.attr('href')),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中国人事考试网 - 通知公告',
|
||||
link: link,
|
||||
item: await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({ method: 'get', url: item.link, responseType: 'buffer' });
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
item.description = content('div.text').html();
|
||||
item.pubDate = new Date(content('#p_publishtime').text().replace(/[年|月]/g, '-').replace(/日/g, ' ') + ' GMT+8').toUTCString();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user