python3.5+selenium 3.141.0+Firefox67安装

  • 我的电脑已安装python3.5并配置号环境变量
    1. 验证python安装无异常:在cmd中输入python,显示安装的python版本号
  • 在官网下载Firefox:https://www.firefox.com.cn
  • 下载对应版本的geckodriver:https://github.com/mozilla/geckodriver/releases,并将geckodriver.exe放置python安装根目录下,与python.exe同级
  • 打开cmd,准备安装selenium
    • 输入pip
    • cmd输入指令安装在线安装selenium
      • >pip install selenium==2.53.6
      • 等到进度显示100%,安装完成
      • 提示有可用的新版本安装: python -m pip install --upgrade pip
    • 检查selenium环境
      • 输入以下语句,查看firefox是否打开
      • python
        >>> from selenium import webdriver
        >>> webdriver.Firefox()

      • 如果误输入为firefox,会报error

      • 提示error sessionid,更新selenium版本:pip install -U selenium
  • 至此环境搭建完成,打开百度首页
  • python
    >>> from selenium import webdriver
    >>>driver=webdriver.Firefox()
    >>>driver.get("https://www.baidu.com")

  

猜你喜欢

转载自www.cnblogs.com/Arcy/p/11069067.html