Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created March 11, 2012 14:48
Show Gist options
  • Save t-kashima/2016701 to your computer and use it in GitHub Desktop.
Save t-kashima/2016701 to your computer and use it in GitHub Desktop.
function getTopUrl(query) {
var url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=' + encodeURI(query);
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
var object = Utilities.jsonParse(json);
return object["responseData"]["results"][0]["unescapedUrl"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment