Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scrape image urls
// Google Images
var urls=Array.from(document.querySelectorAll(".rg_i")).map(el=>el.hasAttribute("data-src")?el.getAttribute("data-src"):el.getAttribute("data-iurl")).filter(l=>l!=null).join("\n");
var a = document.createElement("a");a.download = "filename.txt";a.href = "data:text/csv;charset=utf-8,"+urls;a.click();
// DuckDuckGo Images (uses Bing)
var urls=Array.from(document.querySelectorAll(".tile--img__img")).map(el=>el.hasAttribute("data-src")?el.getAttribute("src"):el.getAttribute("data-src")).filter(l=>l!=null).map(l=>"https:"+l).join("\n");
var a = document.createElement("a");a.download = "filename.txt";a.href = "data:text/csv;charset=utf-8,"+urls;a.click();
// Bing Images
var urls=Array.from(document.querySelectorAll(".mimg")).map(el=>el.hasAttribute("src")?el.getAttribute("src"):null).filter(l=>l!=null&&l.startsWith("http")).join("\n");
var a = document.createElement("a");a.download = "filename.txt";a.href = "data:text/csv;charset=utf-8,"+urls;a.click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment