mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-14 17:19:37 +08:00
feat(route): add 德阳考试中心 (#7901)
This commit is contained in:
@@ -713,3 +713,15 @@ pageClass: routes
|
|||||||
### 审查调查
|
### 审查调查
|
||||||
|
|
||||||
<Route author="LogicJake" example="/ccdi/scdc" path="/ccdi/scdc"/>
|
<Route author="LogicJake" example="/ccdi/scdc" path="/ccdi/scdc"/>
|
||||||
|
|
||||||
|
## 德阳考试中心
|
||||||
|
|
||||||
|
### 考试新闻
|
||||||
|
|
||||||
|
<Route author="zytomorrow" example="/dykszx/news" path="/dykszx/news/:type?" :paramsDesc="['考试类型。']">
|
||||||
|
|
||||||
|
| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 |
|
||||||
|
| :------: | :------: | :------: |:------: |:------: |
|
||||||
|
| all | gwy | sydw | zyzc | other |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|||||||
@@ -4224,4 +4224,7 @@ router.get('/odaily/activity', require('./routes/odaily/activity'));
|
|||||||
// Fashion Network
|
// Fashion Network
|
||||||
router.get('/fashionnetwork/news/:sectors?/:categories?/:language?', require('./routes/fashionnetwork/news.js'));
|
router.get('/fashionnetwork/news/:sectors?/:categories?/:language?', require('./routes/fashionnetwork/news.js'));
|
||||||
|
|
||||||
|
// dykszx
|
||||||
|
router.get('/dykszx/news/:type?', require('./routes/dykszx/news'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
57
lib/routes/dykszx/news.js
Normal file
57
lib/routes/dykszx/news.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const host = 'https://www.dykszx.com';
|
||||||
|
|
||||||
|
const getContent = (href, caches) => {
|
||||||
|
const newsPage = `${host}${href}`;
|
||||||
|
return caches.tryGet(newsPage, async () => {
|
||||||
|
const response = await got.get(newsPage);
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const newsTime = $('body > div:nth-child(3) > div.page.w > div.shuxing.w')
|
||||||
|
.text()
|
||||||
|
.trim()
|
||||||
|
.match(/时间:(.*?)点击/g)[0];
|
||||||
|
// 移除二维码
|
||||||
|
$('.sjlook').remove();
|
||||||
|
const content = $('#show-body').html();
|
||||||
|
return { newsTime, content, newsPage };
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const newsTypeObj = {
|
||||||
|
all: { selector: '#nrs > li > b', name: '新闻中心' },
|
||||||
|
gwy: { selector: 'body > div:nth-child(3) > div:nth-child(8) > ul > li', name: '公务员考试' },
|
||||||
|
sydw: { selector: 'body > div:nth-child(3) > div:nth-child(9) > ul > li', name: '事业单位考试' },
|
||||||
|
zyzc: { selector: 'body > div:nth-child(3) > div:nth-child(10) > ul > li', name: '执(职)业资格、职称考试' },
|
||||||
|
other: { selector: 'body > div:nth-child(3) > div:nth-child(11) > ul > li', name: '其他考试' },
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const newsType = ctx.params.type || 'all';
|
||||||
|
const response = await got.get(host);
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const newsList = $(newsTypeObj[newsType].selector).toArray();
|
||||||
|
|
||||||
|
const newsDetail = await Promise.all(
|
||||||
|
newsList.map(async (item) => {
|
||||||
|
const href = item.children[0].attribs.href;
|
||||||
|
const newsContent = await getContent(href, ctx.cache);
|
||||||
|
return {
|
||||||
|
title: item.children[0].children[0].data,
|
||||||
|
description: newsContent.content,
|
||||||
|
link: newsContent.newsPage,
|
||||||
|
pubDate: timezone(parseDate(newsContent.newsTime, '时间:YYYY-MM-DD HH:mm:ss'), +8),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `德阳人事考试网 - ${newsTypeObj[newsType].name}`,
|
||||||
|
link: host,
|
||||||
|
description: '德阳人事考试网 考试新闻发布',
|
||||||
|
item: newsDetail,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user