fix(route): jseea (#11075)

* fix(route): jseea

* fix: docs anchor
This commit is contained in:
Tony 2022-10-13 16:07:17 +04:00 committed by GitHub
parent 9be1457ec8
commit 58aee4c315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 191 additions and 192 deletions

View File

@ -74,6 +74,18 @@ pageClass: routes
</Route>
## 北京市人民政府
### 北京教育考试院
<Route author="gavin-k" example="/gov/beijing/bjeea/bjeeagg" path="/gov/beijing/bjeea/:type" :paramsDesc="['分类名']">
| 通知公告 | 招考政策 | 自考快递 |
| :-----: | :--: | :--: |
| bjeeagg | zkzc | zkkd |
</Route>
## 北京市卫生健康委员会
### 新闻中心
@ -104,18 +116,6 @@ pageClass: routes
</Route>
## 德阳考试中心
### 考试新闻
<Route author="zytomorrow" example="/dykszx/news" path="/dykszx/news/:type?" :paramsDesc="['考试类型']">
| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 |
| :--: | :---: | :--: | :---------: | :---: |
| all | gwy | sydw | zyzc | other |
</Route>
## 德阳市人民政府
### 政府公开信息
@ -353,6 +353,26 @@ pageClass: routes
<Route author="XYenon" example="/gov/harbin/kjj" path="/gov/harbin/kjj"/>
## 河北省财政厅
<Route author="nczitzk" example="/gov/hebei/czt/xwdt" path="/gov/hebei/czt/xwdt/:category?" :paramsDesc="['分类,见下表,默认为财政动态']">
| 财政动态 | 综合新闻 | 通知公告 |
| ---- | ---- | ---- |
| gzdt | zhxw | tzgg |
</Route>
## 河北省退役军人事务厅
<Route author="SunShinenny" example="/gov/veterans/hebei/sxxx" path="/gov/veterans/hebei/:type" :paramsDesc="['分类名']">
| 省内信息 | 厅内信息 | 市县信息 |
| :--: | :--: | :--: |
| ywgz | tnxx | sxxx |
</Route>
## 湖北省软件行业协会
### 新闻中心
@ -368,6 +388,42 @@ pageClass: routes
</Route>
## 湖南省政府采购网
### 公告
<Route author="Jeason0228" example="/gov/hunan/notice/all" path="/gov/hunan/notice/:type" :paramsDesc="['all=全部cg=采购公告,zb=中标公告,fb=废标公告,ht=合同公告,gz=更正公告,zz=终止公告,qt=其他公告']" />
## 江苏省人民政府
### 动态
<Route author="ocleo1" example="/gov/province/jiangsu/important-news" path="/gov/province/jiangsu/:category" :paramsDesc="['分类名']">
| 省政府常务会议 | 要闻关注 | 部门资讯 | 市县动态 | 政策解读 |
| :---------------: | :------------: | :--------: | :---------: | :-------------------: |
| executive-meeting | important-news | department | city-county | policy-interpretation |
| 政府信息公开年度报告 | 政府信息公开制度 | 省政府及办公厅文件 | 规范性文件 |
| :-----------: | :-------------------: | :-----------: | :----------------: |
| annual-report | information-publicity | documentation | normative-document |
| 立法意见征集 | 意见征集 |
| :----------------------------: | :----------------: |
| legislative-opinion-collection | opinion-collection |
</Route>
### 省教育考试院 - 新闻中心
<Route author="schen1024" example="/jseea/news/zkyw" path="/gov/jiangsu/eea/:type?" :paramsDesc="['分类,默认为 `zkyw`,具体参数见下表']" radar="1" rssbud="1">
| 招考要闻 | 教育动态 | 招考信息 | 政策文件 | 院校动态 |
| :--: | :--: | :--: | :--: | :--: |
| zkyw | jydt | zkxx | zcwj | yxdt |
</Route>
## 联合国
### 安理会否决了决议
@ -436,6 +492,18 @@ pageClass: routes
<Route author="nczitzk" example="/cia/foia-annual-report" path="/cia/foia-annual-report"/>
## 南京市人民政府
### 信息公开
<Route author="ocleo1" example="/gov/city/nanjing/news" path="/gov/city/nanjing/:category" :paramsDesc="['分类名']">
| 南京信息 | 部门动态 | 各区动态 | 民生信息 |
| :--: | :--------: | :------: | :--------: |
| news | department | district | livelihood |
</Route>
## 全国哲学社会科学工作办公室
### 通用
@ -470,9 +538,21 @@ pageClass: routes
<Route author="sgqy" example="/go.jp/mofa" path="/go.jp/mofa"/>
## 西省人民政府
## 西省人民政府
### 陕西省科学技术厅
### 人社厅
<Route author="wolfyu1991" example="/gov/shanxi/rst/rsks-tzgg" path="/gov/shanxi/rst/:category" :paramsDesc="['分类名']">
| 通知公告 | 公务员考试 | 事业单位考试 | 专业技术人员资格考试 | 其他考试 |
| :-------: | :--------: | :---------: | :-------------: | :-------: |
| rsks-tzgg | rsks-gwyks | rsks-sydwks | rsks-zyjsryzgks | rsks-qtks |
</Route>
## 陕西省省人民政府
### 省科学技术厅
<Route author="nczitzk" example="/gov/shaanxi/kjt" path="/gov/shaanxi/kjt/:id?" :paramsDesc="['分类,见下表,默认为通知公告']">
@ -1005,98 +1085,6 @@ pageClass: routes
</Route>
### 北京市人民政府
#### 北京教育考试院
<Route author="gavin-k" example="/gov/beijing/bjeea/bjeeagg" path="/gov/beijing/bjeea/:type" :paramsDesc="['分类名']">
| 通知公告 | 招考政策 | 自考快递 |
| :-----: | :--: | :--: |
| bjeeagg | zkzc | zkkd |
</Route>
### 河北省财政厅
<Route author="nczitzk" example="/gov/hebei/czt/xwdt" path="/gov/hebei/czt/xwdt/:category?" :paramsDesc="['分类,见下表,默认为财政动态']">
| 财政动态 | 综合新闻 | 通知公告 |
| ---- | ---- | ---- |
| gzdt | zhxw | tzgg |
</Route>
### 河北省退役军人事务厅
<Route author="SunShinenny" example="/gov/veterans/hebei/sxxx" path="/gov/veterans/hebei/:type" :paramsDesc="['分类名']">
| 省内信息 | 厅内信息 | 市县信息 |
| :--: | :--: | :--: |
| ywgz | tnxx | sxxx |
</Route>
### 湖南省政府采购网 - 公告
<Route author="Jeason0228" example="/gov/hunan/notice/all" path="/gov/hunan/notice/:type" :paramsDesc="['all=全部cg=采购公告,zb=中标公告,fb=废标公告,ht=合同公告,gz=更正公告,zz=终止公告,qt=其他公告']" />
### 江苏省人民政府
<Route author="ocleo1" example="/gov/province/jiangsu/important-news" path="/gov/province/jiangsu/:category" :paramsDesc="['分类名']">
| 省政府常务会议 | 要闻关注 | 部门资讯 | 市县动态 | 政策解读 |
| :---------------: | :------------: | :--------: | :---------: | :-------------------: |
| executive-meeting | important-news | department | city-county | policy-interpretation |
| 政府信息公开年度报告 | 政府信息公开制度 | 省政府及办公厅文件 | 规范性文件 |
| :-----------: | :-------------------: | :-----------: | :----------------: |
| annual-report | information-publicity | documentation | normative-document |
| 立法意见征集 | 意见征集 |
| :----------------------------: | :----------------: |
| legislative-opinion-collection | opinion-collection |
</Route>
#### 江苏省教育考试院
<Route author="schen1024" example="/gov/jiangsu/eea/zcgd" path="/gov/jiangsu/eea/:type?" :paramsDesc="['分类, 默认为 `wdyw`, 具体参数见下表']">
注意:其他栏目的内容格式不兼容,且不便统一,此处只做了下标的栏目
| 具体栏目 | 参数 |
| :--: | :--: |
| 招考要闻 | zkyw |
| 政策规定 | zcgd |
| 招考信息 | zkxx |
| 招考资料 | zkzl |
| 学习交流 | xxjl |
</Route>
### 山西省人民政府
#### 山西省人社厅
<Route author="wolfyu1991" example="/gov/shanxi/rst/rsks-tzgg" path="/gov/shanxi/rst/:category" :paramsDesc="['分类名']">
| 通知公告 | 公务员考试 | 事业单位考试 | 专业技术人员资格考试 | 其他考试 |
| :-------: | :--------: | :---------: | :-------------: | :-------: |
| rsks-tzgg | rsks-gwyks | rsks-sydwks | rsks-zyjsryzgks | rsks-qtks |
</Route>
### 南京市人民政府
<Route author="ocleo1" example="/gov/city/nanjing/news" path="/gov/city/nanjing/:category" :paramsDesc="['分类名']">
| 南京信息 | 部门动态 | 各区动态 | 民生信息 |
| :--: | :--------: | :------: | :--------: |
| news | department | district | livelihood |
</Route>
## 中国驻外使领馆
### 大使馆重要通知

View File

@ -248,6 +248,18 @@ path="/ctfhub/upcoming/:limit?"
</Route>
## 德阳考试中心
### 考试新闻
<Route author="zytomorrow" example="/dykszx/news" path="/dykszx/news/:type?" :paramsDesc="['考试类型']">
| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 |
| :--: | :---: | :--: | :---------: | :---: |
| all | gwy | sydw | zyzc | other |
</Route>
## 东莞教研网
### 分类

View File

@ -1190,7 +1190,7 @@ router.get('/gov/suzhou/news/:uid', lazyloadRouteHandler('./routes/gov/suzhou/ne
router.get('/gov/suzhou/doc', lazyloadRouteHandler('./routes/gov/suzhou/doc'));
// 江苏
router.get('/gov/jiangsu/eea/:type?', lazyloadRouteHandler('./routes/gov/jiangsu/eea'));
// router.get('/gov/jiangsu/eea/:type?', lazyloadRouteHandler('./routes/gov/jiangsu/eea'));
// 山西
router.get('/gov/shanxi/rst/:category', lazyloadRouteHandler('./routes/gov/shanxi/rst'));

View File

@ -1,84 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
// 参考 bit/jwc 北京理工大学的的页面写成
const baseUrl = 'http://www.jseea.cn/';
const siteTitle = '--江苏省教育考试院';
const catrgoryMap = {
zkyw: { title: '招考要闻', suffix: 'zkyw/zkyw_channel173_1.html' },
zcgd: { title: '政策规定', suffix: 'plank/plank_index_1.html' },
zkxx: { title: '招考信息', suffix: 'enrollment/enrollment_index_1.html' },
zkzl: { title: '招考资料', suffix: 'enrollmentinfo/enrollmentinfo_index_1.html' },
xxjl: { title: '学习交流', suffix: 'learningexchange/learningexchange_index_1.html' },
};
// 专门定义一个function用于加载文章内容
async function load(link) {
// 异步请求文章
const response = await got.get(link);
// 加载文章内容
const $ = cheerio.load(response.data);
// 提取文章内容
const description = $('#left-container').html();
// 返回解析的结果
return { description };
}
module.exports = async (ctx) => {
// 默认 正常规定 然后获取列表页面
const type = ctx.params.type || 'zcgd';
const listPageUrl = baseUrl + catrgoryMap[type].suffix;
const response = await got({
method: 'get',
url: listPageUrl,
headers: {
Referer: baseUrl,
},
});
const $ = cheerio.load(response.data);
// console.log(type+":"+listPageUrl);
// 获取当前页面的 list
const list = $('td.content_css2>ul>li');
const result = await Promise.all(
// 遍历每一篇文章
list
.map(async (item) => {
const $ = cheerio.load(list[item]); // 将列表项加载成 html
const $rel_url = $('a').attr('href'); // 获取 每一项的url
// 获取绝对路径 招考要闻是绝对路径
const $item_url = type === 'zkyw' ? $rel_url : baseUrl + $rel_url;
const $title = $('a').attr('title'); // 获取每个的标题
const date_txt = $.text().match(/[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/); // 匹配 yyyy-mm-dd格式时间
const $pubdate = new Date(date_txt); // 正则匹配发布时间 然后转换成时间
// console.log(item + ":" + $item_url + ":" + $title + ":" + date_txt);
// 列表上提取到的信息
// 标题 链接
const single = {
title: $title,
pubDate: $pubdate,
link: $item_url,
guid: $item_url,
};
// 对于列表的每一项, 单独获取 时间与详细内容
const other = await ctx.cache.tryGet($item_url, () => load($item_url));
// 合并解析后的结果集作为该篇文章最终的输出结果
return Promise.resolve(Object.assign({}, single, other));
})
.get()
);
ctx.state.data = {
title: catrgoryMap[type].title + siteTitle,
link: baseUrl,
description: catrgoryMap[type].title + siteTitle,
item: result,
};
};

View File

@ -704,7 +704,7 @@ module.exports = {
kjt: [
{
title: '陕西省科学技术厅',
docs: 'https://docs.rsshub.app/government.html#shan-xi-ren-min-zheng-fu-shan-xi-sheng-ke-xue-ji-shu-ting',
docs: 'https://docs.rsshub.app/government.html#shan-xi-sheng-sheng-ren-min-zheng-fu-sheng-ke-xue-ji-shu-ting',
source: ['/view/iList.jsp', '/'],
target: (params, url) => `/gov/shaanxi/kjt/${new URL(url).searchParams.get('cat_id')}`,
},

View File

@ -0,0 +1,3 @@
module.exports = {
'/news/:type?': ['schen1024'],
};

64
lib/v2/jseea/news.js Normal file
View File

@ -0,0 +1,64 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
// 参考 bit/jwc 北京理工大学的的页面写成
const baseUrl = 'https://www.jseea.cn';
const siteTitle = ' - 江苏省教育考试院';
// 专门定义一个function用于加载文章内容
async function load(link) {
// 异步请求文章
const { data: response } = await got(link);
// 加载文章内容
const $ = cheerio.load(response);
// 提取文章内容
$('strong').remove();
const description = $('#content').html();
// 返回解析的结果
return description;
}
module.exports = async (ctx) => {
// 默认 正常规定 然后获取列表页面
const type = ctx.params.type ?? 'zkyw';
const listPageUrl = `${baseUrl}/webfile/news/${type}/`;
const { data: response } = await got(listPageUrl);
const $ = cheerio.load(response);
// console.log(type+":"+listPageUrl);
// 获取当前页面的 list
const list = $('div.content-list-div ul li a')
.toArray()
.map((item) => {
item = $(item);
return {
title: item
.contents()
.filter((_, e) => e.nodeType === 3)
.text()
.trim(),
link: `https:${item.attr('href')}`,
pubDate: timezone(parseDate(item.find('span').text(), 'YYYY-MM-DD'), 8),
};
});
const result = await Promise.all(
// 遍历每一篇文章
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
item.description = await load(item.link);
// 合并解析后的结果集作为该篇文章最终的输出结果
return item;
})
)
);
ctx.state.data = {
title: $('head title').text() + siteTitle,
link: listPageUrl,
item: result,
};
};

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

@ -0,0 +1,13 @@
module.exports = {
'jseea.cn': {
_name: '江苏省教育考试院',
'.': [
{
title: '新闻中心',
docs: 'https://docs.rsshub.app/government.html#jiang-su-sheng-ren-min-zheng-fu',
source: ['/webfile/news/:type'],
target: '/jseea/news/:type',
},
],
},
};

3
lib/v2/jseea/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/news/:type?', require('./news'));
};