Skip to content

Instantly share code, notes, and snippets.

@nym
Created June 12, 2012 17:13
Show Gist options
  • Save nym/2918776 to your computer and use it in GitHub Desktop.
Save nym/2918776 to your computer and use it in GitHub Desktop.
JSDOM Sample
var jsdom = require('jsdom');
jsdom.defaultDocumentFeatures = {
FetchExternalResources : ['script'],
ProcessExternalResources : ['script'],
MutationEvents : false,
QuerySelector : false
};
//var fs = require('fs');
//var jquery = fs.readFileSync("./jquery-1.6.2.min.js").toString();
//var index = fs.readFileSync("index.html").toString();
jsdom.env({
html: "<html><body>Hello <script>document.body.innerHTML = 'WORLD';</script></body></html>",
//documentRoot: '/Users/tlongson/chi/chi/app',
src: [
],
done: function(errors, window) {
console.log(window.document.body.innerHTML);
console.log(window.$);
return;
var $ = window.$;
//console.log('HN Links');
//$('td.title:not(:last) a').each(function() {
// console.log(' -', $(this).text());
//});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment