需要跑个web动态扫描, mac权限和chrome版本有多坑。
在2021年9.29,我的chrome是96,但是chromeDriver只支持到93…
如果你有问题:
[
](https://sites.google.com/a/chromium.org/chromedriver/home)
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
你需要下一个chromedriver, 一定要注意和你的chrome浏览器版本匹配, 不然还会报一个binary chrome 不匹配错误。
如果你不想全局安装的话,可以把chromedriver放到任意文件夹,然后:
from selenium.webdriver.remote.webdriver import WebDriverchrome_options = webdriver.ChromeOptions()driver = webdriver.Chrome(executable_path="/your_path/chromedriver", chrome_options = chrome_options)
如果你不想使用默认chrome浏览器,可以下个对应版本的chromium, 然后声明一下路径:
chrome_options = webdriver.ChromeOptions()chrome_options.binary_location = "/your_path/Chromium.app/Contents/MacOS/Chromiumdriver = webdriver.Chrome(executable_path="/your_path/chromedriver", chrome_options = chrome_options)
注意: MacOS下,要给Chromium和chromedriver权限~!
