Can you deploy Watir on Heroku to generate HTML Snapshots? If so, how?

故事扮演 提交于 2019-12-18 12:42:53

问题


I would like to generate HTML Snapshots using Watir, hosted on Heroku.

Google's Full Specification for Making AJAX Applications Crawlable suggests using HTMLUnit... see How do I create an HTML snapshot? point #3.

HtmlUnit is a Java-only headless browser emulator; and unfortunately jRuby is not an option on Heroku. So HtmlUnit is ruled out (to my knowledge).

If you're interested I have another question open regarding HtmlUnit as a service hosted on Google App Engine... Making AJAX Applications Crawlable? How to build a simple web service on Google App Engine to produce HTML Snapshots? ... still waiting on a proven example/answer.


回答1:


No. You need a full desktop environment to run watir. Heroku doesn't provide you with that.

You could use a service such as Amazon EC2




回答2:


Yes you can

Use Watir with PhantomJS, which is headless

browser = Watir::Browser.new :phantomjs

To use PhantomJS on Heroku, you'll need to use a Heroku PhantomJS buildpack




回答3:


Troelskin's answer is incorrect. There are ways to run "headless" browsers with Watir, which do not require a "full desktop environment". Having said that, I do not know which method may be appropriate on Heroku.

Other "headless" automation options (if you are using Ruby) are Mechanize with Open-Uri, along with (optional) Nokogiri.



来源:https://stackoverflow.com/questions/3597118/can-you-deploy-watir-on-heroku-to-generate-html-snapshots-if-so-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!