Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Screen Scraping with jsdom and node.js technique:
// 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');
html: "<html><body></body></html>",
scripts: [
}, function (err, window) {
var $ = window.jQuery;
$('body').append("<div class='testing'>Hello World</div>");
console.log($(".testing").text()); // outputs Hello World
// more examples:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment