1. 程式人生 > >今天刷新系統明天再寫日記

今天刷新系統明天再寫日記

import urllib.request
url="https://blog.csdn.net/weiwei_pig/article/details/51178226"
file=urllib.request.urlopen(url)

# url="https://blog.csdn.net/weiwei_pig/article/details/51178226"
# headers=("User-Agent","Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Mobile Safari/537.36")
# opener=urllib.request.build_opener() # opener.addheaders=[headers] # data=opener.open(url).read() # # fhandle=open("C:/mymodules/3.html","wb") # fhandle.write(data) # fhandle.close() url="https://blog.csdn.net/weiwei_pig/article/details/51178226" req=urllib.request.Request(url) req.add_header("User-Agent
","Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Mobile Safari/537.36") data1=urllib.request.urlopen(req).read() fhandles=open("C:/mymodules/3-1.html","wb") fhandles.write(data1) fhandles.close()