#使用urllib库,将langlang2017全站网页请求并保存 #1、引入模块 from urllib import request from urllib import error#2、操作 #(1)创建url base_url = "http://www.langlang2017.com/route.html"try:# (2)请求urlreponse = request.urlopen(base_url,timeout=0.02)# (3)读取内容html = reponse.read()# (4)转码html = html.decode("utf-8")# (5)保存with open("route.html", "w", encoding="utf-8") as f:f.write(html)except error.URLError as e:print(e)