def download_taobao_chromedriver(): """ 下载淘宝镜像chromedriver http://npm.taobao.org/mirrors/chromedriver :return: """ # 获取版本号列表 url = "http://npm.taobao.org/mirrors/chromedriver/" result = BeautifulSoup(HttpUtil.get(url).text, features="lxml") prefix = result.find("pre").find_all("a") # 过滤 # info = [s.extract() for s in prefix('prefix')] local_version_url = url + get_local_version(prefix) # 获取版本下面的文件列表 driver_list = BeautifulSoup(HttpUtil.get(local_version_url).text, features="lxml") filename_list = driver_list.find_all("a") for s in filename_list: s = s.text # 如果在文件名中找到系统平台名称 if s.find(sys.platform) != -1: # 下载文件 HttpUtil.download_file(local_version_url + s, None, s) FileUtil.zip_extract(s, None)
def download_chromedriver(): """ 下载chrome驱动 http://chromedriver.storage.googleapis.com/index.html :return: """ # 获取版本号列表 url = "http://chromedriver.storage.googleapis.com/" result = BeautifulSoup(HttpUtil.get(url, { "delimiter": "/", "prefix": "" }).text, features="lxml") prefix = result.find_all("prefix") # 过滤 # info = [s.extract() for s in prefix('prefix')] local_version = get_local_version(prefix) # 获取版本下面的文件列表 driver_list = BeautifulSoup(HttpUtil.get(url, { "delimiter": "/", "prefix": local_version }).text, features="lxml") filename_list = driver_list.find_all("key") for s in filename_list: s = s.text # 如果在文件名中找到系统平台名称 if s.find(sys.platform) != -1: filename = s[len(local_version):] # 下载文件 HttpUtil.download_file(url + s, None, filename) FileUtil.zip_extract(filename, None)