Ubuntu下 DevToolsActivePort file doesn't exist 错误

错误描述

Ubuntu下运行一个selenium调用无头chrome浏览器进行爬取的Python程序报出如下的错误:

(unknown error: DevToolsActivePort file doesn't exist) 
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) 

解决办法

修改代码如下:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')

猜你喜欢

转载自blog.csdn.net/dta0502/article/details/84063658