当前位置: 首页 > news >正文

电子商务网站面临的安全隐患小红书网站开发费用

电子商务网站面临的安全隐患,小红书网站开发费用,智慧团建网站密码忘了,网站优化工具升上去以前通过ChromeDriverManager().install()的方式自动下载驱动的方式#xff0c;现在行不通了#xff0c;访问不通下载网址#xff0c;会报错#xff1a;requests.exceptions.ConnectionError: Could not reach host. Are you offline? 所以想着换一个下载地址和方式…以前通过ChromeDriverManager().install()的方式自动下载驱动的方式现在行不通了访问不通下载网址会报错requests.exceptions.ConnectionError: Could not reach host. Are you offline? 所以想着换一个下载地址和方式通过国内的镜像https://registry.npmmirror.com/binary.html?pathchrome-for-testing/下载。 通过接口返回分析发现该网站获取驱动版本的地址为https://registry.npmmirror.com/-/binary/chrome-for-testing/ 最终的下载地址前缀为 https://cdn.npmmirror.com/binaries 于是有了下面 的代码通过windowsAPI获取安装的浏览器的版本通过上面的地址获取浏览器驱动版本列表信息找到与浏览器大版本号相同的最新版本的驱动版本拼接成最终的下载地址。下载驱动压缩包用解压缩出来的驱动exe文件替换原来的旧文件然后删除解压缩文件和下载的压缩文件。 根据浏览器版本更新驱动为对应版本的驱动文件 pip install requests pip install pywin32 import os import zipfile import requests from win32com import client import shutildef get_version_by_path(exe_path):通过谷歌浏览器的安装路径下的.exe获取浏览器版本exe_path 浏览器exe程序文件完整路劲如C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe# 判断路径文件是否存在if not os.path.isfile(exe_path):raise FileNotFoundError(f{exe_path} is not found.)version client.Dispatch(Scripting.FileSystemObject).GetFileVersion(exe_path)return version.strip()def get_download_url(version, browser_namechrome): 获取与版本适配的驱动文件的下载地址 version为浏览器版本browsern_name为浏览器名称download_url https://cdn.npmmirror.com/binariesroot https://registry.npmmirror.com/-/binary/chrome_path chrome-for-testing/edge_path edgedriver/gecko_path geckodriver/version_url root chrome_pathif browser_name edge:version_url root edge_path# 获取与当前版本匹配的最大版本的下载地址response requests.get(urlversion_url)if response.status_code 200:version_list eval(response.text)for i in range(len(version_list)):dic version_list[i]if int(dic[name].split(.)[0]) int(version.split(.)[0]):driver_version version_list[i - 1][name]if browser_name chrome:download_url f{download_url}/chrome-for-testing/{driver_version}win64/chromedriver-win64.zipif browser_name edge:download_url f{download_url}/edgedriver/{driver_version}edgedriver_win64.zipreturn download_urldef download_driver(url, file_path, browser_namechrome): 下载驱动文件到指定路径url 为文件下载地址filepath 为文件保存下载文件的文件夹driver_file chromedriver.exeif browser_name edge:driver_file msedgedriver.exe# 通过requests下载文件save_path f{file_path}{os.sep}{url.split(/)[-1]}response requests.get(url, streamTrue)response.raise_for_status()with open(save_path, wb) as file:for chunk in response.iter_content(chunk_size16384):file.write(chunk)# 如果原来存在驱动文件则先删除原有的驱动文件if os.path.exists(f{file_path}{os.sep}{driver_file}):os.remove(f{file_path}{os.sep}{driver_file})# 解压下载的压缩文件并将驱动文件复制到filepath下with zipfile.ZipFile(save_path, r) as zip_file:file_list zip_file.namelist()for file in file_list:if file.endswith(driver_file):zip_file.extract(file, pathfile_path)if / in file:shutil.copy(f{file_path}{os.sep}{file}, f{file_path}{os.sep}{driver_file})shutil.rmtree(f{file_path}{os.sep}{file.split(/)[0]}) # 删除解压后的文件夹breakos.remove(save_path) # 删除下载的压缩文件def update_driver(driver_path, browser_name, browser_exe_file):更新驱动文件为当前浏览器版本对应的驱动driver_path 为保存驱动文件的路径browser_name 为浏览器的名称browser_exe_file 为浏览器安装路径下的.exe文件的完整文件名browser_version get_version_by_path(browser_exe_file)download_url get_download_url(browser_version, browser_name)download_driver(download_url, driver_path, browser_name)if __name__ __main__:driver_path ./browser_name chromebrowser_exe C:/Program Files/Google/Chrome/Application/chrome.exeupdate_driver(driver_path, browser_name, browser_exe)
http://www.hkea.cn/news/14502320/

相关文章:

  • 梧州推广网站服务商做网站不推广管用吗
  • 网站流量高iis如何做负载均衡wordpress 100并发
  • 网站后台管理系统开发做网站设像素
  • 专业网站制作软件网页制作软件ai
  • 庆阳网站设计服务免费网站教程
  • 自媒体135网站大渡口的网站开发公司
  • 帮开设赌场的网站做美工株洲网站设计公司
  • 国外网站seo四平网站建设哪家效果好
  • 珠宝网站源码网站域名注册后怎么建设
  • 做购物网站需要什么wordpress自己写代码
  • app网站开发重庆杨庄网站建设
  • 网站建设模板的wordpress社区主题
  • 兰州网站建设怎么选小网站文案
  • 深圳福田网站制作了解网站开发 后台流程
  • 学做网站的步骤上海电子商城网站制作
  • 宝山专业做网站英语网站排名
  • 微信公众号可以做网站嘛音乐app详情页设计
  • 江苏建设通网站大型广告公司有哪些
  • 中企动力网站建设方案温州文成县高端网站设计
  • wordpress 没有分类目录大地seo视频
  • 临沂网站定制洛阳做网站优化
  • 北京的电商平台网站有哪些株洲今天最新通知
  • 网站建设视频教程phpmi2设计公司网站
  • 网站建设服务市场aspx网站实例
  • 网站做好后北京网站平台建设
  • 福建微网站建设域名大全
  • 做淘宝网站的主机湖北网络建设公司网站
  • 前端如何兼职做网站潍坊专业做薪酬绩效
  • 做推广便宜的网站龙川县建设网站
  • 网站建设公司织梦模板百度制作网站