下载自己的版本
ChromeDriver - WebDriver for Chrome - Downloadshttps://chromedriver.chromium.org/downloads
https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.jsonhttps://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
把下载好的程序 Google Chrome for Testing.app 解压到 /usr/local/bin/
双击打开试一下,如果打不开,
sudo xattr -d com.apple.quarantine /拖动APP
然后重命名为 chromedriver
.app扩展名也去掉
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
# 启动浏览器驱动
driver = webdriver.Chrome()
# 访问url
driver.get('https://www.baidu.com')
# 定位元素
el = driver.find_element(By.ID, 'kw')
# 执行自动化操作
el.send_keys('热搜')
driver.find_element(By.ID, 'su').click()
# 休眠5秒
sleep(5)
# 关闭浏览器并释放进程资源
# driver.quit()