当前位置: 首页>>代码示例>>Python>>正文


Python client.agent函数代码示例

本文整理汇总了Python中modules.client.agent函数的典型用法代码示例。如果您正苦于以下问题:Python agent函数的具体用法?Python agent怎么用?Python agent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了agent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_link

def find_link(url, html=''):
    global limit
    limit+=1
    log('Finding in : %s'%url)
    try: referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0]
    except: referer = 'http://' + urlparse.urlparse(url).netloc
    host  = urlparse.urlparse(url).netloc
    headers = {'Referer':referer, 'Host':host, 'User-Agent' : client.agent(), 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language' : 'en-US,en;q=0.5'}
    
    if html=='':
        url = manual_url_fix(url)
        html = client.request(url, headers=headers)
        html = manual_html_fix(url,html,headers)

    ref=url
    fs=list(globals().copy())
    for f in fs:
        if 'finder' in f:
            resolved = eval (f+"(html,ref)")
            if resolved:
                log('Resolved with %s: %s'%(f,resolved))
                return resolved
                break


    return
开发者ID:c0ns0le,项目名称:YCBuilds,代码行数:26,代码来源:__init__.py

示例2: finder1

def finder1(html,url):
    global limit
    ref=url
    try:
        urls = re.findall('<i?frame.+?src=(?:\'|\")(.+?)(?:\'|\")',html)
        try:
            urls.append(re.findall("playStream\('iframe', '(.+?)'\)",html)[0])
        except: pass
        for url in urls:
            if 'c4.zedo' in url:
                continue
            if "micast" in url or 'turbocast' in url:
                return finder47(html,ref)
            rr = resolve_it(url)
            if rr:
                return rr
            uri = manual_fix(url,ref)
            if limit>=25:
                log("Exiting - iframe visit limit reached")
                return
            resolved = find_link(uri) 
            if resolved:
                break
        headers = {'User-Agent': client.agent(), 'Referer': ref}
        if '.m3u8' in resolved and '|' not in resolved:
            headers.update({'X-Requested-With':'ShockwaveFlash/20.0.0.228', 'Host':urlparse.urlparse(resolved).netloc, 'Connection':'keep-alive'})
            resolved += '|%s' % urllib.urlencode(headers)
        return resolved
    except:
        return
开发者ID:c0ns0le,项目名称:YCBuilds,代码行数:30,代码来源:__init__.py

示例3: finder72

def finder72(html,ref):
    try:
        url = re.findall('src\s*:\s*\'(.+?(?:.m3u8)?)\'',html)[0]
        url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref})
        return url
    except:
        pass
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:7,代码来源:__init__.py

示例4: find_link

