Need help with Trending-YouTube-Scraper?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

167 Stars 113 Forks BSD 2-Clause "Simplified" License 11 Commits 6 Opened issues


Python script that scrapes the currently trending YouTube videos in a variety of countries

Services available


Need anything else?

Contributors list

No Data

Trending YouTube Video Scraper

Originally used to build this dataset on Kaggle, which has about 6 months worth of trending YouTube videos on it. This script will scrape the most relevant information from videos that are currently trending on YouTube in a specified set of countries. You can find example output files in the output directory.

Trending YouTube videos for whatever country you are in currently can be found here.



In order to use this script, you will need a valid API key for the YouTube Data API. It is free and the instructions for doing so are here. It is slightly awkward to get a key, but if you follow the instructions you should be ok.

Once you have the key, put it inside a text file named

in the same directory as the script, or if it's not in the same directory you can target it with the


The only module needed that is not in the standard library is the


Country Codes

In order to run, the script needs country codes for the countries to collect trending videos from. These are 2 letter country abbreviations according to ISO 3166-1. A list of all existing ones can be found here, however not all of these are assured to work with the YouTube API. This project comes with a list of 10 inside the


Running the Script

The script is fairly simple to run, it takes the following optional parameters:

  • --key_path
    which takes a path argument that targets the text file containing your API key. By default this is
    in the current directory.
  • --country_code_path
    which takes a path argument that targets the text file containing the list of country codes to target. By default this is
    in the current directory.
  • --output_dir
    which takes a path argument that specifies the folder to create the output CSV files for each country. By default this is
    in the current directory.


This project is licensed under the BSD 2-Clause License - see the file for details

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.