Scraping Youtube Data
Last updated
Last updated
Requirements
YouTube API Key (generate via )
Python 3.10+ installed
Linux environment or WSL environment
This might take a while depending on your environment.
4. Get a YouTube API Key
Set Up Environment Variables
Create a .env
file in the root directory and add your API key:
6. Finalize Package Setup
This validates and installs local dependencies including the data-universe
package.
If you encounter an error like:ModuleNotFoundError
Go back to the root directory and run:
You’ll be prompted to select one of the following:
Scrape using a default test script
Scrape any video of your choice
Scrape up to 5 random videos from a specific channel
Transcripts are returned in the terminal. For local downloads, use the Custom API endpoints below.
Navigate to the project root and run:
Downloads transcript to local machine
Headers
X-API-KEY
"youtube_api_key"
Body (JSON)
video_id
video id of youtube video
Response
Scrapes random videos , allowing you specify the total number of videos you'd like to scrape
Headers
X-API-KEY
"youtube_api_key"
Body (JSON)
channel_id
Youtube Channel ID
Response
These endpoints wrap the CLI scraper logic and save the output to your local Transcripts
folder in .txt
and .pdf
formats.
You can test these APIs using Postman by:
Setting request method to POST
Using the appropriate URL
Providing the correct JSON body
Viewing transcript generation in your terminal and output folder
For this example, we're using custom video scrapper endpoint , when you send the request , a Transcript
folder is generated and your desired transcript is downloaded to your local machine in PDF and .txt format!
Now lets interact with our custom scrapper using a sample frontend application
To setup the frontend, open a split terminal and navigate into the frontend folder
2. Install Dependencies
Set Up Frontend Environment Variables
Create a .env
file in the frontend directory:
Launch the frontend app
Follow any of the links and it will spin up a sample application for the youtube scrapper on your local machine
Paste a YouTube video URL or ID
Click Scrape Video
Then click Download Transcript
Transcripts are saved to the local Transcripts
folder in .pdf formats. You can monitor scraper activity via the terminal.
Visit and follow to generate your API key.
POST
POST