def find_link(url, html=''):
    log('Finding in : %s'%url)
    try: referer = urlparse.parse_qs(urlparse.urlparse(url).query)['referer'][0]
    except: referer = 'http://' + urlparse.urlparse(url).netloc
    host  = urlparse.urlparse(url).netloc
    headers = {'Referer':referer, 'Host':host, 'User-Agent' : client.agent(), 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language' : 'en-US,en;q=0.5'}
    
    if html=='' or html is None:
        url = manual_url_fix(url)
        html = client.request(url, headers=headers)
        if 'livetvcdn' in url or 'shadow' in url or 'blog' in url and 'goto/' not in url:
            import requests
            s = requests.Session()
            r = s.get(url,headers=headers)
            html = r.text


    ref=url
    fs=list(globals().copy())
    for f in fs:
        if 'finder' in f:
            resolved = eval (f+"(html,ref)")
            if resolved:
                log('Resolved with %s: %s'%(f,resolved))
                return resolved
                break
    return
开发者ID:tvspeler,项目名称:SportStreams,代码行数:27,代码来源:__init__.py

示例5: resolve_it

def resolve_it(url, title='Video',icon='x'):
    if '.m3u8' in url or 'rtmp:' in url or '.flv' in url or '.mp4' in url or '.ts' in url or url.startswith('plugin://'):
        if '.m3u8' in url and '|' not in url:
            url += '|%s' % urllib.urlencode({'User-Agent': client.agent()})
        if '.ts' in url:
            url = 'plugin://plugin.video.f4mTester/?name=%s&iconImage=%s&streamtype=TSDOWNLOADER&url='%(urllib.quote(title),urllib.quote(icon)) + urllib.quote(url)
        return url

    if '.f4m' in url:
        from resolvers import f4m
        resolved = f4m.resolve(url)
        return resolved

    if url.startswith('acestream://') or url.startswith('sop://') or '.acelive' in url:
        from resolvers import sop_ace
        resolved = sop_ace.resolve(url, title)
        return resolved
    netloc = prepare(urlparse.urlparse(url).netloc)
    if netloc in resolver_dict.keys():
        resolver = resolver_dict[netloc]
        log("Calling resolver: " + resolver)
        exec "from resolvers import %s"%resolver
        resolved = eval(resolver+".resolve(url)")
        return resolved

    else:
       return 
开发者ID:stick141,项目名称:modules4all,代码行数:27,代码来源:__init__.py

示例6: resolve_it

def resolve_it(url, title='Video'):
    if '.m3u8' in url or 'rtmp:' in url or '.flv' in url or '.mp4' in url or '.ts' in url or url.startswith('plugin://'):
        if '.m3u8' in url and '|' not in url:
            url += '|%s' % urllib.urlencode({'User-Agent': client.agent()})
        return url

    if '.f4m' in url:
        from resolvers import f4m
        resolved = f4m.resolve(url)
        return resolved

    if url.startswith('acestream://') or url.startswith('sop://') or '.acelive' in url:
        from resolvers import sop_ace
        resolved = sop_ace.resolve(url, title)
        return resolved
    netloc = prepare(urlparse.urlparse(url).netloc)
    if netloc in resolver_dict.keys():
        resolver = resolver_dict[netloc]
        log("Calling resolver: " + resolver)
        exec "from resolvers import %s"%resolver
        resolved = eval(resolver+".resolve(url)")
        return resolved

    else:
       return 
开发者ID:tvspeler,项目名称:SportStreams,代码行数:25,代码来源:__init__.py

示例7: finder73

def finder73(html,url):
    try:
        ref = url
        url = re.findall('Player\(\{\n\s*source\:\s*\'(.+?)\'\,',html)[0]
        url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref})
        return url
    except:
        return
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:8,代码来源:__init__.py

示例8: finder79

def finder79(html,url):
    try:
        ref = url
        url = re.findall("playStream\('hls', '(.+?)'",html)[0] 
        url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref, 'X-Requested-With':constants.get_shockwave(), 'Host':urlparse.urlparse(url).netloc, 'Connection':'keep-alive','Accept':'*/*'})
        return url
    except:
        return
开发者ID:tvspeler,项目名称:SportStreams,代码行数:8,代码来源:__init__.py

示例9: finder75

def finder75(html,url):
    try:
        ref = url
        url = re.findall('file: window.atob\(\'(.+?)\'\),', html)[0]
        file = base64.b64decode(url)
        file += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref, 'X-Requested-With':constants.get_shockwave(), 'Host':urlparse.urlparse(file).netloc, 'Connection':'keep-alive','Accept':'*/*'})
        return file
    except:
        return
开发者ID:tvspeler,项目名称:SportStreams,代码行数:9,代码来源:__init__.py

示例10: finder107

def finder107(html,ref):
    try:
        m3u8 = re.findall('playlist_url:\s*[\"\']([^\"\']+)',html)[0]
        host = re.findall('cdn_host:\s*[\"\']([^\"\']+)',html)[0]
        url = 'http://' + host + m3u8
        url+='|%s' % urllib.urlencode({'Referer':ref, 'User-agent':client.agent()})
        return url
    except:
        return
开发者ID:tvspeler,项目名称:SportStreams,代码行数:9,代码来源:__init__.py

示例11: finder65

def finder65(html,url):
    try:
        referer = url
        url = re.findall('src=(?:\'|\")(.+?)(?:\'|\").+?type="video/mp4"',html)[0]
        url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': referer})

        return url
    except:
        return
开发者ID:bialagary,项目名称:mw,代码行数:9,代码来源:__init__.py

示例12: finder73

