PhantomJS with Selenium error: Message: 'phantomjs' executable needs to be in PATH

后端 未结 7 1851
灰色年华
灰色年华 2020-12-05 13:59

I am attempting to run this script:

https://github.com/Chillee/coursera-dl-all

However, the script fails at the line session = webdriver.PhantomJS()

7条回答
  •  独厮守ぢ
    2020-12-05 14:48

    This will work perfectly.

    import platform
    from os import getcwd
    from selenium import webdriver
    
    if (platform.system() == 'Windows'):
    driver = webdriver.PhantomJS(executable_path=getcwd() + "\phantomjs")
    
    if (platform.system() == 'Darwin'):
    driver = webdriver.PhantomJS(executable_path=getcwd() + "/phantomjs")
    

提交回复
热议问题