用Python实现批量扫描域名是否存在指定文件
初学Python练手项目,直接上代码,后续技术进步了可以加上指定字典扫描,现在还不会^_^
加上并发的话扫描速度会更快,现在也不会~
1 import requests 2 3 with open('domains.txt','r') as file: 4 domains =[line.strip() for line in file] 5 for domain in domains: 6 try: 7 response = requests.get(f'http://{domain}/admin') 8 if response.status_code == 200: 9 with open('res.txt','a') as file: 10 file.write(f'http://{domain}/admin\n') 11 except: 12 print(f'域名{domain}无法访问') 13
运行结果