def finder73(html,url):
    try:
        ref = url
        url = re.findall('Player\(\{\n\s*source\:\s*[\'\"](.+?)[\'\"]\,',html)[0]
        url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref})
        if 'ace/manifest' in url:
            url = finder102(html,url)
        return url
    except:
        return
开发者ID:tvspeler,项目名称:SportStreams,代码行数:10,代码来源:__init__.py

示例13: finder92

def finder92(html,ref):
    try:
        url = re.findall('source\s*src=\s*"\s*(.+?)\s*"\s*type=\s*"\s*application/x-mpegURL\s*"\s*/>',html)[0]
        if 'rtmp' in url:
            url+=' swfUrl=http://www.shadow-net.biz/javascript/videojs/flashls/video-js.swf flashver=%s live=true timeout=18 swfVfy=1 pageUrl=http://www.shadow-net.biz/'%FLASH
        elif 'm3u8' in url:

            url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref, 'X-Requested-With':'ShockwaveFlash/20.0.0.286', 'Host':urlparse.urlparse(url).netloc, 'Connection':'keep-alive','Accept':'*/*', 'Origin':'http://shadow.go.ro'})
        return url
    except:
        return
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:11,代码来源:__init__.py

示例14: finder92

def finder92(html,ref):
    try:
        url = re.findall('src=[\"\']([^\"\']+)[\"\'].+?mpeg',html)[0]
        if 'rtmp' in url:
            url+=' swfUrl=http://www.shadow-net.biz/javascript/videojs/flashls/video-js.swf flashver=%s live=true timeout=18 swfVfy=1 pageUrl=http://www.shadow-net.biz/'%FLASH
        elif 'm3u8' in url:

            url += '|%s' % urllib.urlencode({'User-Agent': client.agent(), 'Referer': ref, 'X-Requested-With':constants.get_shockwave(), 'Host':urlparse.urlparse(url).netloc, 'Connection':'keep-alive','Accept':'*/*', 'Origin':'http://shadow.go.ro'})
        return url
    except:
        return
开发者ID:tvspeler,项目名称:SportStreams,代码行数:11,代码来源:__init__.py

示例15: finder1

def finder1(html,url):
    html = html.replace('/adplus/adplus.html?id=','')
    try:html = urllib.unquote(html)
    except:pass
    global limit
    limit+=1
    ref=url
    try:
        urls = re.findall('<i?frame\s*.+?src=(?:\'|\")(.+?)(?:\'|\")',html,flags=re.IGNORECASE)
        urly = client.parseDOM(html, "iframe", ret="src")
        urlc = re.findall('top.location.href\s*=\s*[\'\"](.+?axe-tv[^\'\"]+)[\'\"]',html)
        for url in urlc:
            if 'sky-sports-1' not in url and 'fox1ushd' not in url:
                urls.append(url)
        urls += urly
        try:
            urls.append(re.findall("playStream\('iframe', '(.+?)'\)",html)[0])
        except: pass

        urls += re.findall('<a.+?href=[\'\"](/live-.+?stream.+?)[\'\"]',html)
        urls += re.findall('(http://www.hdmyt.info/(?:channel|player).php\?file=[^"\']+)["\']',html)
        
        from random import shuffle
        for url in urls:
            url = url.replace('https','http')
            if 'c4.zedo' in url or 'ProtectFile.File' in url or 'adServe' in url or 'facebook' in url or 'banner' in url:
                continue

            elif "micast" in url or 'turbocast' in url:
                return finder47(html,ref)
                
            elif 'lshstream' in url:
                return finder2(url,url)    

            rr = resolve_it(url)
            if rr:
                return rr
            uri = manual_fix(url,ref)
            if limit>=25:
                log("Exiting - iframe visit limit reached")
                return
            resolved = find_link(uri) 
            if resolved:
                break
        headers = {'User-Agent': client.agent(), 'Referer': ref}
        if '.m3u8' in resolved and '|' not in resolved:
            headers.update({'X-Requested-With':constants.get_shockwave(), 'Host':urlparse.urlparse(resolved).netloc, 'Connection':'keep-alive'})
            resolved += '|%s' % urllib.urlencode(headers)
        return resolved
    except:
        return
开发者ID:stick141,项目名称:modules4all,代码行数:51,代码来源:__init__.py


注:本文中的modules.client.agent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。