从cronjob中的脚本启动phantomJS

Jon*_*han 8 python cron crontab phantomjs

我正在通过cronjob运行python脚本.我有一个虚拟环境,在cronjob中,我正在通过这个虚拟环境运行它.当我运行脚本时,通常phantomJS应该启动它,但是通过cronjob中的脚本运行它我得到了这个错误.cronjob中缺少什么才能启动phantomjs?

Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen
Traceback (most recent call last):
  File "/home/scraper/superfish-extension/chrome_3day.py", line 96, in <module>
    main()
  File "/home/scraper/superfish-extension/chrome_3day.py", line 73, in main
    browser = use_phantomjs()
  File "/home/scraper/superfish-extension/chrome.py", line 81, in use_phantomjs
    browser = webdriver.PhantomJS()
  File "/home/scraper/.virtualenvs/superfish/lib/python2.6/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 50, in __init__
    self.service.start()
  File "/home/scraper/.virtualenvs/superfish/lib/python2.6/site-packages/selenium/webdriver/phantomjs/service.py", line 69, in start
    raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
WebDriverException: Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen
Run Code Online (Sandbox Code Playgroud)

Art*_* B. 14

由于可能安装了幻像/usr/local/bin,您应该PATH在crontab中添加该dir .以下应该做的伎俩:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Run Code Online (Sandbox Code Playgroud)