Created
January 20, 2018 15:16
-
-
Save erajanraja24/02279e405e28311f220f557156363d7b to your computer and use it in GitHub Desktop.
Scraping google search results
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
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); | |
} | |
} |
Which regex to use in the case I want to scrape the name of the projects here? https://defillama.com/recent
It does not work anymore. Google blocks bot searches.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you
I am learning Apps Script in your youtube channel