wongzeon / icp-checker Goto Github PK
View Code? Open in Web Editor NEWICP备案查询,可查询企业或域名的ICP备案信息,自动完成滑动验证,保存结果到Excel表格,适用于新版的工信部备案管理系统网站,告别频繁拖动验证,以及某站*工具要开通VIP才可查看备案信息的坑
License: GNU Affero General Public License v3.0
ICP备案查询,可查询企业或域名的ICP备案信息,自动完成滑动验证,保存结果到Excel表格,适用于新版的工信部备案管理系统网站,告别频繁拖动验证,以及某站*工具要开通VIP才可查看备案信息的坑
License: GNU Affero General Public License v3.0
import requests
import hashlib
import time
import base64
import cv2
import os
while True:
#提前获取要查询的对象信息,以免Token失效(Token有效时间为3分钟)
print("以企业名称查询的,需要输入企业全称\n")
print("以域名查询的,请不要输入“http/www”等域名外的字符\n")
info = input("请输入要查询的备案信息,可以为公司名或域名:")
info_data = {
'pageNum':'',
'pageSize':'',
'unitName':info
}
#构造AuthKey
timeStamp = int(round(time.time()1000))
authSecret = 'testtest' + str(timeStamp)
authKey = hashlib.md5(authSecret.encode(encoding='UTF-8')).hexdigest()
#获取Cookie
cookie_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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36 Edg/90.0.818.42'
}
cookie = requests.utils.dict_from_cookiejar(requests.get('https://beian.miit.gov.cn/',headers=cookie_headers).cookies)['__jsluid_s']
#请求获取Token
t_url = 'https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth'
t_headers = {
'Host': 'hlwicpfwc.miit.gov.cn',
'Connection': 'keep-alive',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Microsoft Edge";v="90"',
'Accept': '/*',
'DNT': '1',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/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
#获取验证图像、UUID
p_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': '" Not A;Brand";v="99", "Chromium";v="90", "Microsoft Edge";v="90"',
'Accept': 'application/json, text/plain, /',
'DNT': '1',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/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, json=info_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']
except KeyError:
print("请重试,请求状态码:",p_request.status_code)
#解码图片,写入并计算图片缺口位置
with open('bigImage.jpg','wb') as f:
f.write(base64.b64decode(big_image))
f.close()
with open('smallImage.jpg','wb') as f:
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_loc
mouse_length = position[0]+1
os.remove('bigImage.jpg')
os.remove('smallImage.jpg')
#通过拼图验证,获取sign
check_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': '" Not A;Brand";v="99", "Chromium";v="90", "Microsoft Edge";v="90"',
'DNT': '1',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36 Edg/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']
except KeyError:
print(check_request.json()['msg'])
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': '" Not A;Brand";v="99", "Chromium";v="90", "Microsoft Edge";v="90"',
'DNT': '1',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36 Edg/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("域名具体信息如下:")
for i in range(1,page_total+1):
for k in range(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']
if not bool(domain_content_approved):
domain_content_approved = "无"
except KeyError:
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
}
if info_data_page['pageNum'] > page_total:
print("查询完毕",'\n')
break
else:
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')
我需求是定时检查某一些域名备案是否还在,如果域名备案被注销,则通过**软件通知我。
大佬,能搞成批量嘛对指定文件扫描
不容易啊
存在特殊符号的企业,特殊符号会被删除掉,导致查询错误
失效了
连续查多条的时候 会有一些明明有备案但是返回结果是查询无备案,遇到过好几次了,不知道哪里的问题 判断还是缓存 过一会查询就能继续查到实际结果了 希望排查下
可以添加批量域名查询吗,一次查询多个URL
拿cursor改了几个版本,有用到的地方库主可以参考下
# -*- coding: utf-8 -*-
"""
ICP-Checker.py
日期:2023-10-01
作者:soapffz
改编自:https://github.com/wongzeon/ICP-Checker
此脚本用于批量查询域名的备案信息。它首先获取必要的Cookie和Token,然后对输入的域名进行查询。查询结果包括备案信息和不支持备案的域名。
主要功能如下:
1. 批量查询:支持从文件中读取域名进行批量查询。
2. 备案信息获取:对每个域名,获取其备案信息,包括域名主办方、域名、备案许可证号、网站备案号、域名类型、网站前置审批项、是否限制接入、审核通过日期等。
3. 不支持备案的域名:对于不支持备案的域名,会打印出相应的提示信息。
4. 查询间隔:在批量查询中,每次查询之间有10秒的间隔,以防止频繁查询导致的问题。
注意:此脚本需要在Python 3环境下运行,并需要安装requests和tqdm等第三方库。
"""
import re
import os
import cv2
import time
import base64
import hashlib
import requests
import openpyxl as xl
from openpyxl.styles import Alignment
import argparse
import sys
import logging
from tqdm import tqdm
import os
import subprocess
import logging
# 创建一个handler,用于写入日志文件
handler = logging.StreamHandler(sys.stdout)
# 再创建一个handler,用于输出到控制台
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# 定义handler的输出格式
formatter = logging.Formatter("%(message)s")
handler.setFormatter(formatter)
console.setFormatter(formatter)
# 给logger添加handler
logging.getLogger("").addHandler(handler)
logging.getLogger("").addHandler(console)
# 设置日志格式
logging.basicConfig(level=logging.INFO, format="%(message)s")
os.environ["no_proxy"] = "*"
# 添加命令行参数解析
arg_parser = argparse.ArgumentParser(
description="Check ICP for a domain or a list of domains from a file."
)
arg_parser.add_argument(
"input", help="The domain or the file containing a list of domains."
)
args = arg_parser.parse_args()
# 设置保存路径
output_directory = "./outs/"
if not os.path.exists(output_directory):
os.makedirs(output_directory)
# 使用requests.Session
http_session = requests.Session()
class CustomException(Exception):
pass
def send_request(
url, method="get", headers=None, data=None, json=None, timeout=(3.06, 27)
):
try:
response = requests.request(
method, url, headers=headers, data=data, json=json, timeout=timeout
)
return response
except requests.RequestException as e:
raise CustomException(f"请求失败: {e}")
def retrieve_cookies():
cookie_headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32"
}
err_num = 0
while err_num < 3:
response = send_request("https://beian.miit.gov.cn/", headers=cookie_headers)
try:
cookie = requests.utils.dict_from_cookiejar(response.cookies)["__jsluid_s"]
return cookie
except KeyError:
err_num += 1
time.sleep(3)
raise CustomException("获取Cookie失败,请重试!")
def retrieve_token():
timeStamp = round(time.time() * 1000)
authSecret = "testtest" + str(timeStamp)
authKey = hashlib.md5(authSecret.encode(encoding="UTF-8")).hexdigest()
auth_data = {"authKey": authKey, "timeStamp": timeStamp}
url = "https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth"
try:
t_response = requests.post(
url=url, data=auth_data, headers=base_header, timeout=(3.06, 27)
).json()
token = t_response["params"]["bussiness"]
except:
return -1
return token
def retrieve_check_pic(token):
url = "https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImage"
base_header["Accept"] = "application/json, text/plain, */*"
base_header.update({"Content-Length": "0", "token": token})
try:
p_request = requests.post(
url=url, data="", headers=base_header, timeout=(3.06, 27)
).json()
p_uuid = p_request["params"]["uuid"]
big_image = p_request["params"]["bigImage"]
small_image = p_request["params"]["smallImage"]
except:
return -1
# 解码图片,写入并计算图片缺口位置
with open("bigImage.jpg", "wb") as f:
f.write(base64.b64decode(big_image))
with open("smallImage.jpg", "wb") as f:
f.write(base64.b64decode(small_image))
background_image = cv2.imread("bigImage.jpg", cv2.COLOR_GRAY2RGB)
fill_image = cv2.imread("smallImage.jpg", cv2.COLOR_GRAY2RGB)
position_match = cv2.matchTemplate(
background_image, fill_image, cv2.TM_CCOEFF_NORMED
)
max_loc = cv2.minMaxLoc(position_match)[3][0]
mouse_length = max_loc + 1
os.remove("bigImage.jpg")
os.remove("smallImage.jpg")
check_data = {"key": p_uuid, "value": mouse_length}
return check_data
def retrieve_sign(check_data, token):
check_url = "https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/checkImage"
base_header.update(
{"Content-Length": "60", "token": token, "Content-Type": "application/json"}
)
try:
pic_sign = requests.post(
check_url, json=check_data, headers=base_header, timeout=(3.06, 27)
).json()
sign = pic_sign["params"]
except:
return -1
return sign
def query_base(info):
# 过滤空值和特殊字符,只允许 - —《》. () 分别用于域名和公司名
try:
if info == "":
raise ValueError("InputNone")
info = re.sub("[^\\u4e00-\\u9fa5-A-Za-z0-9,-.()《》—()]", "", info)
info = (
info.replace(" ", "")
.replace("https://www.", "")
.replace("http://www.", "")
.replace("http://", "")
)
input_zh = re.compile("[\u4e00-\u9fa5]")
zh_match = input_zh.search(info)
if zh_match:
info_result = info
else:
# 检测是否为可备案的域名类型(类型同步日期2022/01/06)
input_url = re.compile(
r"([^.]+)(?:\.(?:GOV\.cn|ORG\.cn|AC\.cn|MIL\.cn|NET\.cn|EDU\.cn|COM\.cn|BJ\.cn|TJ\.cn|SH\.cn|CQ\.cn|HE\.cn|SX\.cn|NM\.cn|LN\.cn|JL\.cn|HL\.cn|JS\.cn|ZJ\.cn|AH\.cn|FJ\.cn|JX\.cn|SD\.cn|HA\.cn|HB\.cn|HN\.cn|GD\.cn|GX\.cn|HI\.cn|SC\.cn|GZ\.cn|YN\.cn|XZ\.cn|SN\.cn|GS\.cn|QH\.cn|NX\.cn|XJ\.cn|TW\.cn|HK\.cn|MO\.cn|cn|REN|WANG|CITIC|TOP|SOHU|XIN|COM|NET|CLUB|XYZ|VIP|SITE|SHOP|INK|INFO|MOBI|RED|PRO|KIM|LTD|GROUP|BIZ|AUTO|LINK|WORK|LAW|BEER|STORE|TECH|FUN|ONLINE|ART|DESIGN|WIKI|LOVE|CENTER|VIDEO|SOCIAL|TEAM|SHOW|COOL|ZONE|WORLD|TODAY|CITY|CHAT|COMPANY|LIVE|FUND|GOLD|PLUS|GURU|RUN|PUB|EMAIL|LIFE|CO|FASHION|FIT|LUXE|YOGA|BAIDU|CLOUD|HOST|SPACE|PRESS|WEBSITE|ARCHI|ASIA|BIO|BLACK|BLUE|GREEN|LOTTO|ORGANIC|PET|PINK|POKER|PROMO|SKI|VOTE|VOTO|ICU|LA))",
flags=re.IGNORECASE,
)
info_result = input_url.search(info)
if info_result is None:
if info.split(".")[0] == "":
raise ValueError("OnlyDomainInput")
raise ValueError("ValidType")
else:
info_result = info_result.group()
info_data = {
"pageNum": "1",
"pageSize": "40",
"serviceType": 1,
"unitName": info_result,
}
return info_data
except ValueError as e:
if str(e) == "InputNone" or str(e) == "OnlyDomainInput":
logging.error(f"[-] 请正确输入域名: {info}")
else:
logging.error(f"[-] {info} 不支持备案")
def retrieve_beian_info(info_data, p_uuid, token, sign):
global base_header
domain_list = []
info_url = "https://hlwicpfwc.miit.gov.cn/icpproject_query/api/icpAbbreviateInfo/queryByCondition"
base_header.update(
{"Content-Length": "78", "uuid": p_uuid, "token": token, "sign": sign}
)
max_retries = 3
for _ in range(max_retries):
try:
beian_info = requests.post(
url=info_url, json=info_data, headers=base_header, timeout=(3.06, 27)
).json()
if not beian_info["success"]:
if beian_info["code"] in [401, 429]:
# 如果遇到401或429错误,重新获取COOKIE和token
logging.info("[+] 正在获取Cookie,请稍等……")
cookie = retrieve_cookies()
base_header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32",
"Origin": "https://beian.miit.gov.cn",
"Referer": "https://beian.miit.gov.cn/",
"Cookie": f"__jsluid_s={cookie}",
}
if cookie != -1:
token = retrieve_token()
if token == -1:
raise CustomException("获取Token失败")
logging.info("[+] Retrieving Token, please wait……")
if token != -1:
logging.info("[+] Token retrieved, querying, please wait……")
check_data = retrieve_check_pic(token)
if check_data != -1:
sign = retrieve_sign(check_data, token)
p_uuid = check_data["key"]
if sign != -1:
base_header.update(
{
"Content-Length": "78",
"uuid": p_uuid,
"token": token,
"sign": sign,
}
)
continue
logging.error(
f'[-] 请求错误: CODE {beian_info["code"]} MSG {beian_info["msg"]}'
)
return domain_list
# 如果请求成功,处理数据并退出循环
# ...(省略处理数据的代码)
break
except Exception as e:
logging.error(f"[-] 意外错误: {e}")
return domain_list
return domain_list
def save_data(domain_list):
"""
打印最终结果,并保存数据至Excel表格,同时调整表格格式。
"""
# 计算需要写入表格的总行数,如果是空列表,即代表该域名没有备案信息,也有可能是获取信息失败了
total_row = len(domain_list)
if total_row == 1:
total_row = 0
elif total_row == 0:
logging.info("[!] 所查域名无备案")
return
logging.info(f"[+] 查询结果如下:\n\n{domain_list}")
# 将表格保存到当前目录的outs文件夹下
file_path = os.path.join(output_directory, "备案信息.xlsx")
# 存在对应文件,则读取表格追加写入,不存在则创建,并设置表格的标题、列宽、冻结窗格、文字布局等格式
if os.path.exists(file_path):
wb = xl.load_workbook(file_path)
ws = wb["备案信息"]
max_row = ws.max_row
start = max_row + 1
total_row = total_row + start
after_title = 0
else:
wb = xl.Workbook()
ws = wb.active
ws.title = "备案信息"
title_list = [
"域名主办方",
"域名",
"备案许可证号",
"网站备案号",
"域名类型",
"网站前置审批项",
"是否限制接入",
"审核通过日期",
]
for i in range(0, 8):
ws.cell(1, i + 1).value = title_list[i]
col_width = {
"A": 45,
"B": 40,
"C": 22,
"D": 24,
"E": 9,
"F": 15,
"G": 13,
"H": 21,
}
for k, v in col_width.items():
ws.column_dimensions[k].width = v
ws.freeze_panes = "A2"
start = 0
after_title = 2
# 写入查询数据
for j in range(start, total_row + 1):
for k in range(0, 8):
try:
ws.cell(j + after_title, k + 1).value = domain_list[j - start][k]
except:
continue
# 垂直居中
for row in range(ws.max_row):
for col in range(ws.max_column):
ws.cell(row + 1, col + 1).alignment = Alignment(
horizontal="center", vertical="center"
)
try:
wb.save(file_path)
except PermissionError:
logging.error("[!] 备案信息登记表格已打开,无法写入文件。如需写入,请关闭文件后重新执行!")
return -1
logging.info(f"[+] 查询结果保存在:{file_path}")
return "OK"
import time
def main(input):
try:
query_count = 0 # 添加计数器
while True: # 添加一个无限循环
if query_count % 20 == 0: # 每20次查询后重新生成COOKIE和token
logging.info("[+] 正在获取Cookie,请稍等……")
cookie = retrieve_cookies()
global base_header
base_header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32",
"Origin": "https://beian.miit.gov.cn",
"Referer": "https://beian.miit.gov.cn/",
"Cookie": f"__jsluid_s={cookie}",
}
if cookie != -1:
token = retrieve_token()
logging.info("[+] Retrieving Token, please wait……")
if token != -1:
logging.info("[+] Token retrieved, querying, please wait……")
check_data = retrieve_check_pic(token)
if check_data != -1:
sign = retrieve_sign(check_data, token)
p_uuid = check_data["key"]
if sign != -1:
# If input is a file, perform batch check
if os.path.isfile(input):
# 获取文件行数作为进度条的总进度
with open(input) as f:
total = sum(1 for _ in f)
with open(input) as f, tqdm(
total=total, ncols=70, position=0, leave=True
) as pbar:
for line in f:
domain = line.strip()
logging.info(f"\n[+] 正在查询 {domain} ……")
info = query_base(domain)
domain_list = retrieve_beian_info(
info, p_uuid, token, sign
)
if domain_list:
logging.info(
f"\n{domain} 备案信息为:\n{domain_list}"
)
else:
logging.info(f"\n{domain} 不支持备案")
save_data(domain_list)
pbar.update()
time.sleep(8) # 设置间隔时间
query_count += 1 # 每次查询后增加计数器的值
else:
domain = input
info = query_base(domain)
domain_list = retrieve_beian_info(
info, p_uuid, token, sign
)
save_data(domain_list)
query_count += 1 # 每次查询后增加计数器的值
except CustomException as e:
logging.error(f"[-] {e}\n")
if __name__ == "__main__":
main(args.input)
检测到401重新生成cookie和token,就是429屏蔽设置8秒或10秒间隔都会被长时间封禁
还改了一个加代理池的版本,但是用代理IP会有SSL的问题
第一个:
所有单独.cn的域名一律提示不支持备案!但.org.cn .com.cn 这一类的正常
第二个:
域名备案条件判断的问题,似乎有点多余吧,管网域名后缀我随便输入都可以提交上去显示空记录,也并没有提示不支持
是否可以去掉这个域名限制备案的判断?目前来看这个判断把单独的CN域名全拦截了
第三个:
是否可以添加多线程?批量查询?目前我尝试可以一次性复制几十条到窗口也是可以批量,但是量还是太小,有数量限制,而且遇到报错的也不知道是哪条域名报错没查询成功,能否在输入窗口支持输入txt格式的文件?读取txt里面的内容一条一条查询,然后把查询到的结果报错的域名单独导出xlsx,成功的在另一个xlsx,这样可以明确知道哪些没成功,方便后续重查
第四个:
报错问题,以下是遇到过的错误:
获取Sign遇到错误,请重试!
The previously referenced variable "t_response"
计算图片缺口位置错误,请重试!
有时候重试几次就可以查出来有时候必须重启服务器才可以正常查询
方便留个TG的话最好 我每天查询域名备案量很大 可以帮助你完善程序
报错信息如下:
Traceback (most recent call last):
File "beian-info.py", line 26, in
File "requests\api.py", line 75, in get
File "requests\api.py", line 61, in request
File "requests\sessions.py", line 542, in request
File "requests\sessions.py", line 655, in send
File "requests\adapters.py", line 439, in send
File "urllib3\connectionpool.py", line 696, in urlopen
File "urllib3\connectionpool.py", line 964, in prepare_proxy
File "urllib3\connection.py", line 359, in connect
File "urllib3\connection.py", line 500, in connect_tls_proxy
File "urllib3\util\ssl.py", line 453, in ssl_wrap_socket
File "urllib3\util\ssl.py", line 495, in _ssl_wrap_socket_impl
File "ssl.py", line 500, in wrap_socket
File "ssl.py", line 997, in _create
ValueError: check_hostname requires server_hostname
[45304] Failed to execute script 'beian-info' due to unhandled exception!
大佬您好,感谢分享,现在使用发现cn域名无结果返回,能麻烦查看下接口是出现什么问题了吗
大佬更新一下没有你的脚本我可怎么活啊
优酷信息技术(北京)有限公司 这种无法识别到。
服务器请求报错521
apipost工具请求403
大佬,好像改图像算法了。完全失效了
求更新
获取Token,请等待……
已获取到Token,查询中,速度取决于网站响应,请等待……
计算图片缺口位置错误,请重试!
用不了了,官方是不是把接口改了
Hello, do you know of a similar project for Node? Thank you in advance.
基于Python3 + Vue3.js 技术栈实现的域名和SSL证书监测平台
https://github.com/mouday/domain-admin
您好,大佬
想请问 这一段
self.base_url = 'https://hlwicpfwc.miit.gov.cn/icpproject_query/api/'
self.auth_url = self.base_url + 'auth' # 返回token
self.image_url = self.base_url + 'image/getCheckImagePoint' # 返回Secretkey、uuid
self.check_url = self.base_url + 'image/checkImage' # 返回Sign,传值里的token是uuid
self.query_url = self.base_url + 'icpAbbreviateInfo/queryByCondition' # 标头需要:cookie、token、sign、uuid
Token, Secretkey, Uuid 都成功获取到了。
在 check_url 那边,是如何成功请求到的?它里面需要
{
"token": "xxx",
"secretKey": "xxx",
"clientUid": "xxx",
"pointJson": "xxx"
}
这个 pointJson是如何生成出来的呀?我这儿学习把逻辑移去PHP端上 卡在这边了 麻烦了 谢谢您。
https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth 接口500,获取不到token
2023-11-27 21:00:00 失效了~求大佬修复下
换成点文字的那种了
有亲告诉下现在好用了吗(12月8日)
ICP Query Extension
暂时只有 Chrome 浏览器
Browser Extension for ICP Query
一款开源的浏览器插件,方便以下功能:
https://github.com/yuedanlabs/icp-query-extension
最后,喜欢的话,不求 star,也不求评价,请尽情享用你的快乐时光吧😋
但如果你愿意放下繁忙的工作只为支持一下我们的开源,我们也非常感谢🙏 (点我去 star)
能否做成批量查询域名备案
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.