use code to generate list of links on a web page

The below code, posted here by Phil Gorman can be used to easily generate a list of all of the links on a single web page.

Simply follow these steps.

1. In Chrome, right click on the web page containing the links and select 'Inspect'.

2. In the panel that opens click on the 'Console' tab.

3. In the pane at the bottom right enter the code, and then press 'ENTER'.

4. A new tab will open in the browser with a list of the links and the name of each link, or the text which contains the link. This text can then be pasted in two columns in Excel.

var x = document.querySelectorAll("a");3.

var myarray = []

for (var i=0; i<x.length; i++){

var nametext = x[i].textContent;

var cleantext = nametext.replace(/\s+/g, ' ').trim();

var cleanlink = x[i].href;



function make_table() {

var table = '<table><thead><th>Name</th><th>Links</th></thead><tbody>';

for (var i=0; i<myarray.length; i++) {

table += '<tr><td>'+ myarray[i][0] + '</td><td>'+myarray[i][1]+'</td></tr>';


var w ="");




Contact Me With Your Litigation Support Questions:

  • Twitter Long Shadow

© 2015 by Sean O'Shea . Proudly created with