示例:Linux/MacOS 中使用 `whois`
bash
cat domains.txt | while read line; do echo $line && whois $line | grep No match for; done
`domains.txt` 是包含所有要查询的域名的文件,每行一个域名。
如果输出中出现 `No match for domain` 表示该域名未注册。
Python 脚本示例:
你可以使用第三方库如 `pythonwhois` 来批量查询。
安装:
bash
pip install pythonwhois
Python 脚本:
python
import whois
with open('domains.txt', 'r') as f:
domains = [line.strip() for line in f]
for domain in domains:
try:
w = whois.whois(domain)
if not w.domain_name:
print(f{domain} 可用)
else:
print(f{domain} 已注册)
except Exception as e:
print(f{domain} 查询失败: {e})