1. Download the browser driver
Taking the Chrome browser as an example, download the browser driver:
Download address of the Chrome browser driver
After opening, it will be such a page, and then check the version number of your browser and download the corresponding version driver.
Unzip after download, it will be an exe file
2. Install the client python library
pip install selenium
It can be installed directly through pip. If you use pycharm, you can see it after the installation is successful, as shown below
3. Write python code and open the browser
from selenium import webdriver
wd = webdriver.Chrome(r'D:\tmp\chromedriver_win32\chromedriver.exe')
Run the program directly, you can successfully open the chrome browser
tips: the code Chrome(r'D:\t
of a string r is meant to follow later in the \ deemed not escape
The opening effect is shown below:
4. Open the URL
from selenium import webdriver
wd = webdriver.Chrome(r'D:\tmp\chromedriver_win32\chromedriver.exe')
wd.get("https://www.baidu.com/")
wd.get("https://www.baidu.com/") 这句就是打开对应的网址
running result: