🗣 SL提问: 批量域名查询工具
✍️ Ai批改: 以下是一个基于Python的批量域名查询工具示例代码,使用`whois`库获取域名注册信息:
python
import whois
import csv
import time
from datetime import datetime
def query_domain_info(domain):
try:
w = whois.whois(domain)
return {
'domain_name': w.domain_name,
'registrar': w.registrar,
'creation_date': w.creation_date,
'expiration_date': w.expiration_date,
'updated_date': w.updated_date,
'name_servers': w.name_servers,
'status': w.status,
'emails': w.emails,
'registrant_organization': w.org if hasattr(w, 'org') else 'N/A'
}
except Exception as e:
return {'error': f'查询失败: {str(e)}'}
def batch_query_domains(domain_list, output_file='domain_results.csv'):
results = []
with open(domain_list, 'r') as f:
domains = [line.strip() for line in f if line.strip()]
for domain in domains:
print(f正在查询: {domain})
result = query_domain_info(domain)
result['domain'] = domain
results.append(result)
time.sleep(1) 避免查询频率过高
保存为CSV文件
with open(output_file, 'w', newline='', encoding='utf-8') as f:
fieldnames = ['domain', 'domain_name', 'registrar', 'creation_date',
'expiration_date', 'updated_date', 'name_servers', 'status',
'emails', 'registrant_organization', 'error']
writer = csv.DictWriter(f, fieldnames=fieldnames)
writer.writeheader()
for row in results:
writer.writerow(row)
print(f查询完成,结果已保存至 {output_file})
if __name__ == __main__:
domain_list_file = 'domains_to_check.txt' 包含域名列表的文本文件
batch_query_domains(domain_list_file)
使用说明:
1、安装依赖:
bash
pip install python-whois
2、准备域名列表文件(domains_to_check.txt):
example.com
google.com
github.com
yourdomain.com
3、运行脚本:
bash
python domain_checker.py
功能特点:
支持批量域名查询
自动保存为CSV格式
包含域名状态、注册商、过期时间等信息
自动添加查询间隔避免IP封锁
输出示例(CSV文件内容):
domain,domain_name,registrar,creation_date,expiration_date,updated_date,name_servers,status,emails,registrant_organization,error
example.com,EXAMPLE.COM,MarkMonitor Inc.,2023-05-15 10:30:00,2024-05-15 10:30:00,2023-05-16 08:20:00,['NS-1234.BIZ.NS', 'NS-4567.CO.NS'],'clientDeleteProhibited https://icann.org/eppclientDeleteProhibited',admin@example.com,Example Organization,Inc.,
注意事项:
1、部分域名可能返回不完整信息(.cn等特殊域名)
2、请遵守各域名注册商的查询限制
3、可修改`time.sleep(1)`调整查询间隔
4、建议使用代理IP进行大规模查询
5、需要处理可能的反爬机制
扩展建议:
添加代理支持
集成WHOIS查询API(如WhoisXML API)
添加域名年龄计算功能
可视化界面(使用Tkinter或Web框架)
增加域名可用性判断功能
支持多线程查询加速
如果需要更专业的解决方案,可以考虑使用商业API服务:
1、WhoisIC (https://www.whois.ic)
2、DomainTools (https://www.domaintools.com)
3、Aliyun Domain WHOIS (https://whois.aliyun.com)
4、AWS Route 53 Domain Registration
0
IP地址: 53.123.203.137
搜索次数: 4
提问时间: 2025-07-12 17:35:36
❓️ 热门提问:
什么是域名解析服务
天水黄金公司
外汇转换器
金戒指女女
555
1万炒外汇一年能挣多少钱
金号赤金
audemars piguet黄金表
黄金现在卖一克多少钱
山东栖霞金矿事故
豌豆Ai站群搜索引擎系统
🤝 关于我们:
三乐Ai
作文批改
英语分析
在线翻译
拍照识图
Ai提问
英语培训
本站流量
联系我们
📢 温馨提示:本站所有问答由Ai自动创作,内容仅供参考,若有误差请用“联系”里面信息通知我们人工修改或删除。
👉 技术支持:本站由豌豆Ai提供技术支持,使用的最新版:《豌豆Ai站群搜索引擎系统 V.25.05.20》搭建本站。