python判断远程端口是否打开

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

python判断远程端口是否打开,下面的代码判断指定网站的80端口是否打开

import socket
sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sk.settimeout(1)
try:
    sk.connect(('www.open-open.com',80))
    print 'Server port 80 OK!'
except Exception:
    print 'Server port 80 not connect!'
sk.close()