def connectgood(good): 2 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 3 s.connect((good, 80)) 4 s.sendall(b'GET / HTTP/1.1\r\n'+good+'\r\n\r\n') 5 data = s.recv(1024) 6 print(data) 7 s.close() 1 for i in L: 2 connectgood(i) --------------------------------------------------------------------------- gaierror Traceback (most recent call last) <ipython-input-20-7bb3af0dd477> in <module>() 1 for i in L: ----> 2 connectgood(i) <ipython-input-19-dce36beb6b6a> in connectgood(good) 1 def connectgood(good): 2 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ----> 3 s.connect((good, 80)) 4 s.sendall(b'GET / HTTP/1.1\r\n'+good+'\r\n\r\n') 5 data = s.recv(1024) gaierror: [Errno 11001] getaddrinfo failed
时间: 2023-05-19 14:01:36 浏览: 104
tcp.zip_socket客户端
这段代码中出现了一个错误,具体来说是 "gaierror: [Errno 11001] getaddrinfo failed",这个错误通常是由于无法解析主机名或者IP地址导致的。建议检查一下传入的参数是否正确,或者尝试使用IP地址代替主机名。
阅读全文