selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exite

用python写了个爬虫,pycharm中运行正常,linux下crontab运行报错

linux下运行报错:

    selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exite

先执行一下两句安装命令(以ubuntu为例):

    sudo pip install pyvirtualdisplay

    sudo apt-get install xvfb

然后添加如下代码:

    from pyvirtualdisplay import Display

    display = Display(visible=0, size=(800, 800))

    display.start()

    driver = webdriver.Chrome()

 

你可能感兴趣的:(爬虫)