News for hackers. Stuff that matters.
Re:Using jQuery and node.js to scrape html pages in 5 lines by il on Monday September 06, 2010 @03:49AM (#1666188)
I have a question: Does scraping like this execute Javascript on the scraped page? Am I able to access the output of Javascript/AJAX on that page?

As far as I know this is impossible with any other server-side scraping technology.

If so, that would be amazingly useful for a couple of my side projects, much easier than parsing their Javascript code and extracting the info I need.

Re:Using jQuery and node.js to scrape html pages in 5 lines by robinduckett on Monday September 06, 2010 @04:10AM (#1666225)
You'd have to parse the page seperately and run each piece of in line scripts / linked scripts in a sandbox which can talk to jsdom, but it could be done.
Re:Using jQuery and node.js to scrape html pages in 5 lines by _delirium on Monday September 06, 2010 @04:15AM (#1666230)
Sounds like a useful general-purpose library someone could put together: server-side execution of HTML-embedded js, with some sort of configurable sandbox (e.g. decide whether you want to let it call out to the internet or not). All the components are available, but seems like the field is open for an all-in-one solution that gets the defaults and edge cases right.

I imagine Google has something at least close to that internally, given that they've dropped hints here and there about their ability to crawl post-js-processed pages, but unless I've missed it, I don't think they've released anything (my guess is because of the arms-race issue, with shady sites trying to use js to mask certain content from googlebot).

Re:Using jQuery and node.js to scrape html pages in 5 lines by il on Monday September 06, 2010 @04:48AM (#1666278)
Second this idea. Nothing like this exists currently except for a couple buggy poorly documented dead projects.

Selenium might be OK for usability testing a single site, but it's useless for large scale multithreaded crawling and scraping and doesn't scale.

I, for one, would definitely pay good money for an easy library/API to scrape JS-heavy sites without the overhead of a full browser running macros.

Re:Using jQuery and node.js to scrape html pages in 5 lines by fizx on Monday September 06, 2010 @04:41AM (#1666269)
Selenium Remote Control lets you drive a real browser from the scripting language of your choice. xvfb let's you run headless. You really don't need anything else.
Re:Using jQuery and node.js to scrape html pages in 5 lines by il on Monday September 06, 2010 @04:19AM (#1666238)
Is that due to a technical limitation or a security issue? Would everything need to run in a separate sandbox if the JS was from a trusted source(i.e. google)?
Re:Using jQuery and node.js to scrape html pages in 5 lines by vially on Monday September 06, 2010 @08:24AM (#1666506)
If you are using Java you could use HtmlUnit which has fairly good JavaScript support (including AJAX).