Created
August 23, 2011 16:21
-
-
Save robinduckett/1165745 to your computer and use it in GitHub Desktop.
This will insert HTML into a DOM using jsdom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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