YouTube is one of the most popular online video platforms. Videos are published on different topics, such as music, entertainment, education, news, sports, and more.

YouTube also has a feature called shorts, vertical videos, 60 seconds long and can be created and watched on mobile devices. YouTube shorts are similar to TikTok videos and Instagram Reels.

YouTube short video results can be very helpful for data analysis, content creation, marketing research, or personal interest.

YouTube has dynamic web pages. YouTube also has anti-scraping: captchas, IP blocking, and rate limiting that can prevent you from scraping large data you want.

By using SerpApi, you don't need to worry about these noises. SerpApi provides high-quality and reliable results for Youtube Search Results and other platforms. You can customize your searches by using keywords, country, location, language, etc.


Setting up a SerpApi account

SerpApi offers a free plan for newly created accounts. Head to the sign-up page to register an account and do your first search with our interactive playground. When you want to do more searches with us, please visit the pricing page.

Once you are familiar with all the results, you can utilize SERP APIs using your API Key.

Scrape your first YouTube Shorts videos result with SerpApi

Head to the YouTube search results from the documentation on SerpApi for details.

In this tutorial, we will scrape and extract the shorts videos results of "coffee" keyword. The data contains: "id", "title", "link", "thumbnail", "views".

First, you need to install the SerpApi client library.

pip install google-search-results

Set up the SerpApi credentials and search.

import serpapi, os, json

params = {
    'api_key': 'YOUR_API_KEY',         # your serpapi api
    'engine': 'youtube',               # SerpApi search engine	
    'search_query': 'coffee'
}

To retrieve YouTube shorts videos results for a given search term, you can use the following code:

client = serpapi.Client()
shorts_results = client.search(params)['shorts_results']
results = []

for shorts_hash in shorts_results:
    results = results + shorts_hash['shorts']

You can store Shorts videos results JSON data in databases or export them to a CSV file.

import csv

header = ['id', 'title', 'link', 'thumbnail', 'views']

with open('youtube_shorts.csv', 'w', encoding='UTF8', newline='') as f:
    writer = csv.writer(f)

    writer.writerow(header)

    for item in results:
        print(item)
        writer.writerow([item.get('video_id'), item.get('title'), item.get('link'), item.get('thumbnail'), item.get('views')])

This example is using Python, but you can also use your all your favorite programming languages like Ruby, NodeJS, Java, PHP, and more.

If you have any questions, please feel free to contact me.