1
我有一個BeautifulSoup & Selenium腳本運行在Python 2.7中,它可以從終端完美工作,但不會作爲cron作業運行。Chrome 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')
任何人都可以提出建議的問題。
但是,當我在crontab -e下運行它時,它適用於我,所以我必須在系統上給它,而不是在我的客戶上。我如何設置它? – HenryM
@ e4c5我很抱歉,但我不明白爲什麼這意味着它會在我的系統上工作,當我輸入它但它不能在我的客戶系統上運行。我明顯缺乏對cron的理解,但是當我使用crontab -e輸入作業時,它在我的服務器上運行。然後設置 – HenryM
它創建上面顯示的回溯錯誤,而在我的系統上腳本運行並完成其任務 – HenryM