I am trying to open a webpage and write the page in a text file. This is the code so far and its not working. Cam anyone give me a general idea about what I am doing wrong?
import urllib
opener = urllib.FancyURLopener({})
f = opener.open("http://www.python.org/")
g = open("data2.txt", "w")
g.write(str(f)) # str() converts to string
g.close()
All I gets when executing the code is text file data2.txt with below line only:
<addinfourl at 43347592L whose fp = <socket._fileobject object at 0x000000000294C480>>