Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Screen Scraping with jsdom and node.js technique: http://blog.nodejitsu.com/jsdom-jquery-in-5-lines-on-nodejs
// The code creates a new jsdom window
// and adds jQuery to the document via a script element.
// Although it is just an illustrative
// example it is easy to modify it to work with
// real pages retrieved from the Internet.
var jsdom = require('jsdom');
jsdom.env({
html: "<html><body></body></html>",
scripts: [
'http://code.jquery.com/jquery-1.5.min.js'
]
}, function (err, window) {
var $ = window.jQuery;
$('body').append("<div class='testing'>Hello World</div>");
console.log($(".testing").text()); // outputs Hello World
});
// more examples: https://gist.github.com/indexzero/1009644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment