我通过一个使用chromedriver的解析器收集评论,我在服务器上的celery任务中运行解析,我遇到了以下错误
(The process started from chrome location /home/ubuntu/.../chromedriver
is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
这是ChromeDriverManager返回的路径。
我需要以某种方式安装和配置服务器上的谷歌浏览器?这里我的 chrome 选项:
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--headless")
# Adding argument to disable the AutomationControlled flag
chrome_options.add_argument("--remote-debugging-port=9222")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("start-maximized")
# Exclude the collection of enable-automation switches
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_argument("window-size=1280,800")
# Turn-off userAutomationExtension
chrome_options.add_experimental_option("useAutomationExtension", False)
path = ChromeDriverManager().install()
chrome_options.binary_location = path #"/home/ubuntu/chromedriver"
service = Service(path)
driver = webdriver.Chrome(service=service, options=chrome_options)
1条答案
按热度按时间wribegjk1#
如果有人会面临同样的问题,尝试下载chromium-browser并更改binary_path=/usr/bin/chromium-browser,请记住,你必须设置相同的版本。