Skip to content

Instantly share code, notes, and snippets.

@tmpvar
Last active December 19, 2015 14:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmpvar/5969049 to your computer and use it in GitHub Desktop.
Save tmpvar/5969049 to your computer and use it in GitHub Desktop.
vegasjs - super lightning talk
node_modules
var jsdom = require('jsdom');
jsdom.env('http://nodejs.org/dist/', function(e, window) {
console.log(window.document.innerHTML);
});
var jsdom = require('jsdom');
jsdom.env('http://nodejs.org/dist/', [
'http://code.jquery.com/jquery-1.10.2.min.js'
], function(e, window) {
var $ = window.$;
$('a').each(function() {
console.log($(this).text());
});
});
var words = process.argv[2];
var url = 'http://translate.google.com/m?hl=en&sl=en&tl=es&ie=UTF-8&prev=_m&q=' + words;
require('jsdom').env(url, [
'http://code.jquery.com/jquery-1.10.2.min.js'
], function(e, window) {
var $ = window.$;
console.log(words + ' -> ' + $('.t0').text());
});
{
"name": "jsdom-vegasjs",
"version": "0.0.0",
"description": "Couple of sources that aid in showing what jsdom can do in it's basic form",
"main": "01_env.js",
"dependencies": {
"jsdom": "~0.7.0",
"zombie": "~2.0.0-alpha19"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gist.github.com/5969049.git"
},
"author": "",
"license": "BSD",
"bugs": {
"url": "https://gist.github.com/5969049"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment