Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save erajanraja24/02279e405e28311f220f557156363d7b to your computer and use it in GitHub Desktop.
Save erajanraja24/02279e405e28311f220f557156363d7b to your computer and use it in GitHub Desktop.
Scraping google search results
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);
}
}
@busan100
Copy link

thank you
I am learning Apps Script in your youtube channel

@F041
Copy link

F041 commented Jun 7, 2022

Which regex to use in the case I want to scrape the name of the projects here? https://defillama.com/recent

@user3691
Copy link

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