selenium:v3.7.0
First, the Google browser chromdriver.exe
According to their own Google browser version to install the corresponding chromedriver version.
My computer is version 65 of Google, installed v2.36 version, link: https: //pan.baidu.com/s/1_bGfVdpD5i4evNBz06qKkw Password: vl8d
Then chromedriver.exe files in Google Chrome installation directory C: \ Program Files (x86) \ Google \ Chrome \ under Application (other paths are also OK), and then add this to the path environment variable.
With the following code verification, able to jump to Baidu page, i.e. the installation was successful
1
2
3
|
from
selenium
import
webdriver
driver
=
webdriver.Chrome()
driver.get(
'https://www.baidu.com/'
)
|
Second, the Firefox browser: geckodriver.exe
The newest version of Firefox is not supported FireBug other development tools, you can https://ftp.mozilla.org/pub/firefox/releases/ download the following version of Firefox 49, you can increase the Firebug and other extensions.
I downloaded Firefox Firefox Setup 48.0b9.exe, after installation, the https://github.com/mozilla/geckodriver/releases/ download the latest version geckodriver, will geckodriver.exef in C: \ Program Files (x86) \ Mozilla under Firefox directory, and adding environment variables, and then run the following code, we found an error, check the Internet later found to be geckdriver version is too high, then replaced v15.0 version of the ok
1
2
3
|
from
selenium
import
webdriver
driver
=
webdriver.Firefox()
driver.get(
'https://www.baidu.com'
)
|
Three, IE11 browser: IEDriverServer.exe
IE浏览器驱动下载链接:http://selenium-release.storage.googleapis.com/index.html(需爬梯),安装最新版v3.9,将其放在C:\Windows\System32目录下(不用加入环境变量,默认在环境变量中),运行如下代码,发现报错如下,降低版本为3.0.0,重新运行代码发现成功。
1
2
3
|
from
selenium
import
webdriver
driver
=
webdriver.Ie()
driver.get(
'http://www.baidu.com'
)
|
from selenium import webdriver
#启动谷歌浏览器:
# driver = webdriver.Chrome()
#启动IE浏览器:
driver = webdriver.Ie()
#启动火狐浏览器:
# driver = webdriver.Firefox()
driver.get("http://www.baidu.com")