Python查询工信部网站备案信息

Python查询工信部网站备案信息,通过https://beian.miit.gov.cn/查询信息,确保与管局实际信息一致; 支持自动完成图片拖动验证,存在极低的失败率;支持循环…

Python查询工信部网站备案信息,通过https://beian.miit.gov.cn/查询信息,确保与管局实际信息一致;

支持自动完成图片拖动验证,存在极低的失败率;支持循环翻页查询,获取企业名下的所有备案信息;查询完毕后按任意键继续查询;非常方便,哈哈~~

看代码:

#-*-coding:utf-8-*-importrequests,hashlib,time,base64,cv2,oswhileTrue:#提前获取要查询的对象信息,以免Token失效(Token有效时间为3分钟)print("项目地址:https://github.com/wongzeon/ICP-Checker\\n")print("版本:V1.1可用测试:2021-7-27\\n")print("以企业名称查询的,需要输入企业全称\\n")print("以域名查询的,请不要输入“http/www”等域名外的字符\\n")info=input("请输入要查询的备案信息,可以为公司名或域名:")info_data={'pageNum':'','pageSize':'','unitName':info}#构造AuthKeytimeStamp=int(round(time.time()*1000))authSecret='testtest'+str(timeStamp)authKey=hashlib.md5(authSecret.encode(encoding='UTF-8')).hexdigest()#获取Cookiecookie_headers={'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9','accept-encoding':'gzip,deflate,br','accept-language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','user-agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.72Safari/537.36Edg/90.0.818.42'}cookie=requests.utils.dict_from_cookiejar(requests.get('https://beian.miit.gov.cn/',headers=cookie_headers).cookies)['__jsluid_s']#请求获取Tokent_url='https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth't_headers={'Host':'hlwicpfwc.miit.gov.cn','Connection':'keep-alive','sec-ch-ua':'"NotA;Brand";v="99","Chromium";v="90","MicrosoftEdge";v="90"','Accept':'*/*','DNT':'1','sec-ch-ua-mobile':'?0','User-Agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.85Safari/537.36Edg/90.0.818.46','Origin':'https://beian.miit.gov.cn','Sec-Fetch-Site':'same-site','Sec-Fetch-Mode':'cors','Sec-Fetch-Dest':'empty','Referer':'https://beian.miit.gov.cn/','Accept-Encoding':'gzip,deflate,br','Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Cookie':'__jsluid_s='+cookie}data={'authKey':authKey,'timeStamp':timeStamp}t_response=requests.post(t_url,data=data,headers=t_headers)try:get_token=t_response.json()['params']['bussiness']except:print('\\n'"请求被禁止,请稍后或更换头部与IP后再试,状态码:",t_response.status_code)break#获取验证图像、UUIDp_url='https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImage'p_headers={'Host':'hlwicpfwc.miit.gov.cn','Connection':'keep-alive','Content-Length':'0','sec-ch-ua':'"NotA;Brand";v="99","Chromium";v="90","MicrosoftEdge";v="90"','Accept':'application/json,text/plain,*/*','DNT':'1','sec-ch-ua-mobile':'?0','User-Agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.85Safari/537.36Edg/90.0.818.46','token':get_token,'Origin':'https://beian.miit.gov.cn','Sec-Fetch-Site':'same-site','Sec-Fetch-Mode':'cors','Sec-Fetch-Dest':'empty','Referer':'https://beian.miit.gov.cn/','Accept-Encoding':'gzip,deflate,br','Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Cookie':'__jsluid_s='+cookie}p_request=requests.post(p_url,data='',headers=p_headers)try:p_uuid=p_request.json()['params']['uuid']big_image=p_request.json()['params']['bigImage']small_image=p_request.json()['params']['smallImage']exceptKeyError:print("请重试,请求状态码:",p_request.status_code)#解码图片,写入并计算图片缺口位置withopen('bigImage.jpg','wb')asf:f.write(base64.b64decode(big_image))f.close()withopen('smallImage.jpg','wb')asf:f.write(base64.b64decode(small_image))f.close()background_image=cv2.imread('bigImage.jpg',cv2.COLOR_GRAY2RGB)fill_image=cv2.imread('smallImage.jpg',cv2.COLOR_GRAY2RGB)background_image_canny=cv2.Canny(background_image,100,200)fill_image_canny=cv2.Canny(fill_image,100,300)position_match=cv2.matchTemplate(background_image,fill_image,cv2.TM_CCOEFF_NORMED)min_val,max_val,min_loc,max_loc=cv2.minMaxLoc(position_match)position=max_locmouse_length=position[0]+1os.remove('bigImage.jpg')os.remove('smallImage.jpg')#通过拼图验证,获取signcheck_url='https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/checkImage'check_headers={'Host':'hlwicpfwc.miit.gov.cn','Accept':'application/json,text/plain,*/*','Connection':'keep-alive','Content-Length':'60','sec-ch-ua':'"NotA;Brand";v="99","Chromium";v="90","MicrosoftEdge";v="90"','DNT':'1','sec-ch-ua-mobile':'?0','User-Agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.72Safari/537.36Edg/90.0.818.42','token':get_token,'Content-Type':'application/json','Origin':'https://beian.miit.gov.cn','Sec-Fetch-Site':'same-site','Sec-Fetch-Mode':'cors','Sec-Fetch-Dest':'empty','Referer':'https://beian.miit.gov.cn/','Accept-Encoding':'gzip,deflate,br','Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Cookie':'__jsluid_s='+cookie}check_data={'key':p_uuid,'value':mouse_length}check_request=requests.post(check_url,json=check_data,headers=check_headers)try:sign=check_request.json()['params']exceptException:print('\\n'"请求被禁止,请稍后或更换头部与IP后再试,状态码:",check_request.status_code)break#获取备案信息info_url='https://hlwicpfwc.miit.gov.cn/icpproject_query/api/icpAbbreviateInfo/queryByCondition'info_headers={'Host':'hlwicpfwc.miit.gov.cn','Connection':'keep-alive','Content-Length':'78','sec-ch-ua':'"NotA;Brand";v="99","Chromium";v="90","MicrosoftEdge";v="90"','DNT':'1','sec-ch-ua-mobile':'?0','User-Agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.72Safari/537.36Edg/90.0.818.42','Content-Type':'application/json','Accept':'application/json,text/plain,*/*','uuid':p_uuid,'token':get_token,'sign':sign,'Origin':'https://beian.miit.gov.cn','Sec-Fetch-Site':'same-site','Sec-Fetch-Mode':'cors','Sec-Fetch-Dest':'empty','Referer':'https://beian.miit.gov.cn/','Accept-Encoding':'gzip,deflate,br','Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Cookie':'__jsluid_s='+cookie}info_request=requests.post(info_url,json=info_data,headers=info_headers)domain_total=info_request.json()['params']['total']page_total=info_request.json()['params']['lastPage']page_size=info_request.json()['params']['pageSize']start_row=info_request.json()['params']['startRow']end_row=info_request.json()['params']['endRow']os.system('cls')print("\\n查询对象",info,"共有",domain_total,"个备案域名",'\\n')print("域名具体信息如下:")foriinrange(1,page_total+1):forkinrange(start_row,end_row+1):info_base=info_request.json()['params']['list'][k]domain_name=info_base['domain']domain_type=info_base['natureName']domain_licence=info_base['mainLicence']domain_web_licence=info_base['serviceLicence']domain_site_name=info_base['serviceName']domain_status=info_base['limitAccess']domain_approve_date=info_base['updateRecordTime']domain_owner=info_base['unitName']try:domain_content_approved=info_base['contentTypeName']ifnotbool(domain_content_approved):domain_content_approved="无"exceptKeyError:domain_content_approved="无"print("\\n域名主办方:",domain_owner,'\\n')print("域名:",domain_name,'\\n')print("网站名称:",domain_site_name,'\\n')print("备案许可证号:",domain_licence,'\\n')print("网站备案号:",domain_web_licence,'\\n')print("域名类型:",domain_type,'\\n')print("网站前置审批项:",domain_content_approved,'\\n')print("是否限制接入:",domain_status,'\\n')print("审核通过日期:",domain_approve_date,'\\n')info_data_page={'pageNum':i+1,'pageSize':'10','unitName':info}ifinfo_data_page['pageNum']>page_total:print("查询完毕",'\\n')breakelse:info_request=requests.post(info_url,json=info_data_page,headers=info_headers)start_row=info_request.json()['params']['startRow']end_row=info_request.json()['params']['endRow']time.sleep(3)os.system('pause')

产品猿社区致力收录更多优质的商业产品,给服务商以及软件采购客户提供更多优质的软件产品,帮助开发者变现来实现多方共赢;

日常运营的过程中我们难免会遇到各种版权纠纷等问题,如果您在社区内发现有您的产品未经您授权而被用户提供下载或使用,您可按照我们投诉流程处理,点我投诉

本文来自用户发布投稿,不代表产品猿立场 ;若对此文有疑问或内容有严重错误,可联系平台客服反馈;

部分产品是用户投稿,可能本文没有提供官方下下载地址或教程,若您看到的内容没有下载入口,您可以在我们产品园商城搜索看开发者是否有发布商品;若您是开发者,也诚邀您入驻商城平台发布的产品,地址:点我进入

如若转载,请注明出处:https://www.chanpinyuan.cn/42966.html;
(0)
上一篇 2023年5月17日 下午4:16
下一篇 2023年5月17日 下午4:16

相关推荐

发表回复

登录后才能评论
分享本页
返回顶部