[英]gaierror: [Errno -2] Name or service not known
def make_req(data, url, method='POST')
params = urllib.urlencode(data)
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain",
}
conn = httplib.HTTPSConnection(url)
conn.request(method, url, params, headers)
response = conn.getresponse()
response_data = response.read()
conn.close()
But it is throwing: in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno -2] Name or service not known
但它抛出:
in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): gaierror: [Errno -2] Name or service not known
What is the reason ? 是什么原因 ? What is this error?
这个错误是什么?
You need to call request() with the URI relative to the server. 您需要使用相对于服务器的URI调用request()。 If
url
is www.google.com/images?q=test
you have to do: 如果
url
是www.google.com/images?q=test
,则必须执行以下操作:
conn = httplib.HTTPSConnection('www.google.com')
conn.request('GET', '/images?q=test')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.