注意网页源码的编码格式!
import requests
from urllib.request import urlopen
url = "http://www.baidu.com"
# resp = urlopen(url)
resp = requests.get(url)
with open("mybaidu.html", mode="w", encoding='utf-8') as f:
print(resp.content.decode("utf-8"))
print("over!")
resp = urlopen(url)
print(resp.read().decode('utf-8'))
爬虫其他知识可在我的其他blog中找到