Linuxでselenium+chromedriver爬虫類を利用してエラーを報告

592 ワード

エラー:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.10.0-42-generic x86_64)
解決策:
Start the Display before start the Chrome. 
まず、ubuntuを例に2つのインストールコマンドを実行します.
pip install pyvirtualdisplay
sudo apt-get install xvfb

次に、次のコードを追加します.
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 800))  
display.start()
driver = webdriver.Chrome()