Web Crawler That Can Interpret Javascript
Solution 1:
Ruby's Capybara is an integration test library, but it can also be used to write stand-alone web-crawlers. Given that it uses backends like Selenium or headless WebKit, it interprets javascript out-of-the-box:
require'capybara/dsl'require'capybara-webkit'include Capybara::DSL
Capybara.current_driver = :webkit
Capybara.app_host = "http://www.google.com"
page.visit("/")
puts(page.html)
Solution 2:
I've been using HtmlUnit (Java). This was originally designed for unit testing pages. It's not perfect javascript, but it hasn't failed me in my limited usage. According to the site, it can run the following JS frameworks to a reasonable degree:
- jQuery 1.2.6
- MochiKit 1.4.1
- GWT 2.0.0
- Sarissa 0.9.9.3
- MooTools 1.2.1
- Prototype 1.6.0
- Ext JS 2.2
- Dojo 1.0.2
- YUI 2.3.0
Solution 3:
You are more likely to have success in Java than in PHP. There is a pre-existing Javascript interpreter for Java called Rhino. It's a reference implementation, and well-documented.
Rhino is used in lots of existing Java apps to provide Javascript scripting ability within the app. I have also heard of it used to assist with performing automated tests in Javascript.
I also know that Java includes code that can parse and render HTML, though someone who knows more about Java than me can probably advise more on that. I am not denying it would be very difficult to achieve something like this; you'd essentially be re-implementing a lot of what a browser does.
Solution 4:
You could use Mozilla's rendering engine Gecko:
Solution 5:
Give a look here: http://snippets.scrapy.org/snippets/22/ it's a python screen scraping and web crawling framework used with webdrivers that open a page, render all the things you need and gives you the possibilities to "capture" anything you want in the page via
Post a Comment for "Web Crawler That Can Interpret Javascript"