fix(route): Fix gov/chongqing/sydwgkzp error (#14827)
* feat(route): 更新重庆事业单位考试通知 * docs: fix docs ---------
This commit is contained in:
parent
2dd1b75f7b
commit
01a16fd04a
|
|
@ -7,9 +7,22 @@ import { parseDate } from '@/utils/parse-date';
|
|||
|
||||
export const route: Route = {
|
||||
path: '/chongqing/gzw/:category{.+}?',
|
||||
name: 'Unknown',
|
||||
maintainers: [],
|
||||
parameters: {
|
||||
category: '分类,见下表,默认为通知公告',
|
||||
},
|
||||
name: '重庆市人民政府 国有资产监督管理委员会',
|
||||
url: 'gzw.cq.gov.cn',
|
||||
maintainers: ['nczitzk'],
|
||||
handler,
|
||||
radar: [
|
||||
{
|
||||
source: 'gzw.cq.gov.cn/*category',
|
||||
target: '/chongqing/gzw/*category',
|
||||
},
|
||||
],
|
||||
description: `| 通知公告 | 国企资讯 | 国企简介 | 国企招聘 |
|
||||
| --------- | -------- | -------- | -------- |
|
||||
| tzgg\_191 | gqdj | gqjj | gqzp |`,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
|
|
|
|||
|
|
@ -8,21 +8,12 @@ export const route: Route = {
|
|||
path: '/chongqing/rsks',
|
||||
categories: ['government'],
|
||||
example: '/gov/chongqing/rsks',
|
||||
parameters: {},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['rlsbj.cq.gov.cn/'],
|
||||
},
|
||||
],
|
||||
name: '重庆人事考试通知公告',
|
||||
name: '重庆市人民政府 人力社保局 - 人事考试通知',
|
||||
maintainers: ['Mai19930513'],
|
||||
handler,
|
||||
url: 'rlsbj.cq.gov.cn/',
|
||||
|
|
|
|||
|
|
@ -1,47 +1,41 @@
|
|||
import { Route } from '@/types';
|
||||
import { Route, Data } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
// 重庆市事业单位公开招聘
|
||||
const sydwgkzpUrl = 'https://rlsbj.cq.gov.cn/zwxx_182/sydw/';
|
||||
import type { Context } from 'hono';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/chongqing/sydwgkzp',
|
||||
path: '/chongqing/sydwgkzp/:year?',
|
||||
url: 'rlsbj.cq.gov.cn/',
|
||||
categories: ['government'],
|
||||
example: '/gov/chongqing/sydwgkzp',
|
||||
parameters: {},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
parameters: {
|
||||
year: '需要订阅的年份,格式为`YYYY`,必须小于等于当前年份,默认为当前年份',
|
||||
},
|
||||
radar: [
|
||||
{
|
||||
source: ['rlsbj.cq.gov.cn/'],
|
||||
},
|
||||
],
|
||||
name: '人力社保局',
|
||||
name: '重庆市人民政府 人力社保局 - 事业单位公开招聘',
|
||||
maintainers: ['MajexH'],
|
||||
handler,
|
||||
url: 'rlsbj.cq.gov.cn/',
|
||||
description: `#### 人事考试通知 {#chong-qing-shi-ren-min-zheng-fu-ren-li-she-bao-ju-ren-shi-kao-shi-tong-zhi}
|
||||
|
||||
|
||||
#### 事业单位公开招聘 {#chong-qing-shi-ren-min-zheng-fu-ren-li-she-bao-ju-shi-ye-dan-wei-gong-kai-zhao-pin}`,
|
||||
};
|
||||
|
||||
async function handler() {
|
||||
const { data: response } = await got(sydwgkzpUrl);
|
||||
async function handler(ctx: Context): Promise<Data> {
|
||||
// 获取用户输入的 year
|
||||
const { year = currentYear() }: { year?: number } = ctx.req.param();
|
||||
|
||||
// 替换 url
|
||||
const sydwgkzpUrl = `https://rlsbj.cq.gov.cn/zwxx_182/sydw/sydwgkzp${year}/`;
|
||||
|
||||
const { data: response }: { data: any } = await got(sydwgkzpUrl);
|
||||
|
||||
const $ = load(response);
|
||||
|
||||
// 获取所有的标题
|
||||
const list = $('div.page-list .tab-item > li')
|
||||
const list = $('div[class="p-rt rt"] .tab-item > li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
|
@ -60,10 +54,10 @@ async function handler() {
|
|||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const { data: response }: { data: any } = await got(item.link);
|
||||
const $ = load(response);
|
||||
// 主题正文
|
||||
item.description = $('div[class="view TRS_UEDITOR trs_paper_default trs_web"]').first().html();
|
||||
item.description = $('div[class="trs_editor_view TRS_UEDITOR trs_paper_default trs_web"]').first().html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
|
|
@ -75,3 +69,7 @@ async function handler() {
|
|||
item: items,
|
||||
};
|
||||
}
|
||||
|
||||
function currentYear(): number {
|
||||
return new Date().getFullYear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue