PhantomJS path on Heroku PhantomJS path on Heroku heroku heroku

PhantomJS path on Heroku


I managed to use Selenium with PhantomJS in my Python application deployed to Heroku following these steps:

1) Switch to using the Cedar-14 stack on my Heroku application

$ heroku stack:set cedar-14

2) Install a PhantomJS buildpack

$ heroku buildpacks:add https://github.com/stomita/heroku-buildpack-phantomjs

With these changes I could then use Selenium to fetch websites

from selenium import webdriverbrowser = webdriver.PhantomJS()browser.get("http://www.google.com")  # This does not throw an exception if it got a 404html = browser.page_sourceprint html  # If this outputs more than just '<html><head></head><body></body></html>' you know that it worked