Created
February 27, 2013 01:37
-
-
Save noahgrant/5044155 to your computer and use it in GitHub Desktop.
Slightly bigger jsdom example
This file contains hidden or 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 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