title: Print web page source code in python
body: <p>I want to print a web page source code but python print command just prints empty space and I think it's because of its large size. Is there any way to print page source code in shell or at list in a file?
  I've tried printing in a file but this error occurred:</p>
  
  <pre><code>UnicodeEncodeError: 'charmap' codec can't encode character '\u06cc' in position 11826: character maps to &lt;undefined&gt;
  </code></pre>
  
  <p>How can I fix it?</p>
  
  <pre><code>import urllib.request
  response = urllib.request.urlopen('http://www.farsnews.com')
  html = response.read()
  
  print(html)#prints empty space! 
  
  hf=open('test.txt','w')
  a=str(html,'utf-8')
  hf.write(a)
  hf.close()
  </code></pre>
  
  <p>Python easily prints <code>a[0:1000]</code> but for <code>a[0:len(a)]</code> as I said empty space!</p>