0

I am trying to run this code:

    import urllib
    htmlfile = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&ei=7VzrV6WWG8KC0ATxor_IDw")
    htmltext = htmlfile.read()
    print htmltext

But the following error is shown, when I run the code:

    Traceback (most recent call last):
    File "C:\Python27\newscrap.py", line 2, in <module>
    htmlfile = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&ei=7VzrV6WWG8KC0ATxor_IDw")
    File "C:\Python27\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
    File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
    File "C:\Python27\lib\urllib.py", line 443, in open_https
h.endheaders(data)
    File "C:\Python27\lib\httplib.py", line 997, in endheaders
self._send_output(message_body)
    File "C:\Python27\lib\httplib.py", line 850, in _send_output
self.send(msg)
    File "C:\Python27\lib\httplib.py", line 812, in send
self.connect()
    File "C:\Python27\lib\httplib.py", line 1208, in connect
HTTPConnection.connect(self)
    File "C:\Python27\lib\httplib.py", line 793, in connect
self.timeout, self.source_address)
    File "C:\Python27\lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
     IOError: [Errno socket error] [Errno 11004] getaddrinfo failed

Can anyone tell why this error occurs?

4
  • Is your firewall configured to allow requests from your apllication? Commented Sep 28, 2016 at 6:47
  • Does this work on the machine you are running on nslookup www.google.co.in? Commented Sep 28, 2016 at 6:56
  • Also you can always run ping google.co.in on the machine you are on to see if you get a response to help troubleshoot Commented Sep 28, 2016 at 7:18
  • no..It is not responding Commented Sep 28, 2016 at 8:15

1 Answer 1

1

It's a connection problem (your code works on my computer). Check your firewall / proxy settings / dns server / other connection settings.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.