立即学习:https://edu.csdn.net/course/play/24756/280658?utm_source=blogtoedu
import urllib.request as ur
import user_agent
request = ur.Request(
url='http://xxx.xxx.xxx',
headers={
'User-Agent':user_agent.get_pc()
}
)
result = ur.urlopen(request).read()
with open('xxx.html','wb') as f:
f.write(result)
#将爬取的页面写到本地