Skip to Main Content
Go to Penn Libraries homepage   Go to Guides homepage

Accessible Guides Project

Not That You Asked - How to extract a list of links from a webpage

  1. Use Chrome
  2. Be sure you're in a live environment. For example, in Penn Libraries Guides, this will not work in the editor.
  3. Open Development Tools
    - Press Command+Option+C (Mac) or Control+Shift+C (Windows, Linux, ChromeOS).
  4. Click Console
  5. At the bottom, after the arrow (>), paste in this code: var x = document.querySelectorAll("a");
    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 ="");

Penn Libraries Home Franklin Home
(215) 898-7555