In [1]:
import requests
from bs4 import BeautifulSoup

In [8]:
class VidSource(object):
    def __init__(self, url, keyclass = ['iframe','video','embed']):
        self.url = url
        self.soupa = ''
        self.links = []
        self.keys = keyclass
    
    def __getUrlSource__(self, url):
        source_object = requests.get(url)
        soup = BeautifulSoup(source_object.text, 'html.parser')
        return(soup)
        
    def _getLinks_(self, termlist, soup):
        for i in termlist:
            self._loadIframes_(i, soup)
            
    def _loadIframes_(self, i, soup):
        soup.findAll(i)
        count = count + 1
        if len(k)>0:
            for j in k:
                if j['src'] is None:
                    soupb = self.__getUrlSource__(j['src'])
                    if count < 4:
                        self._getLinks_(['video', 'embed'], soupb)
                if j['src'] is not None:
                    self._filter_(j['src'])
                    
    def _filter_(self, url):
        soup = self.getUrlSource(url)
        k = soup.findAll(self.query)
        if len(k) > 0:
            self.links.append(url)
    
    def getResults(self):
        count = 0
        self.soupa = self.__getUrlSource__(self.url)
        self._getLinks_(self.keys, self.soupa)
        
            
        
url = 'http://hindimoviesonline.watch/dangal-full-movie-online/'
source_object = requests.get(url)
soup = BeautifulSoup(source_object.text, 'html.parser')
#print(soup.prettify())
keyclass = ['iframe','video','embed']


  File "<ipython-input-8-d527d2f25a1b>", line 21
    if len(k)>0:
     ^
IndentationError: expected an indented block

In [3]:
videolinks = []
for i in keyclass:
    k = soup.findAll(i)
    #print(k)
    if len(k)>0:
        for j in k:
            if j['src'] is not None:
                videolinks.append(j['src'])
print(videolinks)


['http://videohost.site/play/y0mgnHcdyduX0M8/', 'http://videohost1.com/play/EEYV5Bmbdwj9ZDy/', 'http://hindimoviesonline.watch/wp-content/uploads/AroundTheWorld.html', 'http://hindimoviesonline.watch/wp-content/uploads/new.html', 'http://hindimoviesonline.watch/wp-content/uploads/TrendingNow.html']

In [4]:
r = requests.head('https://redirector.googlevideo.com/videoplayback?id=7f21afcf6ec3a2de&itag=18&source=webdrive&requiressl=yes&ttl=transient&mm=30&mn=sn-2gb7sn7z&ms=nxu&mv=u&nh=IgpwcjAyLnByZzAzKgkxMjcuMC4wLjE&pl=48&mime=video/mp4&lmt=1484994549959561&mt=1486209357&ip=2001:67c:2db8:7::3e0&ipbits=128&expire=1486223899&sparams=ip%2Cipbits%2Cexpire%2Cid%2Citag%2Csource%2Crequiressl%2Cttl%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cmime%2Clmt&signature=4B892C683301E049240AF81D173768BE210CA4B6.7B4F270C05B75E369293F1F1AF92D03F8E7222D6&key=ck2&app=explorer&driveid=0B2aSpxR38G5MUVBsR3FETElZQ3c')
print (r.headers)


{'Pragma': 'no-cache', 'Date': 'Sun, 05 Feb 2017 06:08:58 GMT', 'Expires': 'Fri, 01 Jan 1990 00:00:00 GMT', 'Cache-Control': 'no-cache, must-revalidate', 'Content-Type': 'text/html; charset=UTF-8', 'X-XSS-Protection': '1; mode=block', 'Alt-Svc': 'quic=":443"; ma=2592000; v="35,34"', 'Server': 'ClientMapServer', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Length': '2188'}

In [ ]: