python-web automation environment to build

1, download the browser, Chrome

2, download the browser drive, and unzip

Address: http://npm.taobao.org/mirrors/chromedriver/ 

Note: you need to download and browser version corresponding drive, such as the browser version: Version 78.0.3904.97 (official version) (64), then you can drive 78 at the beginning of the download, if there are multiple, select the latest time to click into , find the corresponding system to download.

 

 

 

 

Attention to earlier, namely 78, 78 corresponding to the beginning of the drive download

 

 

 

 

 

 

3, the browser driving position

Mac directly to chromedriver.exe into / usr / local / bin this path.

 

windows directly into the python installation directory to the same directory with the python.exe, because when you install python has already been configured environment variables, so do not put here in the configuration. Can also be placed in other positions need to be added to the environment variable 

4, install selenium

cmd command-line installation. Use the following command to install selenium: pip install -U selenium.

Installation time out, it is recommended to replace domestic sources to download: https: //pypi.tuna.tsinghua.edu.cn/simple/

If ie, firefox, drivers only need to be replaced ieserverdriver, or geckodriver can. Other installation steps exactly the same.

 

5, check the installation is normal

Import webdriver the Selenium from 
# to open the Google browser
Driver = webdriver.Chrome ()
# access Baidu Home
driver.get ( "http://www.baidu.com")

If successful, the normal installation instructions 

 

Guess you like

Origin www.cnblogs.com/zhaoyuli/p/11863645.html