Advertisement
Guest User

Youtube Scraper

a guest
Nov 27th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. """
  2. Name : youtube_scraper.py
  3. Author : WestEastDevs Inc.
  4. Usage : youtube_scraper.py
  5. Main Purpose : For a given youtube video ID - retrieve the google drive URL for the same video
  6.  
  7. Change Log :
  8. 27.11.2015 - Created.
  9. """
  10.  
  11. import urllib2
  12. import re
  13.  
  14. def get_video_url(html_result):
  15. """
  16. get_video_url() -> string
  17.  
  18. Purpose : Get the google drive URL for a given html response
  19.  
  20. Parameters : @html_result - The result of the HTML request
  21.  
  22.  
  23. Return Value : The URL for the Google Drive video
  24. """
  25. result = re.findall(",\"src\":\"(.*?)\"", html_result)[0]
  26. return result.replace("\\", "")
  27.  
  28.  
  29. def main():
  30. required_video = raw_input("Please insert required video ID : ")
  31.  
  32. response = urllib2.urlopen("http://reel.pk/embed/" + required_video).read()
  33.  
  34. print "\nThe Google Drive URL : \n\n", get_video_url(response)
  35.  
  36.  
  37.  
  38.  
  39.  
  40. if __name__ == '__main__':
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement