Forked from erajanraja24/Scrape search results with google apps script
Created
January 22, 2018 17:37
-
-
Save prasannakulkarni333/eb9a90b8125ae29bc3ccd9840c033aa4 to your computer and use it in GitHub Desktop.
Scraping google search results
This file contains 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
function scrapeGoogle() { | |
var searchResults=UrlFetchApp.fetch("https://www.google.co.in/search?q="+encodeURIComponent("amarindaz youtube channel")); | |
var titleExp=/<h3 class=\"r\">([\s\S]*?)<\/h3>/gi; | |
var titleResults=searchResults.getContentText().match(titleExp); | |
// Logger.log(titleResults); | |
for(var i in titleResults) | |
{ | |
var actualTitle=titleResults[i].replace(/(^\s+)|(\s+$)/g, "").replace(/<\/?[^>]+>/gi, ""); | |
Logger.log(actualTitle); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment