-
-
Save twhite96/9d96561dbfc4ee0ac94667f44146764e to your computer and use it in GitHub Desktop.
Python YouTube Playlist Link Collector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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