Advertisement
VictorMisa

extraer titulos de youtube e ids

Jan 18th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. IDs + titulo :
  2.  
  3. javascript:(function() { var links = document.querySelectorAll('a#video-title'); var videoData = new Set(); for (var i = 0; i < links.length; i++) { var link = links[i]; var href = link.getAttribute('href'); var videoId = href.match(/watch\?v=([^&]+)/); var title = link.textContent.trim(); if (videoId) { videoData.add("'" + videoId[1] + "'\\" + title); } } if (videoData.size > 0) { var csvContent = 'ID\\Título\n'; videoData.forEach(function(item) { csvContent += item + '\n'; }); var blob = new Blob([csvContent], { type: 'text/csv' }); var url = window.URL.createObjectURL(blob); var a = document.createElement('a'); a.href = url; a.download = 'videos.csv'; a.style.display = 'none'; document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(url); document.body.removeChild(a); } else { alert('No se encontraron enlaces con el atributo id="video-title".'); }})();
  4.  
  5.  
  6. id solo :
  7.  
  8. javascript:(function() { var links = document.querySelectorAll('a#video-title'); var videoIds = []; for (var i = 0; i < links.length; i++) { var href = links[i].getAttribute('href'); var videoId = href.match(/watch\?v=([^&]+)/); if (videoId) { videoIds.push("'" + videoId[1] + "'"); } } if (videoIds.length > 0) { var idsString = videoIds.join(', '); var textarea = document.createElement('textarea'); textarea.value = idsString; document.body.appendChild(textarea); textarea.select(); document.execCommand('copy'); document.body.removeChild(textarea); alert('Los IDs se han copiado al portapapeles:\n\n' + idsString); } else { alert('No se encontraron enlaces con el atributo id="video-title".'); }})();
  9.  
  10.  
  11.  
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement