Extracting all URLs on a Web Page with Chrome Developer Tools
Posted on May 30, 2014 in Google Chrome, JavaScript by Matt Jennings

Thank you to Shan Eapen Koshy for positing a YouTube video on how to do this.

  1. In Chrome, go the website that you want to extract links from, like
  2.  Open Chrome Developer Tools by pressing Cmd + Opt + i (Mac) or F12 (Windows).
  3. Click the Console panel near the top of Chrome Developer Tools.
  4. Inside the Console panel paste the JavaScript below and press Enter:
    var urls = document.getElementsByTagName('a');
    for (url in urls) {
        console.log ( urls[url].href );
  5. Now you will see all the links from that particular web page.
  6. You can also click the Undock into a separate window button (in the upper-right of Chrome Developer Tools and just left of the X that you can click to close Chrome Developer Tools). This will open a separate window that only displays Chrome Developer Tools along with the extracted links.

4 Responses

  1. Shwetha says:

    But when the same code is written for chrome extension it gives “undefined” as the result

  2. William Pate says:

    I love your code block in this post. Thus, I’m probably gonna steal it. 🙂

Leave a Reply

To Top ↑