Skip to content

Commit

Permalink
feat: add route ‘/gov/tianjin/tjftz-notice/channelId' 、‘/gov/tianjin/…
Browse files Browse the repository at this point in the history
…tjrcgzw-notice/:cate/:subCate' (DIYgod#18434)

* feat: 宁波市人力资源保障局-某分类-公告列表

* feat: 宁波国资委-某分类-公告列表

* Update lib/routes/gov/zj/ningborsjnotice.ts

Co-authored-by: Tony <[email protected]>

* Update lib/routes/gov/zj/ningbogzw-notice.ts

Co-authored-by: Tony <[email protected]>

* Update lib/routes/gov/zj/ningbogzw-notice.ts

Co-authored-by: Tony <[email protected]>

* Update lib/routes/gov/zj/ningborsjnotice.ts

Co-authored-by: Tony <[email protected]>

* fix: description content indent update

* fix: route ‘/gov/zj/search/:websiteid?/:word/:cateid?’ result.item deduplication

* fix: route ‘/gov/zj/search/:websiteid?/:word/:cateid?’ result.item deduplication

* feat: add route ‘/gov/tianjin/tjftz-notice/:channelId'

* feat: add route ‘/gov/tianjin/tjrcgzw-notice/:cate/:subCate'

* Update lib/routes/gov/tianjin/tjrcgzw.ts

Co-authored-by: Tony <[email protected]>

* Update lib/routes/gov/tianjin/tjrcgzw.ts

Co-authored-by: Tony <[email protected]>

* fix: fix lint issues

---------
  • Loading branch information
HaoyuLee authored Feb 25, 2025
1 parent 94ce003 commit a70bebd
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
53 changes: 53 additions & 0 deletions lib/routes/gov/tianjin/tjftz.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/tianjin/tjftz-notice/:channelId',
categories: ['government'],
example: '/gov/tianjin/tjftz-notice/6302',
parameters: {
channelId: '公告分类id、详细信息点击源网站https://www.tjftz.gov.cn/请求中寻找',
},
radar: [
{
source: ['tjftz.gov.cn/channels/:channelId.html'],
target: '/tianjin/tjftz-notice/:channelId',
},
],
name: '天津港保税区-公告',
url: 'tjftz.gov.cn',
maintainers: ['HaoyuLee'],
description: `
| 公告类别 | channelId |
| ------------ | -- |
| 首页>新闻>保税区要闻>区域聚焦 | 6302 |
`,
async handler(ctx) {
const { channelId = '6302' } = ctx.req.param();
const url = `https://www.tjftz.gov.cn/channels/${channelId}.html`;
const { data: response } = await got(url);
const noticeCate = load(response)('.location').text().trim();
const item = load(response)('#sec_right>ul>span>li>.layui-row')
.toArray()
.map((el) => {
const $ = load(el);
return {
title: `天津保税区:${$('a').attr('title')}`,
link: `https://www.tjftz.gov.cn${$('a').attr('href')}`,
pubDate: parseDate($('span').text().trim()),
author: '天津保税区',
description: `
<h4>${noticeCate}</h4>
<a href="https://www.tjftz.gov.cn${$('a').attr('href')}">${$('a').attr('title')}</a>
`,
};
});
return {
title: '天津港保税区-公告',
link: url,
item,
};
},
};
51 changes: 51 additions & 0 deletions lib/routes/gov/tianjin/tjrcgzw.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/tianjin/tjrcgzw-notice/:cate/:subCate',
categories: ['government'],
example: '/gov/tianjin/tjrcgzw-notice/rczc/sjrczc/',
parameters: {
channelId: '公告分类id、详细信息点击源网站https://hrss.tj.gov.cn/ztzl/ztzl1/tjrcgzw/请求中寻找',
},
radar: [
{
source: ['hrss.tj.gov.cn/ztzl/ztzl1/tjrcgzw/'],
target: '/tianjin/tjrcgzw-notice/:cate/:subCate',
},
],
name: '天津人才工作网-公告',
url: 'hrss.tj.gov.cn/ztzl/ztzl1/tjrcgzw/',
maintainers: ['HaoyuLee'],
async handler(ctx) {
const { cate, subCate } = ctx.req.param();
const url = `https://hrss.tj.gov.cn/ztzl/ztzl1/tjrcgzw/${cate}/${subCate}/`;
const { data: response } = await got(url);
const noticeCate = load(response)('.routeBlockAuto').text().trim();
const item = load(response)('ul.listUlBox01>li')
.toArray()
.map((el) => {
const $ = load(el);
const title = $('a').text().trim();
const href = $('a').attr('href') || '';
const date = $('span').text().trim();
const link = href!.includes('http') ? href : new URL(href, url).href;
return {
title: `天津人才工作网:${title}`,
link,
pubDate: parseDate(date),
author: '天津人才工作网',
description: `
<h4>${noticeCate}</h4>
<a href="${link}">${title}</a>
`,
};
});
return {
title: '天津人才工作网-公告',
link: url,
item,
};
},
};

0 comments on commit a70bebd

Please sign in to comment.