Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // imgchili album downloader
- // downloads full images for a given link to working folder
- // run like...
- // `node script.js http://imgchili.net/album/abc123`
- var request=require('request');
- var fs=require('fs');
- var download = function(uri, filename, callback){
- request.head(uri, function(err, res, body){
- request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
- });
- };
- var link=process.argv[2];
- request(link, function(e,r,b){
- var img_links = b.match(/a\shref\=['"]show(.*?)['"]\</ig);
- img_links.forEach(function(linka){
- linka = linka.replace(/a\shref\=['"](show.*?)['"]\</ig, '$1');
- linka = "http://imgchili.net/"+linka
- request(linka, function(e,r,b){
- var image_link = b.match(/id="show_image.*?\n.*?src="(.*?)"/ig);
- image_link = image_link[0].replace(/id="show_image.*?\n.*?src="(.*?)"/, "$1");
- download(image_link, image_link.slice(image_link.length - 20, image_link.length)+'.jpg', function(){
- console.log(image_link.slice(image_link.length - 20, image_link.length)+'.jpg'+' done.');
- })
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement