Save HTML of some website in a txt file with python -
Save HTML of some website in a txt file with python -
i need save html code of website in txt file, easy exercise have doubts because have function this:
import urllib.request def get_html(url): f=open('htmlcode.txt','w') page=urllib.request.urlopen(url) pagetext=page.read() ## save html , later save in file f.write(pagetext) f.close()
but doesn't work.
easiest way utilize urlretrieve:
import urllib urllib.urlretrieve("http://www.example.com/test.html", "test.txt")
python html parsing python-3.x urllib
Comments
Post a Comment