Skip to content

Instantly share code, notes, and snippets.

@robinduckett
Created August 23, 2011 16:21
Show Gist options
  • Save robinduckett/1165745 to your computer and use it in GitHub Desktop.
Save robinduckett/1165745 to your computer and use it in GitHub Desktop.
This will insert HTML into a DOM using jsdom
var jsdom = require('jsdom');
var request = require('request');
request.get({url: 'http://google.com/', followRedirect: true}, function(err, res, body) {
if (!err) {
if (res.statusCode == 200) {
jsdom.env(body, ['http://code.jquery.com/jquery-1.5.min.js'], function(errors, window) {
$ = window.jQuery;
$('#lga').append('<div>WHAT</div>');
console.log(window.document.outerHTML);
window.close();
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment