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'.
![](https://static.wixstatic.com/media/af7fa4_e7f3caa168c241f590dc0ef984deefbf~mv2.png/v1/fill/w_980,h_387,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/af7fa4_e7f3caa168c241f590dc0ef984deefbf~mv2.png)
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'.
![](https://static.wixstatic.com/media/af7fa4_1cf6911f4aa9456db0b7681d28dc3d4e~mv2.png/v1/fill/w_980,h_610,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/af7fa4_1cf6911f4aa9456db0b7681d28dc3d4e~mv2.png)
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.
![](https://static.wixstatic.com/media/af7fa4_a485a1143e9f4cb3bdbdbb32e84c2885~mv2.png/v1/fill/w_980,h_569,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/af7fa4_a485a1143e9f4cb3bdbdbb32e84c2885~mv2.png)
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;
myarray.push([cleantext,cleanlink]);
};
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 = window.open("");
w.document.write(table);
}
make_table()
Comments