import urllib.request
url = 'http://yandex.ru'
html = urllib.request.urlopen(url).read()
f = open('page.html', 'w')
f.write(str(html))
html = urllib.request.urlopen(url).read().decode('utf-8').encode('cp1251')
import urllib.request
url = 'http://example.com'
html = urllib.request.urlopen(url).read().decode('cp1251')
f = open('page.html', 'w')
f.write(html)