Skip to content

Instantly share code, notes, and snippets.

@andkamau
andkamau / youtube_screen_scrape.py
Created October 16, 2016 18:38 — forked from ljmccarthy/youtube_screen_scrape.py
An example of how to download metadata for all videos of a specified YouTube channel using simple BeautifulSoup screen scraping. The data will be much more up-to-date and reliable than the RSS feed or YouTube API results (which is a sad state of affairs really).
import urllib
import json
from bs4 import BeautifulSoup
from collections import namedtuple
Video = namedtuple("Video", "video_id title duration views thumbnail")
def parse_video_div(div):
video_id = div.get("data-context-item-id", "")
title = div.find("a", "yt-uix-tile-link").text