2016-11-14 9 views
1

私はBeautifulSoupを持っています& Python 2.7で動作するSeleniumスクリプトは、端末からは完全に動作しますが、cronジョブとしては動作しません。それが失敗を開始しクロムのwebdriverはcronから開けません

Traceback (most recent call last): 
File "sel_hourly.py", line 50, in <module> 
with closing(Chrome(chrome_options=options)) as driver: 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__ 
desired_capabilities=desired_capabilities) 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__ 
self.start_session(desired_capabilities, browser_profile) 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session 
response = self.execute(Command.NEW_SESSION, capabilities) 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute 
self.error_handler.check_response(response) 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response 
raise exception_class(message, screen, stacktrace) 
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally 
(Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.8.0-22-generic x86_64) 

ライン50は、以下の中のステートメントである:

options = webdriver.ChromeOptions() 
options.add_argument("--start-maximized") 
with closing(Chrome(chrome_options=options)) as driver: 
    driver.get(url) 
    # wait for the page to load 
    time.sleep(1) 
    # store it to string variable 
    page_source = driver.page_source 
    soup = bs4.BeautifulSoup(page_source,'lxml') 

は、誰もが問題に助言でし

は、私は、次のトレースバックを取得します。

+0

しかし、それは私がcrontab -eの下で実行すると私のために働くので、私は自分のシステム上でそれを与えておかなければなりません。どうすれば設定できますか? – HenryM

+0

@ e4c5申し訳ありませんが、私はそれが私のシステム上で動作することを意味する理由は理解していませんが、それは私の顧客のシステム上で実行されません。私は明らかにcronの理解が不足していますが、crontab -eを使用してジョブに入ると、サーバ上で動作します。その後、セットされたとき – HenryM

+0

私は上記のトレースバックエラーを生成していますが、私のシステムではスクリプトが実行されてタスクが完了します – HenryM

答えて

0

私の解決策は、firefoxに切り替えて、pyvirtualdisplayを実装してディスプレイを模倣することでした。

関連する問題