To extract URLs from the webpage currently open in your browser, run the script below in Developer Tools. It lists the page's clickable <a> links, their anchor text, and whether each link points to another host. The output is a CSV you can paste into a spreadsheet or the Datablist CSV editor.

This extracts links present on one rendered page. It does not crawl every page on the site, and it cannot see links that have not loaded yet. Scroll or expand the page first if it loads content on demand.

Step 1: Run JavaScript code in Google Chrome Developer Tools

  • Open Google Chrome Developer Tools with Cmd + Opt + i (Mac) or F12 (Windows). And click on the Console tab.
  • Copy-Paste the following JavaScript code and press Enter.
const rows = [['Url', 'Anchor Text', 'External']];
for (const link of document.querySelectorAll('a[href]')) {
  if (!['http:', 'https:'].includes(link.protocol)) continue;
  rows.push([
    link.href,
    link.textContent.replace(/\s+/g, ' ').trim(),
    link.host === location.host ? 'FALSE' : 'TRUE'
  ]);
}
const csv = rows.map(row => row.map(value =>
  `"${String(value).replace(/"/g, '""')}"`
).join(',')).join('\n');
console.log(csv);
Open Google Developer Tools
Open Google Developer Tools

Step 2: Copy-paste exported URLs into a CSV file or spreadsheet tools

The JavaScript code will extract all URLs from the webpage with the following values:

  • URL - The link URL
  • Anchor Text - The label associated with the link. Called "Anchor Text".
  • External - A boolean (TRUE, FALSE)

The result is printed on the console using CSV format. Copy the full output into a .csv file or a spreadsheet. The script quotes each cell and escapes quotation marks in anchor text, so commas in labels do not split a row. Links without http or https, such as mailto: links, are excluded.

For example, a link labeled About, "Us" on the current host produces "https://example.com/about","About, ""Us""","FALSE". A link to another host produces TRUE in the last column.

Copy the entire console output, including the header row.

Open Google Results
Open Google Results

To filter quickly your links, open Datablist CSV editor. Create a collection and paste your CSV data. Check the Google and Amazon examples below for a more step-by-step guide.

Create new collection
Create new collection

Select 'First row contains header' and click on the "+" button for each column to import them.

Paste results
Paste results

Then you will be able to use text search or filter on a specific property. You can use Datablist to consolidate all your CSV data. And Datablist comes with an algorithm for deduplication to have a clean list or URLs.

Example with Google Results

This is a step-by-step example with the Google results page. We want to extract all external links from a Google search result.

Only links loaded into the current results page can appear in the export. Search engines may change their page layout or limit the visible results, so check the extracted rows before using them.

Open Google Results
Open Google Results

Step 2: Copy-paste the code and run it

Open the console in Google Developer Tools, paste the JavaScript code and press Enter.

Copy-paste code
Copy-paste code

Copy the results. Select the line and ctrl + c or use the Copy button when Chrome shows it.

Run JavaScript code
Run JavaScript code

Step 3: Filter results

Open Datablist CSV editor, create a collection, and paste the copied URLs.

Note: Don't forget to select the option First row contains headers and to click the "+" button as shown.

Copy-Paste results in Datablist
Copy-Paste results in Datablist

Once imported. Click "Filter on property" in the "External" column.

Create Filters
Create Filters

And filter items with External to TRUE and Url that does not contain google. Check our guide on how to clean your scraped data

Filter URLs outside Google
Filter URLs outside Google

And here are your external links:

Google Links results
Google Links results

Example with Amazon Results

This is a step-by-step example with the Amazon products page. We want to extract all links from this page.

Amazon products listing
Amazon products listing

Open the Chrome Developer Tools:

Open Chrome Developer Tools
Open Chrome Developer Tools

Copy-paste the JavaScript code:

Copy-Paste code
Copy-Paste code

And run it by pressing Enter:

Run code
Run code

With Datablist CSV editor, create a collection.

Create collection
Create collection

Paste your scrapped URLs:

Paste scrapped URLs
Paste scrapped URLs

Your scrapped URLs are listed on the tool. Filter the links, deduplicate the results, and clean your scraped data.

Scrapped Amazon URLs
Scrapped Amazon URLs