Is there a way to use PhantomJS in Python?

后端 未结 8 1300
死守一世寂寞
死守一世寂寞 2020-11-22 08:05

I want to use PhantomJS in Python. I googled this problem but couldn\'t find proper solutions.

I find os.popen() may be a good choice. But I couldn\'t

8条回答
  •  孤街浪徒
    2020-11-22 08:17

    In case you are using Buildout, you can easily automate the installation processes that Pykler describes using the gp.recipe.node recipe.

    [nodejs]
    recipe = gp.recipe.node
    version = 0.10.32
    npms = phantomjs
    scripts = phantomjs
    

    That part installs node.js as binary (at least on my system) and then uses npm to install PhantomJS. Finally it creates an entry point bin/phantomjs, which you can call the PhantomJS webdriver with. (To install Selenium, you need to specify it in your egg requirements or in the Buildout configuration.)

    driver = webdriver.PhantomJS('bin/phantomjs')
    

提交回复
热议问题