Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
parse images
var http = require('http');
var jsdom = require('jsdom');
var url = "http://deathtoglamour.com/articles/695-top-ten-sexiest-exploits-of-uk-olympic-gold-medal-winners-hopefully";
var options = {
host: 'deathtoglamour.com',
port: 80,
path: '/articles/695-top-ten-sexiest-exploits-of-uk-olympic-gold-medal-winners-hopefully',
method: 'GET'
};
http.get(options, function(response){
response.setEncoding('utf8');
var data = '';
response.on('data',function(chunk){
data += chunk;
});
response.on('end',function(){
data = data.replace(/(<\/html>)[\s\S]*/g, '$1');
parse(data,function(err,data){
console.log(data);
});
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
function parse(data, callback){
jsdom.env({html: data, scripts: ['http://code.jquery.com/jquery-1.5.min.js']},function(err, window){
var $ = window.jQuery;
// $(window).load(function(){
////////////////////////////////////////////////////////////////////////////////////
var images = $('.ContentBlock').find('img');//.attr('src');
for(var i=0;i<images.length;i++){
var img = images[i];
var src = $(img).attr('src');
var k = (img.width + img.height)/2;
console.log(src, k);
}
callback(null,'OK');
////////////////////////////////////////////////////////////////////////////////////
// });
});
}
http://www.click2edit.com/photos/0000/0406/201207291343563967_3749.jpg 0
http://www.click2edit.com/photos/0000/0409/Jessica-Ennis-interview-86aGCv-lgn.jpg 0
http://www.click2edit.com/photos/0000/0412/201207291343589313_4407.jpg 0
http://www.click2edit.com/photos/0000/0415/201207291343589416_905.jpg 0
http://www.click2edit.com/photos/0000/0418/201207291343589455_5365.jpg 0
http://www.click2edit.com/photos/0000/0427/beth-tweddle-dress--z.jpg 0
http://www.click2edit.com/photos/0000/0430/201207301343633352_2040.jpg 0
http://www.click2edit.com/photos/0000/0433/Beth-Tweddle-Feet-747204.jpg 0
http://www.click2edit.com/photos/0000/0424/201207301343633283_9922.jpg 0
http://www.click2edit.com/photos/0000/0421/201207301343633140_7026.jpg 0
http://www.click2edit.com/photos/0000/0436/13_Rebecca_Adlington.jpg 0
http://www.click2edit.com/photos/0000/0439/Rebecca-Adlington-Feet-460991.jpg 0
http://www.click2edit.com/photos/0000/0442/201208011343851030_6799.jpg 0
http://www.click2edit.com/photos/0000/0445/Tom-Daley_peanut_smuggling.jpg 0
http://www.click2edit.com/photos/0000/0448/201208011343805624_843.jpg 0
http://www.click2edit.com/photos/0000/0451/201208011343855335_945.jpg 0
http://www.click2edit.com/photos/0000/0454/201208011343855378_7816.jpg 0
http://www.click2edit.com/photos/0000/0466/anna_watkins.png 0
http://www.click2edit.com/photos/0000/0463/201208031343978284_162.jpg 0
http://www.click2edit.com/photos/0000/0460/double_canoe_girls.jpg 0
http://www.click2edit.com/photos/0000/0457/Rachel_Cawthorn_Team_GB_Canoe_Sprint_Athletes.jpg 0
http://www.click2edit.com/photos/0000/0469/Rachel_Cawthorn_Meets_the_queen.jpg 0
http://www.click2edit.com/photos/0000/0472/kari-anne_payne_in_zest_magazine.jpg 0
http://www.click2edit.com/photos/0000/0475/201208041344090409_1633.jpeg 0
http://www.click2edit.com/photos/0000/0478/201208041344090470_462.jpg 0
http://www.click2edit.com/photos/0000/0481/201208041344090531_8225.jpg 0
http://www.click2edit.com/photos/0000/0484/201208041344090586_3074.jpg 0
http://www.click2edit.com/photos/0000/0487/keri-anne_payne_isn_sexy_cat_woman_outfit_full.jpg 0
http://www.click2edit.com/photos/0000/0490/chris_hoy_getty.jpg 0
http://www.click2edit.com/photos/0000/0493/4112606862_bb03610245_z.jpg 0
OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment