Extract all the URL's from the webpage

There could be a scenario to extract all the URLs related to a page on the website. 

Please follow below steps to read all the URLs on the page
  • Go to the Google Chrome browser and type the URL in the browser.
  • Once the website opens, click F12 or developer tools and click on the console tab

browser console
  • Now paste the below command on the console window as shown below
urls = $$('a'); for (url in urls) console.log ( urls[url].href );
Command
  • Now click enter to get the list of URLs on the webpage
Results
  • Also, few other commands which also gives much detailed granular URL Extraction with Anchor Text (COLOURED) that on chrome and firefox browser
var urls=$$('a');for(url in urls){console.log("%c#"+url+" - %c"+urls[url].innerHTML +" -- %c"+urls[url].href,"color:red;","color:green;","color:blue;");}
  • For IE and Edge browser use below command
var urls=$$('a');for(url in urls){console.log("#"+url+" - "+urls[url].innerHTML +" -- "+urls[url].href)}

Happy extracting !!

Comments