What is the best way to "get" a web page?

Pete harbingerofpeace at post.com
Sat Sep 23 23:22:03 EDT 2006


I have the following code:

>>> web_page = urllib.urlopen("http://www.python.org")
>>> file = open("temp.html", "w")
>>> web_page_contents = web_page.read()
>>> file.write(web_page_contents)
>>> file.close
<built-in method close of file object at 0xb7cc76e0>
>>>

The file "temp.html" is created, but it doesn't look like the page at
www.python.org. I'm guessing there are multiple frames and my code did
not get everything. Can anyone point me to a tutorial or other
reference on how to "get" all of the html contents at a particular
page?

Why did Python print the line after "file.close"?

Thanks,
Pete




More information about the Python-list mailing list