Skip to content

Instantly share code, notes, and snippets.

@noahgrant
Created February 27, 2013 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahgrant/5044155 to your computer and use it in GitHub Desktop.
Save noahgrant/5044155 to your computer and use it in GitHub Desktop.
Slightly bigger jsdom example
var http = require('http'),
request = require('request'),
util = require('util'),
jsdom = require('jsdom'),
jquery = require('jquery'),
xhr = require('xmlhttprequest');
exports.test = function(req,res) {
request('http://www.lg.com/us/washers/all-washers', function(err, response, body) {
if (!err && response.statusCode === 200) {
var window = jsdom.jsdom(body).createWindow();
$ = jquery.create(window);
var XHR = xhr.XMLHttpReqest;
$.support.cors = true;
$.ajaxSettings.xhr = function() {
return new XHR;
};
window.onload = function() {
res.end($('.product').find('img').attr('src'));
};
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment