title: Save HTML of some website in a txt file with python
body: <p>I need save the HTML code of any website in a txt file, is a very easy exercise but I have doubts with this because a have a function that do this:</p>
  
  <pre><code>import urllib.request
  
  def get_html(url):
      f=open('htmlcode.txt','w')
      page=urllib.request.urlopen(url)
      pagetext=page.read() ## Save the html and later save in the file
      f.write(pagetext)
      f.close()
  </code></pre>
  
  <p>But this doesn't work.</p>