【Python】MacOS安装ChromeDriver
一、下载对应版本的chromedriver


二、解压后放到目录:/usr/local/bin目录

三、解决Mac无法验证Chromedriver开发者身份问题
xattr -d com.apple.quarantine chromedriver
四、验证安装结果
#!/usr/bin/python3
from selenium.webdriver import Chrome
webdriver = Chrome()
time.sleep(5)

五、无头浏览器:从Selenium 4.0开始,官方已经不再支持PhantomJS作为WebDriver。PhantomJS是一个无头浏览器,但由于它不再被积极维护,改用Chrome的无头模式(使用ChromeOptions)
#!/usr/bin/python3 from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--headless") driver = webdriver.Chrome(options=chrome_options) driver.get("http://www.baidu.com") print(driver.page_source) driver.quit()
得意时做事,失意时读书

浙公网安备 33010602011771号