dns轮训python
生活随笔
收集整理的這篇文章主要介紹了
dns轮训python
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
環境
python3
先安裝dnspython模塊 httpclient模塊 resolver模塊
pip install dnspython pip install hhtpclient pip install resolverdns輪訓(方法一)
import dns.resolver import os import http.client iplist = [] appdomain = 'www.baidu.com' def get_iplist(domain=''):try:A = dns.resolver.query(domain,'A')except Exception as e:print ("dns resolver error:"+str(e))return for i in A.response.answer:for j in i.items:iplist.append(j)return True def checkip(ip):checkurl = str(ip) + ':80'getcontent=''http.client.socket.setdefaulttimeout(20)#創建連接對象conn = http.client.HTTPConnection(checkurl)try:conn.request('GET','/',headers = {'Host': appdomain})r = conn.getresponse()getcontent = r.read(15)finally:if getcontent == b'<!DOCTYPE html>':print (str(ip)+' [ok]')else:print (str(ip)+' [Error]') if __name__ == "__main__":if get_iplist(appdomain) and len(iplist) > 0:for ip in iplist:checkip(ip)else:print('dns resolver error.')dns輪訓(方法二)
轉載于:https://www.cnblogs.com/Y139147/p/11295335.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的dns轮训python的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 淘宝开发平台知识点一,入门指南
- 下一篇: C#学习日志三(流程控制语句)