Skip to content

Instantly share code, notes, and snippets.

@twhite96
Forked from fffaraz/bs4.py
Created October 18, 2018 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhite96/9d96561dbfc4ee0ac94667f44146764e to your computer and use it in GitHub Desktop.
Save twhite96/9d96561dbfc4ee0ac94667f44146764e to your computer and use it in GitHub Desktop.
Python YouTube Playlist Link Collector
from bs4 import BeautifulSoup
import requests
def getPlaylistLinks(url):
sourceCode = requests.get(url).text
soup = BeautifulSoup(sourceCode, 'html.parser')
domain = 'https://www.youtube.com'
for link in soup.find_all("a", {"dir": "ltr"}):
href = link.get('href')
if href.startswith('/watch?'):
print(link.string.strip())
print(domain + href + '\n')
getPlaylistLinks('Playlist url')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment