Intro:- Suppose you are visiting some site or social media, or forum or blog, and you just come by bunch of images which is really awesome. And you want all the URL of the Image or Hyperlink. For this you don't need to install any software or Plugin. Its just simple old trick in javascript.
How does it work?
Simple Just run the JavaScript code and It will collect all the data in a text file and ask where you want to it.
*Note: It will save it in a text file but you need to open using Notepad++ to View Proper Line Break Formatting.
Step 1: Open Developer Tool in your Browser. i.e. Press Ctrl + Shift + I will work on both Mozilla and Chrome.
Step 2: Click on Console Tab.
Step 3: And Paste the following code and Run. (In Mozilla Firefox you might have to type allow pasting in console to paste.)
Step 4: Choose What You want to Run
A] To Get Images URL [Paste and Run this Code.]
// Scrape ALL IMAGES From ANY WEBSITE & HTML // img => src var links = document.querySelectorAll('img'); var linksArray = []; for (var i = 0; i < links.length; i++) { // Store links in variable linksArray.push(links[i].src); // Works fine in console console.log(linksArray); } // Create text document — only saves 1st link in text doc var textDoc = document.createElement('a'); textDoc.href = 'data:attachment/text,' + encodeURI(linksArray.join('\n')); textDoc.target = '_blank'; textDoc.download = 'Image_file.txt'; textDoc.click();
B] To Get Hyperlinks URL [Paste and Run this Code.]
// Scrape ALL Hyperlink From ANY WEBSITE & HTML // a => href (function() { var links = document.querySelectorAll('a'); var linksArray = []; // Loop through all links for (var i = 0; i < links.length; i++) { // Store links in variable linksArray.push(links[i]); // Works fine in console console.log(linksArray); } // Create text document — only saves 1st link in text doc var textDoc = document.createElement('a'); textDoc.href = 'data:attachment/text,' + encodeURI(linksArray.join('\n')); textDoc.target = '_blank'; textDoc.download = 'Hyperlink_file.txt'; textDoc.click(); })();
Comments
Post a Comment