diff --git a/lib/routes/gov/hangzhou/namespace.ts b/lib/routes/gov/hangzhou/namespace.ts new file mode 100644 index 000000000..97b73cff0 --- /dev/null +++ b/lib/routes/gov/hangzhou/namespace.ts @@ -0,0 +1,9 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: "Hangzhou People's Government", + url: 'hangzhou.gov.cn', + zh: { + name: '杭州市人民政府', + }, +}; diff --git a/lib/routes/gov/hangzhou/templates/jbxx.art b/lib/routes/gov/hangzhou/templates/jbxx.art new file mode 100644 index 000000000..552356d59 --- /dev/null +++ b/lib/routes/gov/hangzhou/templates/jbxx.art @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ if otherInfo.legalPersonThemeClassification}} + + + + + {{ /if }} + {{ if !otherInfo.legalPersonThemeClassification }} + + + {{ /if }} + + + + + + + + + + + + + + +
办事信息
服务对象{{serviceInfo.serviceTarget}}办理形式{{serviceInfo.processingMethods}}
办理地点{{serviceInfo.processingLocation}}
办理时间{{serviceInfo.processingTime}}
申请信息
受理条件{{applicationInfo.acceptanceConditions}}
禁止性要求{{applicationInfo.prohibitedRequirements}}
数量限制{{applicationInfo.quantityRestrictions}}
结果信息
审批结果名称{{resultInfo.approvalResult}}
审批结果样本{{@ resultInfo.approvalSample }}审批结果类型{{resultInfo.approvalResultType}}
收费信息
是否收费{{feeInfo.isThereAFee}}是否支持网上支付{{feeInfo.isOnlinePaymentSupported}}
审批信息
权力来源{{approvalInfo.authoritySource}}
行使层级{{approvalInfo.exerciseLevel}}实施主体性质{{approvalInfo.implementingEntity}}
送达信息
是否支持物流快递{{deliveryInfo.isLogisticsSupported}}送达时限{{deliveryInfo.deliveryTimeframe}}
送达方式{{deliveryInfo.deliveryMethods}}
中介服务信息
中介服务事项名称{{agentService}}
其他信息
部门名称{{otherInfo.departmentName}}事项类型{{otherInfo.matterType}}
受理机构{{otherInfo.acceptingInstitution}}
基本编码{{otherInfo.basicCode}}实施编码{{otherInfo.implementationCode}}
通办范围{{otherInfo.scopeOfGeneralHandling}}办件类型{{otherInfo.documentType}}
决定机构{{otherInfo.decisionMakingAuthority}}委托部门{{otherInfo.delegatedDepartment}}
网上办理深度{{otherInfo.onlineProcessingDepth}}事项审查类型{{otherInfo.reviewType}}
是否进驻政务大厅{{otherInfo.isItAvailableInTheGovernmentServiceHall}}是否支持自助终端办理{{otherInfo.isSelfServiceTerminalProcessingSupported}}
是否实行告知承诺{{otherInfo.isACommitmentSystemImplemented}}权力属性{{otherInfo.authorityAttribute}}
是否支持预约办理{{otherInfo.isAppointmentBookingSupported}}是否网办{{otherInfo.isOnlineProcessingAvailable}}
自然人主题分类{{otherInfo.naturalPersonThemeClassification}}法人主题分类{{otherInfo.legalPersonThemeClassification}}法人主题分类{{otherInfo.naturalPersonThemeClassification}}
行政相对人权利和义务 + {{otherInfo.rightsAndObligationsOfAdministrativeCounterparties}} +
适用对象说明{{otherInfo.applicableObjectDescription}}
涉及的内容{{otherInfo.contentInvolved}}
diff --git a/lib/routes/gov/hangzhou/zjzwfw.ts b/lib/routes/gov/hangzhou/zjzwfw.ts new file mode 100644 index 000000000..24a01b5c0 --- /dev/null +++ b/lib/routes/gov/hangzhou/zjzwfw.ts @@ -0,0 +1,89 @@ +import logger from '@/utils/logger'; + +export async function crawler(item: any, browser: any): Promise { + try { + let response = ''; + const page = await browser.newPage(); + await page.setRequestInterception(true); + page.on('request', (request) => { + const resourceType = request.resourceType(); + if (['document', 'script', 'stylesheet', 'xhr'].includes(resourceType)) { + request.continue(); + } else { + request.abort(); + } + }); + await page.goto(item.link, { + waitUntil: 'networkidle0', + timeout: 29000, + }); + const selector = '.item-left .item .title .button'; + await page.evaluate((selector) => document.querySelector(selector).click(), selector); + await page.waitForSelector('.item-left .item .bg_box div:nth-child(16)', { timeout: 5000 }); + response = await page.content(); + return response || ''; + } catch (error) { + logger.error('Error when visiting /gov/hangzhou/zwfw:', error); + return ''; + } +} + +export function analyzer(box: any): object { + return { + serviceInfo: { + serviceTarget: box.find('.row:nth(1)>div:nth(1)').find('.inner').children().first().attr('content'), + processingMethods: box.find('.row:nth(1)>div:nth(3)').find('.inner').text(), + processingLocation: box.find('.row:nth(2)>div:nth(1)').find('.inner').text(), + processingTime: box.find('.row:nth(3)>div:nth(1)').find('.inner').text(), + }, + applicationInfo: { + acceptanceConditions: box.find('.row:nth(5)>div:nth(1)').find('.inner').text(), + prohibitedRequirements: box.find('.row:nth(6)>div:nth(1)').find('.inner').text(), + quantityRestrictions: box.find('.row:nth(7)>div:nth(1)').find('.inner').text(), + }, + resultInfo: { + approvalResult: box.find('.row:nth(9)>div:nth(1)').find('.inner').text(), + approvalSample: box.find('.row:nth(10)>div:nth(1)').find('.inner').html(), + approvalResultType: box.find('.row:nth(10)>div:nth(3)').find('.inner').text(), + }, + feeInfo: { + isThereAFee: box.find('.row:nth(12)>div:nth(1)').find('.inner').text(), + isOnlinePaymentSupported: box.find('.row:nth(12)>div:nth(3)').find('.inner').text(), + }, + approvalInfo: { + authoritySource: box.find('.row:nth(14)>div:nth(1)').find('.inner').text(), + exerciseLevel: box.find('.row:nth(15)>div:nth(1)').find('.inner').text(), + implementingEntity: box.find('.row:nth(15)>div:nth(3)').find('.inner').text(), + }, + deliveryInfo: { + isLogisticsSupported: box.find('.row:nth(17)>div:nth(1)').find('.inner').text(), + deliveryTimeframe: box.find('.row:nth(17)>div:nth(3)').find('.inner').text(), + deliveryMethods: box.find('.row:nth(18)>div:nth(1)').find('.inner').text(), + }, + agentService: box.find('.row:nth(20)>div:nth(1)').find('.inner').text(), + otherInfo: { + departmentName: box.find('.row:nth(22)>div:nth(1)').find('.inner').text(), + matterType: box.find('.row:nth(22)>div:nth(3)').find('.inner').text(), + acceptingInstitution: box.find('.row:nth(23)>div:nth(1)').find('.inner').text(), + basicCode: box.find('.row:nth(24)>div:nth(1)').find('.inner').text(), + implementationCode: box.find('.row:nth(24)>div:nth(3)').find('.inner').text(), + scopeOfGeneralHandling: box.find('.row:nth(25)>div:nth(1)').find('.inner').text(), + documentType: box.find('.row:nth(25)>div:nth(3)').find('.inner').text(), + decisionMakingAuthority: box.find('.row:nth(26)>div:nth(1)').find('.inner').text(), + delegatedDepartment: box.find('.row:nth(26)>div:nth(3)').find('.inner').text(), + onlineProcessingDepth: box.find('.row:nth(27)>div:nth(1)').find('.inner').text(), + reviewType: box.find('.row:nth(27)>div:nth(3)').find('.inner').text(), + isItAvailableInTheGovernmentServiceHall: box.find('.row:nth(28)>div:nth(1)').find('.inner').text(), + isSelfServiceTerminalProcessingSupported: box.find('.row:nth(28)>div:nth(3)').find('.inner').text(), + isACommitmentSystemImplemented: box.find('.row:nth(29)>div:nth(1)').find('.inner').text(), + authorityAttribute: box.find('.row:nth(29)>div:nth(3)').find('.inner').text(), + isAppointmentBookingSupported: box.find('.row:nth(30)>div:nth(1)').find('.inner').text(), + isOnlineProcessingAvailable: box.find('.row:nth(30)>div:nth(3)').find('.inner').text(), + naturalPersonThemeClassification: box.find('.row:nth(31)>div:nth(1)').find('.inner').text(), + legalPersonThemeClassification: box.find('.row:nth(31)>div:nth(3)').find('.inner').text(), + rightsAndObligationsOfAdministrativeCounterparties: box.find('.row:nth(32)>div:nth(1)').find('.inner').text(), + applicableObjectDescription: box.find('.row:nth(33)>div:nth(1)').find('.inner').text(), + contentInvolved: box.find('.row:nth(34)>div:nth(1)').find('.inner').text(), + }, + }; +} diff --git a/lib/routes/gov/hangzhou/zwfw.ts b/lib/routes/gov/hangzhou/zwfw.ts new file mode 100644 index 000000000..9c2c24eb6 --- /dev/null +++ b/lib/routes/gov/hangzhou/zwfw.ts @@ -0,0 +1,112 @@ +import { Route } from '@/types'; +import { load } from 'cheerio'; +const __dirname = getCurrentPath(import.meta.url); + +import puppeteer from '@/utils/puppeteer'; +import ofetch from '@/utils/ofetch'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import { crawler, analyzer } from './zjzwfw'; +import timezone from '@/utils/timezone'; +import path from 'node:path'; +import { art } from '@/utils/render'; +import { getCurrentPath } from '@/utils/helpers'; + +export const route: Route = { + path: '/hangzhou/zwfw', + categories: ['government'], + example: '/gov/hangzhou/zwfw', + features: { + requireConfig: false, + requirePuppeteer: true, + antiCrawler: true, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['hangzhou.gov.cn/col/col1256349/index.html'], + }, + ], + name: '政务服务公开', + maintainers: ['flynncao'], + handler, + url: 'hangzhou.gov.cn/col/col1256349/index.html', +}; + +async function handler() { + const host = 'https://www.hangzhou.gov.cn/col/col1256349/index.html'; + const response = await ofetch(host); + + const browser = await puppeteer({ stealth: true }); + const link = host; + const formatted = response + .replace('', '') + .replaceAll('', '') + .replaceAll('', '') + .replaceAll('', '') + .replaceAll('', '') + .replaceAll('', ''); + const $ = load(formatted); + + const list = $('li.clearfix') + .toArray() + .map((item: any) => { + item = $(item); + const title = item.find('a').first().text(); + const time = timezone(parseDate(item.find('span').first().text(), 'YYYY-MM-DD'), 8); + const a = item.find('a').first().attr('href'); + const fullUrl = new URL(a, host).href; + + return { + title, + link: fullUrl, + pubDate: time, + }; + }) + .filter((item) => !item.title.includes('置顶')); + const items: any = await Promise.all( + list.map((item: any) => + cache.tryGet(item.link, async () => { + const host = new URL(item.link).hostname; + if (host === 'www.zjzwfw.gov.cn') { + // 来源为浙江政务服务网 + const content = await crawler(item, browser); + const $ = load(content); + item.description = art(path.resolve(__dirname, 'templates/jbxx.art'), analyzer($('.item-left .item .bg_box'))); + item.author = '浙江政务服务网'; + item.category = $('meta[name="ColumnType"]').attr('content'); + } else { + // 其他正常抓取 + const response = await got(item.link); + const $ = load(response.data); + if (host === 'police.hangzhou.gov.cn') { + // 来源为杭州市公安局 + item.description = $('.art-content .wz_con_content').html(); + item.author = $('meta[name="ContentSource"]').attr('content'); + item.category = $('meta[name="ColumnType"]').attr('content'); + } else { + // 缺省:来源为杭州市政府网 + item.description = $('.article').html(); + item.author = $('meta[name="ContentSource"]').attr('content'); + item.category = $('meta[name="ColumnType"]').attr('content'); + } + } + item.pubDate = $('meta[name="PubDate"]').length ? timezone(parseDate($('meta[name="PubDate"]').attr('content') as string, 'YYYY-MM-DD HH:mm'), 8) : item.pubDate; + return item; + }) + ) + ); + + await browser.close(); + return { + allowEmpty: true, + title: '杭州市人民政府-政务服务公开', + link, + item: items, + }; +}