Installation and use of the Selenium (a) of the Selenium ---

I. Introduction

  Recently crawling web content to help a teacher, I found the page is loaded dynamically, in order to get all of the pages of data, used here to Selenium. Selenium is a tool for Web application testing, which can simulate the real browser, supports multiple browsers, but is run directly in the browser, just as real users in the same operation.

  Environment: win10 64 bit + python3.6 + chrome 78.0.3904.108 64 bit

Second, the installation

Note: The following installation configurations are all reference blogger's own system environment settings

1.python install selenium command:

  pip install selenium

2. Download chromedriver.exe

  chromedriver.exe file is to call the chrome drivers, various versions of the Google browser corresponding to different chromedriver, so here we must select the correct chromedriver according to their chrome version. Download chromedriver of: http://chromedriver.storage.googleapis.com/index.html 

  For example, my chrome version 78.0.3904.108, as follows:

  

  So, I chose chromedriver version would look like this :( above does not 78.0.3904.108, so I just choose a little higher than this version on OK, obviously 78.0.3904.105 version is lower than 108, and is 78.0.3904.11 suitable)

  

   Select chromedriver_win32.zip download

  

3. chromedriver.exe downloaded into the chrome installation directory, as follows:

4. Set the system environment variable to the path of chrome added to the Path, as follows:

 

Third, the basic use

After the above Selenium environment installed and configured, you can write a program to test the python

Test code is as follows:

from selenium import webdriver
# 打开chrome浏览器(需提前安装好chromedriver)
browser = webdriver.Chrome()
print("正在打开网页...")
browser.get("http://www.baidu.com")

效果如下:

 

 

 

Guess you like

Origin www.cnblogs.com/FHC1994/p/11966553.html