我正在尝试通过 python 创建一个远程登录到 Teamspeak 3 服务器查询,这是我的代码:
__author__ = 'Khailz'
import telnetlib, socket
HOST = "unlightedgaming.com"
port = 10011
timeout = 5
for i in range(len(HOST)):
print "scanning " + HOST[i] + " ...\n"
try:
tn = telnetlib.Telnet(HOST[i],23,3)
except socket.timeout:
pass
#tn = telnetlib.Telnet(host, port, timeout)
#telnetlib.Telnet(host, port, timeout)
tn.read_until("Welcome to the TeamSpeak 3 ServerQuery interface")
print tn.read_all()
但我似乎从套接字中得到错误,说它无法获取地址。
C:\Python27\python.exe C:/Users/Khailz/PycharmProjects/Teamspeak-IRC/test.py
scanning 1 ...
Traceback (most recent call last):
File "C:/Users/KhailzXsniper/PycharmProjects/Teamspeak-IRC/test.py", line 14, in <module>
tn = telnetlib.Telnet(HOST[i],23,3)
File "C:\Python27\lib\telnetlib.py", line 211, in __init__
self.open(host, port, timeout)
File "C:\Python27\lib\telnetlib.py", line 227, in open
self.sock = socket.create_connection((host, port), timeout)
File "C:\Python27\lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed
我究竟做错了什么