您的位置:首頁技術文章
文章詳情頁

Python中使用Selenium環境安裝的方法步驟

瀏覽:88日期:2022-06-27 13:23:01
環境準備

已正確安裝python環境,已安裝chrome瀏覽器或者firefox瀏覽器使用 python --version 命令如果輸出python版本則python 安裝成功

安裝selenium

使用pip命令安裝selenium

pip install selenium

下載chrome驅動 或者firefox驅動

selenium的chrome驅動(國內阿里像)selenium的firefox驅動(github地址)

注意:下載對應版本的驅, 點擊瀏覽器三個點 - 幫助 - 關于Google Chrome 即可查看瀏覽器版本

Python中使用Selenium環境安裝的方法步驟

Python中使用Selenium環境安裝的方法步驟

將驅動放入環境變量

因為python 目錄是直接就在環境變量下的,可直接將驅動放于python目錄下

Python中使用Selenium環境安裝的方法步驟

編寫代碼測試selenium

from selenium import webdriverimport timedef hello(): driver = webdriver.Chrome() driver.get('https://www.baidu.com/') time.sleep(3) driver.quit()if __name__ == ’__main__’: hello()

如果能夠上面代碼能夠正常打開瀏覽器,就說明selenium已經安裝成功了

下一篇將編寫關于selenium 的具體使用

到此這篇關于Python中使用Selenium環境安裝的方法步驟的文章就介紹到這了,更多相關Python Selenium環境安裝內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Python 編程
相關文章:
国产综合久久一区二区三区