1. 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")

     

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM