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:
UnicodeEncodeError: 'charmap' codec can't encode character '\u06cc' in position 11826: character maps to <undefined>
How can I fix it?
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()
Python easily prints a[0:1000] but for a[0:len(a)] as I said empty space!