Are you interested in extracting video titles and URLs from a YouTube channel for further analysis or reference?
In this tutorial, we will walk you through a step-by-step process using JavaScript code to export video titles and URLs from any YouTube channel.
By following this guide, you’ll be able to automate the data extraction process and organize the information as per your requirements. So, let’s get started!
Learn How to Copy YouTube channel video URLs using code in 2023
- Step 1: Open the YouTube Channel Page To begin, open your preferred web browser and navigate to the YouTube channel page from which you want to export the video titles and URLs. Then, click the “Videos” tab. You will get something like: https://www.youtube.com/@NetgrowsTech/videos
- Step 2: To proceed with the data extraction process, you need to open the browser console. This can usually be done by accessing the browser’s developer tools and locating the console tab. Once you have found the console, click on it to open it. After the console is open, you can paste the provided JavaScript code snippets to continue with the extraction.
- Step 3: To initiate automated scrolling, open the browser console and paste the first code snippet labeled as “Code snippet 1”. This code snippet will trigger the automated scrolling action, enabling us to collect the required data from the YouTube channel. Here is the code snippet:
//COPY & PASTE CODE 1:
let goToBottom = setInterval(() => window.scrollBy(0, 400), 1000);
After pasting the code snippet in the console (and pressing ENTER key), the page will begin scrolling automatically. Please wait until the scrolling reaches the bottom of the page. This scrolling action is essential to gather all the video titles and URLs from the YouTube channel.
Step 4: Once the scrolling comes to a halt, you can proceed by pasting the second code snippet labeled as “Code snippet 2”. This particular code snippet is responsible for extracting the video titles and URLs from the YouTube channel and displaying them in the console. Here is the code snippet:
//COPY & PASTE CODE 2:
clearInterval(goToBottom);
let arrayVideos = [];
console.log('\n'.repeat(50));
const links = document.querySelectorAll('a');
for (const link of links) {
if (link.id === "video-title-link") {
arrayVideos.push(link.title + ';' + link.href);
console.log(link.title + '\t' + link.href);
}
}
After pasting the second code snippet, the console will display the video titles and URLs in the desired format. You can now choose to copy this data and paste it into a spreadsheet for further analysis or any other use.
Step 5: Optional Step – Export Data as a CSV File If you prefer to export the data as a CSV file, we have an optional step for you.
By following this step, you can download the data in CSV format with semicolon (;) as the separator.
To proceed with the optional step, copy the provided code snippet labeled as “Code snippet 3”. Here’s the code snippet:
//COPY & PASTE CODE 3:
let data = arrayVideos.join('\n');
let blob = new Blob([data], {type: 'text/csv'});
let elem = window.document.createElement('a');
elem.href = window.URL.createObjectURL(blob);
elem.download = 'my_data.csv';
document.body.appendChild(elem);
elem.click();
document.body.removeChild(elem);
By pasting the code snippet, a CSV file named “my_data.csv” will be automatically downloaded.
This file will contain the video titles and URLs in a format suitable for spreadsheet applications.
What you can do with this tutorial? Export youtube channel video list, export youtube channel video URLs, export youtube channel video titles, Youtube export channel list.
Code mirror: https://codepen.io/netgrowstech/pen/NWERwgE