驱动地址
http://chromedriver.storage.googleapis.com/index.html
浏览器历史版本
https://mydown.yesky.com/pcsoft/105582038/versions/
python代码下载并且解压
from urllib import request
import zipfile
def fun(blocknum,blocksize,totalsize):
"""
blocknum:当前的块编号
blocksize:每次传输的块大小
totalsize:网页文件总大小
"""
percent = blocknum*blocksize/totalsize
if percent > 1.0:
percent = 1.0
percent = percent*100
print("download : %.2f%%" %(percent))
def chromedriver_download(pid,path):
'''
pid:驱动版本 浏览器和对应驱动可以在下面查看
http://chromedriver.storage.googleapis.com/index.html
https://mydown.yesky.com/pcsoft/105582038/versions/
path:保存的文件夹路径
'''
# pid = '85.0.4183.38'
# path = "LoginScript/data/"+pid+"/"
path=path + pid+"/"
if not os.path.exists(path):
os.makedirs(path)
filePath = path+"chromedriver_win32.zip"
opener = request.build_opener()
opener.addheaders = ([
("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"),
])
request.install_opener(opener)
request.urlretrieve("http://chromedriver.storage.googleapis.com/"+pid+"/chromedriver_win32.zip",filePath,fun)
f = zipfile.ZipFile(filePath,'r')
for file in f.namelist():
f.extract(file,path)
f.close()
os.remove(filePath)
chromedriver_download("84.0.4147.30","D:/APP/")
有的时候下载速度特别慢,也可能卡顿不知道为啥
网友评论