From ff487f328c3705ff6897dcc31f71363d8215b7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B5=A9=E5=AE=87?= <37102468+HaoyuLee@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:14:04 +0800 Subject: [PATCH] feat(route): add route /gov/zj/ningborsjnotice/:colId?,/gov/zj/ningbogzw-notice/:colId? (#16404) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 宁波市人力资源保障局-某分类-公告列表 * feat: 宁波国资委-某分类-公告列表 * Update lib/routes/gov/zj/ningborsjnotice.ts * Update lib/routes/gov/zj/ningbogzw-notice.ts * Update lib/routes/gov/zj/ningbogzw-notice.ts * Update lib/routes/gov/zj/ningborsjnotice.ts * fix: description content indent update --------- --- lib/routes/gov/zj/ningbogzw-notice.ts | 50 +++++++++++++++++++++++++++ lib/routes/gov/zj/ningborsjnotice.ts | 50 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 lib/routes/gov/zj/ningbogzw-notice.ts create mode 100644 lib/routes/gov/zj/ningborsjnotice.ts diff --git a/lib/routes/gov/zj/ningbogzw-notice.ts b/lib/routes/gov/zj/ningbogzw-notice.ts new file mode 100644 index 00000000000000..f3454f46c05731 --- /dev/null +++ b/lib/routes/gov/zj/ningbogzw-notice.ts @@ -0,0 +1,50 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/zj/ningbogzw-notice/:colId?', + categories: ['government'], + example: '/gov/zj/ningbogzw-notice/1229116730', + parameters: { + colId: '公告分类id、详细信息点击源网站http://gzw.ningbo.gov.cn/请求中寻找', + }, + radar: [ + { + source: ['gzw.ningbo.gov.cn/col/col1229116730/index.html'], + target: '/zj/ningbogzw-notice/:colId?', + }, + ], + name: '宁波市国资委-公告', + url: 'gzw.ningbo.gov.cn', + maintainers: ['HaoyuLee'], + description: ` +| 公告类别 | colId | +| ------------ | -- | +| 首页-市属国企招聘信息-招聘公告 | 1229116730 | + `, + async handler(ctx) { + const { colId = '1229116730' } = ctx.req.param(); + const url = `http://gzw.ningbo.gov.cn/col/col${colId}/index.html`; + const { data: response } = await got(url); + const noticeCate = load(response)('.List-topic .text-tag').text().trim(); + const reg = /
  • .*<\/li>/g; + const item = response.match(reg).map((line) => { + const $ = load(line); + const title = $('a'); + return { + title: `宁波市国资委-${noticeCate}:${title.text()}`, + link: `http://gzw.ningbo.gov.cn${title.attr('href')}`, + pubDate: parseDate($('p').text().replaceAll(/\[|]/g, '')), + author: '宁波市国资委', + description: title.text(), + }; + }); + return { + title: '宁波市国资委', + link: url, + item, + }; + }, +}; diff --git a/lib/routes/gov/zj/ningborsjnotice.ts b/lib/routes/gov/zj/ningborsjnotice.ts new file mode 100644 index 00000000000000..5f3d9202aa0a55 --- /dev/null +++ b/lib/routes/gov/zj/ningborsjnotice.ts @@ -0,0 +1,50 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/zj/ningborsjnotice/:colId?', + categories: ['government'], + example: '/gov/zj/ningborsjnotice/1229676740', + parameters: { + colId: '公告分类id、详细信息点击源网站http://rsj.ningbo.gov.cn/请求中寻找', + }, + radar: [ + { + source: ['rsj.ningbo.gov.cn/col/col1229676740/index.html'], + target: '/zj/ningborsjnotice/:colId?', + }, + ], + name: '宁波市人力资源和社会保障局-公告', + url: 'rsj.ningbo.gov.cn', + maintainers: ['HaoyuLee'], + description: ` +| 公告类别 | colId | +| ------------ | -- | +| 事业单位进人公告 | 1229676740 | + `, + async handler(ctx) { + const { colId = '1229676740' } = ctx.req.param(); + const url = `http://rsj.ningbo.gov.cn/col/col${colId}/index.html`; + const { data: response } = await got(url); + const noticeCate = load(response)('.titel.bgcolor01').text(); + const reg = /
  • .*<\/li>/g; + const item = response.match(reg).map((line) => { + const $ = load(line); + const title = $('.news_titel'); + return { + title: `宁波人社公告-${noticeCate}:${title.text()}`, + link: `http://rsj.ningbo.gov.cn${title.attr('href')}`, + pubDate: parseDate($('.news_date').text().replaceAll(/\[|]/g, '')), + author: '宁波市人力资源和社会保障局', + description: title.text(), + }; + }); + return { + title: '宁波市人力资源和社会保障局-公告', + link: url, + item, + }; + }, +};