Skip to content

Instantly share code, notes, and snippets.

@ShawonAshraf
Created October 13, 2017 08:50
Show Gist options
  • Save ShawonAshraf/1f2bc18425a58258bacdd8feddcf14e9 to your computer and use it in GitHub Desktop.
Save ShawonAshraf/1f2bc18425a58258bacdd8feddcf14e9 to your computer and use it in GitHub Desktop.
Download images from Google image search
// taken from
// https://32hertz.blogspot.com/2015/03/download-all-images-from-google-search.html
var cont=document.getElementsByTagName("body")[0];
var imgs=document.getElementsByTagName("a");
var i=0;var divv= document.createElement("div");
var aray=new Array();var j=-1;
while(++i<imgs.length){
if(imgs[i].href.indexOf("/imgres?imgurl=http")>0){
divv.appendChild(document.createElement("br"));
aray[++j]=decodeURIComponent(imgs[i].href).split(/=|%|&/)[1].split("?imgref")[0];
divv.appendChild(document.createTextNode(aray[j]));
}
}
cont.insertBefore(divv,cont.childNodes[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment