Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
How to scrape between two (2) dates in time // How to convert Channel and Video ID into URL in script

FYI I have not written this code myself, I've sourced it online via forums like this since it does the job in needs to up to a certain point.

I'm looking to scrape YouTube search results data based on keywords between two dates in time, for example; September 19th - October 4th.

What code and where can I add this to the script?

Here is the script I'm currently using:

function YoutubeScraper() {
  var spreadSheet = SpreadsheetApp.getActiveSpreadsheet()
  var activeSheet = spreadSheet.getActiveSheet();

  // Retrieve YouTube.Search.list.
  var search = YouTube.Search.list("snippet", { q: "Gang Beasts", maxResults: 10 });
  var results = search.items.map((item) => [item.snippet.channelId, item.id.videoId, item.snippet.title, item.snippet.publishedAt]);
  
  // Retrieve channel IDs and video IDs.
  var {channelIds, videoIds} = results.reduce((o, [channelId, videoId]) => {
    o.channelIds.push(channelId);
    o.videoIds.push(videoId);
    return o;
  }, {channelIds: [], videoIds: []});

  // Retrieve YouTube.Videos.list.
  var videoList = YouTube.Videos.list("statistics", {id: videoIds.join(",")});
  var videoStats = videoList.items.map((item) => [item.id, item.statistics.viewCount, item.statistics.likeCount, item.statistics.dislikeCount]).reduce((o, [id, ...v]) => Object.assign(o, {[id]: v}), {});

  // Retrieve YouTube.Channels.list
  var channelList = YouTube.Channels.list("statistics", { id: channelIds.join(",") });
  var channelStats = channelList.items.map((item) => [item.id, item.statistics.subscriberCount]).reduce((o, [id, ...v]) => Object.assign(o, {[id]: v}), {});

  // Create an array for putting values and put the values to Spreadsheet.
  results = results.map(e => channelStats[e[0]] ? e.concat(channelStats[e[0]]) : e.concat(Array(2).fill("")));
  results = results.map(e => videoStats[e[1]] ? e.concat(videoStats[e[1]]) : e.concat(Array(3).fill("")));
  activeSheet.getRange(2, 1, results.length, results[0].length).setValues(results);
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda