Skip to content

Instantly share code, notes, and snippets.

@mbcrump
Last active January 18, 2019 20:38
Show Gist options
  • Save mbcrump/8cd65fa6bdc33a11561958a87477cc51 to your computer and use it in GitHub Desktop.
Save mbcrump/8cd65fa6bdc33a11561958a87477cc51 to your computer and use it in GitHub Desktop.
Pull down title and url of all Azure Tips and Tricks videos
# Author: Michael Crump
# Date: 1/18/2019
# Functionality: To easily scrape an Azure YouTube playlist of the title and url and format it with '{number}. title url [new line] and -
from bs4 import BeautifulSoup as bs
import requests
r = requests.get('https://www.youtube.com/playlist?list=PLLasX02E8BPCNCK8Thcxu-Y-XcBUbhFWC')
page = r.text
soup=bs(page,'html.parser')
for i, tr in enumerate(soup.select('tr.pl-video')):
print('{}. {}'.format(i + 1, tr['data-title']))
print('https://www.youtube.com' + tr.a['href'])
print('-' * 80)
# Author: Michael Crump
# Date: 1/18/2019
# Functionality: To scrape an Azure YouTube playlist of the title and url and format is with 'title - url'
from bs4 import BeautifulSoup as bs
import requests
r = requests.get('https://www.youtube.com/playlist?list=PLLasX02E8BPCNCK8Thcxu-Y-XcBUbhFWC')
page = r.text
soup=bs(page,'html.parser')
for i, tr in enumerate(soup.select('tr.pl-video')):
print('{} - https://www.youtube.com{}'.format(tr['data-title'], tr.a['href']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment