Skip to content

Instantly share code, notes, and snippets.

@fffaraz
Created November 25, 2016 20:21
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save fffaraz/f3dcf48ae93b6c04adb9d74b1de711e5 to your computer and use it in GitHub Desktop.
Save fffaraz/f3dcf48ae93b6c04adb9d74b1de711e5 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')
@dahmadjid
Copy link

what do you mean by in conjuction with selenium ? how exactly should you use selenium to solve the infinite scroll problem ?
im working on a playlist with more than 100 and i need to solve this so that i can order the downloaded videos according to the playlist by adding numbers

@Axeltherabbit
Copy link

Made a quick fork https://gist.github.com/Axeltherabbit/5b147d508faf1b5cd735a52bd916b1e4 (No, doesn't solve the 100 video problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment