0

Im currently having a problem with a Python program I made. The program is supposed to connect to google translate using the http.client module. My program works if im just connection to google.com, but it gives me an error when I try to connect to translate.google.com.

import urllib.request,re,http.client

while True:

  print('')
  question = input(">: ").replace(" ","%20").replace("?",'%3F')
  x = "/#auto/es/%s"%(question)
  conn = http.client.HTTPSConnection("www.translate.google.com",80)
  http.client.HTTPConnection.connect(conn)
  conn.request("GET",x)
  response = conn.getresponse()
  data = str(response.read())
  conn.close()
  print("Done")

Traceback (most recent call last):
  File "P:\CS5\translater.py", line 9, in <module>
    http.client.HTTPConnection.connect(conn)
  File "C:\Program Files\Python35-32\lib\http\client.py", line 826, in connect
  (self.host,self.port), self.timeout, self.source_address)
  File "C:\Program Files\Python35-32\lib\socket.py", line 693, in      create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Program Files\Python35-32\lib\socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed
  • 1
    can you include the error? – frederick99 Feb 22 '17 at 13:41
  • 1
    Possible duplicate of [urllib2.URLError: ](http://stackoverflow.com/questions/5022945/urllib2-urlerror-urlopen-error-errno-11004-getaddrinfo-failed) – Stefan Dorunga Feb 22 '17 at 13:54
  • Output of `host www.translate.google.com` on my computer: `Host www.translate.google.com not found: 3(NXDOMAIN)`. Are you sure you specified the right host name? – aha Feb 22 '17 at 18:46

0 Answers0