selenium python 安装
環(huán)境為Win64位系統(tǒng),默認已經(jīng)安裝python2.7到D:\Python27,此次使用的瀏覽器為chrome
下面是selenium的安裝和chromedriver.exe的下載
1.安裝selenium
Windows下安裝selenium
打開命令行cmd,到目錄D:\Python27\Scripts,輸入下面的命令
pip install selenium
回車后,你會看到下面的提示
Downloading/unpacking selenium Downloading selenium-2.38.1.tar.gz (2.5MB): 2.5MB downloaded Running setup.py egg_info for package selenium Installing collected packages: selenium Running setup.py install for selenium Successfully installed selenium Cleaning up...
2.下載chromedriver.exe
下載ChromeDriver驅動包(下載地址:?http://chromedriver.storage.googleapis.com/index.html?path=2.7/
找到對應所需的下載,Windows下沒有64位的,可用32位
指定ChromeDriver所在位置,可以通過兩種方法指定(我在此使用了第三種方法) 1)通過配置ChromeDriver.exe位置到path環(huán)境變量實現(xiàn)。 2)通過webdriver.chrome.driver.系統(tǒng)屬性實現(xiàn)。實現(xiàn)代碼如下: System.setProperty("webdriver.chrome.driver",?"C:\\Documents?and?Settings\\Administrator\\Local?Settings\\Application?Data\\Google\\Chrome\\Application\\chromedriver.exe") 3)把下載的chromedriver.exe直接放入D:\Python27文件夾下即可使用 ? 打開python,輸入from selenium import webdriver ? ? #引用
driver= webdriver.Chrome() ? ? ? ? ? #顯式打開瀏覽器
driver.get('https://www.baidu.com/') ?#跳轉到指定頁面
?
轉載于:https://www.cnblogs.com/zy900406/p/6089175.html
總結
以上是生活随笔為你收集整理的selenium python 安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: $.cookie is not a fu
- 下一篇: 批量更改文件编码格式 utf8到gb23