from urllib.request import Request,urlopen
for i in range(3):
url = 'http://hao123.zongheng.com/store/c0/w0/s0/p{0}/all.html'.format(i+1)
r = Request(url)
html = urlopen(r).read().decode()
filename = '網頁' + str(i+1) + '.html'
with open(filename,'w',encoding='utf-8') as f:
f.write(html)
print(html)