Can I use Watir to scrape data from a website on a linux server without monitor?

随声附和 提交于 2019-12-18 13:37:35

问题


Can I use Watir to scrape data from a website (AJAX used) but on a linux server without monitor? (linode.com) ?


回答1:


There are several ways to do this:

  1. Use HtmlUnit, either Celerity or watir-webdriver (through the remote Selenium2/WebDriver server).

  2. Use a real browser + a virtual X server (Xvfb). I'd recommend using watir-webdriver's Firefox driver and the Headless gem for a simple way to control this from Ruby.

This is basically a tradeoff between speed and realism. Personally I'd go with #2 if the site has any complex JavaScript or invalid HTML, but both approaches could be worth investigation.

For the future, I'm keeping an eye on this project, which looks like a terrific idea.



来源:https://stackoverflow.com/questions/3861871/can-i-use-watir-to-scrape-data-from-a-website-on-a-linux-server-without-monitor

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