First commit

This commit is contained in:
Twentysix
2016-01-02 10:25:47 +01:00
parent 4d6930c3a7
commit 18061321cb
31 changed files with 2860 additions and 0 deletions

29
youtubeparser.py Normal file
View File

@@ -0,0 +1,29 @@
from bs4 import BeautifulSoup
import requests
import asyncio
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
def parsePlaylist(url):
try:
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
tags = soup.find_all("tr", class_="pl-video yt-uix-tile ")
links = []
for tag in tags:
links.append("https://www.youtube.com/watch?v=" + tag['data-video-id'])
if links != []:
return links
else:
return False
except:
return False
def getTitle(url):
try:
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
return soup.title.string.replace(" - YouTube", "")
except:
return False