selenium 运行打开谷歌浏览器报错
主要原因是找不到浏览器路径
解决方案如下:
# -*- coding:utf-8 -*-
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('–no-sandbox')
chrome_options.add_argument('–disable-dev-shm-usage')
chrome_options.add_argument('–headless')
chrome_options.binary_location = "C:/Program Files/Google/Chrome/Application/chrome.exe" # 这里是你指定浏览器的路径
driver = webdriver.Chrome(executable_path='chromedriver.exe', options=chrome_options)
driver.get('https://www.baidu.com/')