用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         
复制代码

运行结果

 

 

posted @   华中第一黑  阅读(32)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示