本文介绍了从cronjob中的脚本启动phantomJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm running a python script through a cronjob. I have a virtual environment and in the cronjob I'm running it through this virtual environment. When I run the script normally phantomJS starts as it should, but running it through a script in a cronjob I get this error. What is missing in the cronjob to be able to start 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


推荐答案

/ usr / local / bin ,您应该将该目录添加到crontab中的 PATH 。下面应该做的诀窍:

As phantom is probably installed in /usr/local/bin, you should add that dir to PATH in your crontab. The following should do the trick:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

这篇关于从cronjob中的脚本启动phantomJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 09:11