Skip to content

Instantly share code, notes, and snippets.

@landbryo
Created August 23, 2019 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landbryo/62fd33de3156bb6dda9193195bfd6f48 to your computer and use it in GitHub Desktop.
Save landbryo/62fd33de3156bb6dda9193195bfd6f48 to your computer and use it in GitHub Desktop.
Google SERP Extractor
javascript:(function(){output='<html><head><title>SEO SERP Extraction Tool</title><style type=\'text/css\'>body,table{font-family:Tahoma,Verdana,Segoe,sans-serif;font-size:11px;color:#000}h1,h2,th{color:#405850}th{text-align:left}h2{font-size:11px;margin-bottom:3px}</style></head><body>'; output+='<table><tbody><tr><td><h1>SEO%20SERP%20Extraction%20Tool</h1></td></tr></tbody></table>'; pageAnchors=document.getElementsByTagName('a'); divClasses=document.getElementsByTagName('div'); var%20linkcount=0;var%20linkLocation=''; var%20linkAnchorText=''; output+='<table><th>ID</th><th>Link</th><th>Anchor</th>'; for(i=0;i<pageAnchors.length;i++){ if(pageAnchors[i].parentNode.parentNode.getAttribute('class')!='_Rm'){ var%20anchorText%20=%20pageAnchors[i].textContent; var%20anchorLink%20=%20pageAnchors[i].href; var%20linkAnchor%20=%20anchorLink%20+%20'\t'+anchorText; var%20anchorID%20=%20pageAnchors[i].id; if(anchorLink!=''){ if(anchorLink.match(/^((?!google\.|cache|blogger.com|\.yahoo\.|youtube\.com\/\?gl=|youtube\.com\/results|javascript:|api\.technorati\.com|botw\.org\/search|del\.icio\.us\/url\/check|digg\.com\/search|search\.twitter\.com\/search|search\.yahoo\.com\/search|siteanalytics\.compete\.com|tools\.seobook\.com\/general\/keyword\/suggestions|web\.archive\.org\/web\/|whois\.domaintools\.com|www\.alexa\.com\/data\/details\/main|www\.bloglines\.com\/search|www\.majesticseo\.com\/search\.php|www\.semrush\.com\/info\/|www\.semrush\.com\/search\.php|www\.stumbleupon\.com\/url|wikipedia.org\/wiki\/Special:Search).)*$/i)){ if(anchorID.match(/^((?!hdtb_more|hdtb_tls|uh_hl).)*$/i)){ linkLocation+=anchorLink+'<br%20/>'; linkAnchorText+=anchorText+'<br%20/>'; linkcount++; if%20(anchorText%20===%20undefined)%20anchorText%20=%20pageAnchors[i].innerText;output+='<tr>'; output+='<td>'+linkcount+'</td>'; output+='<td>'+pageAnchors[i].href+'</a></td>'; output+='<td>'+anchorText+'</td>'; output+='</tr>\n'; } } } } } output+='</table><br/><h2>URL%20List</h2><div>'; output+=linkLocation;output+='</div><br/><h2>Anchor%20Text%20List</h2><div>'; output+=linkAnchorText;output+='<br/>%C2%A0<br/>'; with(window.open()){document.write(output);document.close();}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment