Online Webpage URL Link Extractor

This link extractor tool helps you extract URLs from any web page. With this tool, you can easily extract internal and external links from any online webpage. This is a great way to collect all existing links on a web page for further analysis or reference.

Extracted URLs you can convert to JSON array, HTML select option

How To Get All URLs From Webpage

  1. Enter the URL link of the webpage in the text box shown below
  2. Select the URL type of you want: All Links, Internal Links or External Links
  3. Click the "Extract URL" button
×

How to Extract All Links from a Webpage Using JavaScript

Using JavaScript in the browser console is a fast and efficient way to extract all links from a webpage. After running this JavaScript code, you will get two separate arrays: one for external links and one for internal links.

Here's a simple guide on how to do this using JavaScript:

Step-by-Step Guide Extract links

  1. Open your browser: Go to the webpage you want to extract links from

  2. Open the Browser Developer Tools:

    • In Chrome, you can do this by pressing Ctrl + Shift + I on Windows/Linux or Cmd + Option + I on Mac.

    • 1. Alternatively, you can right-click on the webpage and select "Inspect".

  3. Navigate to the Console Tab: Once Developer Tools is open, click on the "Console" tab.

  4. Run the JavaScript Code: Copy and paste the following JavaScript code into the console and press Enter

JavaScript
let external_links = [];
let internal_links = [];
let urls = {};

const regex_href = /^javascript:void/;
const current_host_name = window.location.hostname;
const a_tags = document.querySelectorAll("a");

a_tags.forEach( a => {
    let href = a.getAttribute("href");
    if (href) {
        if (href && href.charAt(0) == "#" || regex_href.test(href)) {
            return;
        }
        let current_link = {
            url: a.href,
            name: a.innerText || a.href
        };
        const link_hostname = new URL(a.href).hostname;
        if (link_hostname == current_host_name) {
            internal_links.push(current_link);
        } else {
            external_links.push(current_link);
        }
    }
});

urls.internal = internal_links;
urls.external = external_links;
urls.all = [...internal_links, ...external_links];

// show all links
console.log(urls.all);

// show external links only
// console.log(urls.external);

// show internal links only
// console.log(urls.internal);

To copy or preview the array URL list, follow these steps: Copy the JavaScript code provided below and paste it into the Console tab of your browser's developer tools. Press Enter, and a new window will open displaying the array list.

Note: If the popup window is disabled, you will need to enable it.
JavaScript
let code = urls.all;
// let code = urls.internal;
// let code = urls.external;

var popup_page = window.open("", "_blank");
const doc ='<pre>' + JSON.stringify(code, null, 4) + '</pre>';
popup_page.document.write(doc);
popup_page.document.close();
popup_page.focus();

This page was last modified on