(Note) python + selenium + Chrome implemented on Mac and win systems

Mac verification failed, the specific reason has not been found.

Step one, download the necessary drivers first:

Download the latest version of Chromedriver:

https://googlechromelabs.github.io/chrome-for-testing/

And version selection: https://sites.google.com/chromium.org/driver/downloads/version-selection

Other download methods:

1. Google Chrome driver acquisition address: http://chromedriver.storage.googleapis.com/index.html

2. Firefox browser driver acquisition address: https://github.com/mozilla/geckodriver/releases

3. Edge browser driver acquisition address: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

After the download is complete, place it in the root directory:

Mac environment configuration

# 1、将ChromeDriver解压后
# 2、将ChromeDriver 拷贝一份至 

sudo CP -R /Application/path  /usr/local/bin

# 其中/Application/path ,ChromeDriver的解压路径

3、复制完成后,在terminal中进行环境配置

vim ~/.bash_profile

export PATH="$PATH:/usr/local/bin/chromedriver"

4、保存后,再运行
source ~/.bash_profile

 

Win environment configuration

解压后,直接放至项目的根目录下记即可

Step 2: Run jupyter notebook based on conda virtual environment

Step three, install selenium

!pip install selenium

Try the program on win

from selenium import webdriver
driver =webdriver.Chrome()
url = "https://www.baidu.com"
driver.get(url)
driver.close()

Guess you like

Origin blog.csdn.net/qq_23938507/article/details/132939295