Advertisement
Guest User

Get Youtube Videos

a guest
Jun 5th, 2015
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import urllib2
  3. import re
  4.  
  5. data = []
  6.  
  7. def getURLSource(linkToURL):
  8.     try:
  9.         response = urllib2.urlopen(linkToURL)
  10.         html = response.read()
  11.         return html
  12.     except:
  13.         print("It didn't work :(")
  14.  
  15. def getAllYTLinks(source):
  16.     pattern = 'http://www.youtube.com/embed/...........'
  17.     action = re.compile(pattern)
  18.     result = re.findall(action, source)
  19.     data.append(result)
  20.    
  21. def IterateOverURLs(baseURL):
  22.     for i in range(119):
  23.         source = getURLSource(baseURL + str(i*10))
  24.         getAllYTLinks(source)
  25.  
  26. baseURL = 'http://www.outbreak-community.com/viewtopic.php?f=45&t=149&start='
  27. IterateOverURLs(baseURL)
  28.  
  29.  
  30. print data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement