3

Windows 7, Python 3.4, PyCharm Community Edition 3.1.1

I'm new to Python. I want to get the html of a website. I use the following code:

from urllib.request import urlopen
response = urlopen('http://python.org/')
html = response.read()

But I get the following error:

urllib.error.URLError: <urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>

I believe, the problem might come from this:

>>> import urllib
>>> urllib.request.getproxies()
{}

Any ideas, if that is the problem and how can I fix it?

7
  • @ alfasin: Can you please tell me what is returned when you enter the following commands in the python console? >>> import urllib >>> urllib.request.getproxies() Commented May 23, 2014 at 10:21
  • It looks like your Puthon installation is brocken, because it fails to import the default packages. You should re-download the newest version and retry. Also, are you behind a proxy? Commented May 23, 2014 at 10:27
  • I don't have any reasons to believe that it is broken. I believe I just haven't set the proxies. I'm on a company computer, so I have no idea what the connection is... Commented May 23, 2014 at 10:31
  • possible duplicate of Python: URLError: <urlopen error [Errno 10060] Commented May 23, 2014 at 10:51
  • Those posts simply confirm that the problem is that there is no proxy, as I have said here, but doesn't explain how to set one... Commented May 23, 2014 at 11:00

0

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.