By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

How to download web page using python code?

P: 2
Hi all, I am new bee in Python programming...
I am trying to download web page using python code

code:
import urllib

# Get a file-like object for the Python Web site's home page.

f = urllib.urlopen("http://www.python.org")

# Read from the object, storing the page's contents in 's'.

s = f.read()

f.close()

and ERROR is
Traceback (most recent call last):
File "C:\Python26\clk.py", line 5, in <module>
f = urllib.urlopen("http://www.python.org")
File "C:\Python26\lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\Python26\lib\urllib.py", line 203, in open
return getattr(self, name)(url)
File "C:\Python26\lib\urllib.py", line 338, in open_http
h.endheaders()
File "C:\Python26\lib\httplib.py", line 868, in endheaders
self._send_output()
File "C:\Python26\lib\httplib.py", line 740, in _send_output
self.send(msg)
File "C:\Python26\lib\httplib.py", line 699, in send
self.connect()
File "C:\Python26\lib\httplib.py", line 683, in connect
self.timeout)
File "C:\Python26\lib\socket.py", line 498, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
IOError: [Errno socket error] [Errno 11001] getaddrinfo failed

Please let me know how it is comming....
Thank you well in advance.....
Dec 2 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 621
It works fine for me. Perhaps there is a firewall or some other impediment that must be traversed.
Dec 2 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.