Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dnalob/80482dd16fce22d0ee6138aa158ef12f to your computer and use it in GitHub Desktop.
Save dnalob/80482dd16fce22d0ee6138aa158ef12f to your computer and use it in GitHub Desktop.
Scrape YouTube Search Results
function YouTubeScraper() {
var sh1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var keyword = sh1.getRange("B1").getValue();
var results = YouTube.Search.list('id,snippet', {q:keyword, maxResults:50});
//Video ID Published Date Channel ID "Video Title
//" Description Thumbnail URL Channel Title
var items = results.items.map(function(e){
return [e.id.videoId,
e.snippet.publishedAt,
e.snippet.channelId,
e.snippet.title,
e.snippet.description,
e.snippet.thumbnails["default"].url,
e.snippet.channelTitle]
})
sh1.getRange(4, 1, items.length, items[0].length).setValues(items)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment