zoukankan      html  css  js  c++  java
  • Python+Selenium

    Chrome Firefox

    下载浏览器版本对应的驱动文件后,放在D:Program Files (x86)PythonPython38路径下,Python使用时用 driver = webdriver.Chrome()  即可

    火狐  driver = webdriver.Firefox()

    突发问题:Chrome自动更新,导致驱动版本不匹配。解决方法:停止Chrome的自动更新,不然每次都要重新下载驱动

    Edge 

    下载驱动后要在浏览器安装路径下放一个:C:Program Files (x86)MicrosoftEdgeApplication

    又要在Python安装路径下放一个D:Program Files (x86)PythonPython38

    并且使用时要 driver = webdriver.Edge("C:Program Files (x86)MicrosoftEdgeApplicationmsedgedriver.exe")

    否则会报错

    WebDriverException(
    selenium.common.exceptions.WebDriverException: Message: 'MicrosoftWebDriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687

    IE

    驱动的版本号是看selenium的版本号,不是看IE浏览器的。

    先查看selenium版本号,在cmd窗口输入 pip list ,查询电脑已安装的所有第三方库,其中就有selenium

     知道selenium版本号后,下载驱动 http://selenium-release.storage.googleapis.com/index.html

     下载后解压,把驱动文件放在 D:Program Files (x86)PythonPython38  (同Chrome/火狐同样做法),即可

    使用命令 driver = webdriver.Ie()

  • 相关阅读:
    第九章、查找
    opencv- python使用
    opencv初入
    初入
    第四章、数学问题
    数据结构
    分享一个SQLSERVER脚本
    详解SQL语句的集合运算
    数据库权限分配探讨
    数据库分区分表以及读写分离
  • 原文地址:https://www.cnblogs.com/sue2015/p/14846187.html
Copyright © 2011-2022 走看看