Created
August 3, 2018 00:11
-
-
Save johnmurch/8b5cf9416f973afb1ae5bec9904f6ab6 to your computer and use it in GitHub Desktop.
Parse SERP on-page via Chrome Console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RUN from console in Chrome on a Google SERP page -> use &num=100 param in URL | |
var links = []; | |
for(i=0;i<=100;i++){ | |
if(document.evaluate('//*[@id="rso"]/div/div/div['+i+']/div/div/h3/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue){ | |
links.push({ | |
"url":document.evaluate('//*[@id="rso"]/div/div/div['+i+']/div/div/h3/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.href, | |
"title":document.evaluate('//*[@id="rso"]/div/div/div['+i+']/div/div/h3/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML, | |
"description":document.evaluate('//*[@id="rso"]/div/div/div['+i+']/div/div/div/div/span', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment