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


Python urlparse.urlparse方法代码示例

本文整理汇总了Python中urlparse.urlparse.urlparse方法的典型用法代码示例。如果您正苦于以下问题:Python urlparse.urlparse方法的具体用法?Python urlparse.urlparse怎么用?Python urlparse.urlparse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urlparse.urlparse的用法示例。


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

示例1: parse_web_url_from

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def parse_web_url_from(recently_played_url):
# builds the youtube url from plugin://plugin.video.youtube/play/?video_id=dIgSKPzLC9g
# grabs the youtube url from plugin://plugin.video.reddit_viewer/?mode=play&url=https%3A%2F%2Fyoutu.be%2FUhOx-FpEAQk
# excludes googlevideo.com/videoplayback
    from domains import ClassYoutube
    ret_url=recently_played_url.split("|", 1)[0] #remove |Useragent:...
    link_components=urlparse.urlparse( recently_played_url )
    #log("*****{0} scheme[{1}]**".format( recently_played_url, link_components.scheme ) )
    if link_components.scheme=="plugin":
        query = urlparse.parse_qs(link_components.query)
        netloc=link_components.netloc

        if netloc=="plugin.video.reddit_viewer":
            ret_url=''.join(query.get("url"))
        elif netloc=="plugin.video.youtube":
            video_id=query.get("video_id")
            ret_url=ClassYoutube.build_youtube_url_with_video_id(''.join(video_id))  #''.join(video_id)  <-- list to string
            #log("***** video ID="+''.join(video_id)) #ClassYoutube
    elif link_components.scheme=="https":
        #log(link_components.path)
        if link_components.path.startswith('/videoplayback'): #youtube videos parsed by youtube_dl are unplayable from history, we exclude it here
            ret_url=None

    return ret_url 
开发者ID:gedisony,项目名称:script.reddit.reader,代码行数:26,代码来源:actions.py

示例2: join

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def join(base,url):
    join = urlparse.urljoin(base,url)
    url = urlparse.urlparse(join)
    path = posixpath.normpath(url[2])
    return urlparse.urlunparse(
        (url.scheme,url.netloc,path,url.params,url.query,url.fragment)
        ) 
开发者ID:catchup4kodi,项目名称:catchup4kodi,代码行数:9,代码来源:f4mDownloader.py

示例3: init

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def init(self, out_stream, url, proxy=None,use_proxy_for_chunks=True,g_stopEvent=None, maxbitrate=0, auth='',swf=None):
        try:
            self.init_done=False
            self.total_frags=0
            self.init_url=url
            self.clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.auth=auth
            #self.auth="pvtoken=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0MDYzMDMxMTV+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPWQxODA5MWVkYTQ4NDI3NjFjODhjOWQwY2QxNTk3YTI0MWQwOWYwNWI1N2ZmMDE0ZjcxN2QyMTVjZTJkNmJjMDQ%3D%2196e4sdLWrezE46RaCBzzP43/LEM5en2KujAosbeDimQ%3D%7Ehmac%3DACF8A1E4467676C9BCE2721CA5EFF840BD6ED1780046954039373A3B0D942ADC&hdntl=exp=1406303115~acl=%2f*~data=hdntl~hmac=4ab96fa533fd7c40204e487bfc7befaf31dd1f49c27eb1f610673fed9ff97a5f&als=0,2,0,0,0,NaN,0,0,0,37,f,52293145.57,52293155.9,t,s,GARWLHLMHNGA,2.11.3,37&hdcore=2.11.3" 
            if self.auth ==None or self.auth =='None' :
                self.auth=''
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.use_proxy_for_chunks=use_proxy_for_chunks
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            self.maxbitrate=maxbitrate
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.clientHeader= urlparse.parse_qsl(self.clientHeader)
                
                print 'header recieved now url and headers are',url, self.clientHeader 
            self.status='init done'
            self.url=url
            self.swf=swf
            #self.downloadInternal(  url)
            return self.preDownoload()
            
            #os.remove(self.outputfile)
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
开发者ID:catchup4kodi,项目名称:catchup4kodi,代码行数:38,代码来源:f4mDownloader.py

示例4: init

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def init(self, out_stream, url, proxy=None,use_proxy_for_chunks=True,g_stopEvent=None, maxbitrate=0, auth=''):
        try:
            self.init_done=False
            self.total_frags=0
            self.init_url=url
            self.clientHeader=None
            self.status='init'
            self.proxy = proxy
            self.auth=auth
            #self.auth="pvtoken=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0MDYzMDMxMTV+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPWQxODA5MWVkYTQ4NDI3NjFjODhjOWQwY2QxNTk3YTI0MWQwOWYwNWI1N2ZmMDE0ZjcxN2QyMTVjZTJkNmJjMDQ%3D%2196e4sdLWrezE46RaCBzzP43/LEM5en2KujAosbeDimQ%3D%7Ehmac%3DACF8A1E4467676C9BCE2721CA5EFF840BD6ED1780046954039373A3B0D942ADC&hdntl=exp=1406303115~acl=%2f*~data=hdntl~hmac=4ab96fa533fd7c40204e487bfc7befaf31dd1f49c27eb1f610673fed9ff97a5f&als=0,2,0,0,0,NaN,0,0,0,37,f,52293145.57,52293155.9,t,s,GARWLHLMHNGA,2.11.3,37&hdcore=2.11.3" 
            if self.auth ==None or self.auth =='None' :
                self.auth=''
            if self.proxy and len(self.proxy)==0:
                self.proxy=None
            self.use_proxy_for_chunks=use_proxy_for_chunks
            self.out_stream=out_stream
            self.g_stopEvent=g_stopEvent
            self.maxbitrate=maxbitrate
            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.clientHeader= urlparse.parse_qsl(self.clientHeader)
                
                print 'header recieved now url and headers are',url, self.clientHeader 
            self.status='init done'
            self.url=url
            #self.downloadInternal(  url)
            return self.preDownoload()
            
            #os.remove(self.outputfile)
        except: 
            traceback.print_exc()
            self.status='finished'
        return False 
开发者ID:mrknow,项目名称:specto,代码行数:37,代码来源:f4mDownloader.py

示例5: playURLRVideo

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def playURLRVideo(url, name, type_):
    dialog_progress_title='URL Resolver'
    dialog_progress_YTDL = xbmcgui.DialogProgressBG()
    dialog_progress_YTDL.create(dialog_progress_title )
    dialog_progress_YTDL.update(10,dialog_progress_title,translation(32014)  )

    from urlparse import urlparse
    parsed_uri = urlparse( url )
    domain = '{uri.netloc}'.format(uri=parsed_uri)
    try:
        import urlresolver
        #hmf = urlresolver.HostedMediaFile(url)
        dialog_progress_YTDL.update(20,dialog_progress_title,translation(32012)  )

        media_url = urlresolver.resolve(url)
        dialog_progress_YTDL.update(80,dialog_progress_title,translation(32013)  )
        if media_url:
            log( '  URLResolver stream url=' + repr(media_url ))

            pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
            pl.clear()
            pl.add(media_url, xbmcgui.ListItem(name))
            xbmc.Player().play(pl, windowed=False)  #scripts play video like this.
        else:
            log( "  Can't URL Resolve:" + repr(url))
            xbmc_notify('URLresolver', translation(32192),icon="type_urlr.png" )  #Failed to get playable url
    except Exception as e:
        xbmc_notify('URLresolver:'+domain, str(e),icon="type_urlr.png" )
    dialog_progress_YTDL.close() 
开发者ID:gedisony,项目名称:script.reddit.reader,代码行数:31,代码来源:actions.py

示例6: parse_host

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def parse_host(host, ui):
    parsed = urlparse(host)
    ui.debug('urlparse.urlparse result: {}'.format(parsed))
    if not parsed.scheme and not parsed.netloc:
        #  protocol missing
        ui.fatal('Cannot parse "--host" argument. Host address must start '
                 'with a protocol such as "http://" or "https://". '
                 'Value given: {}'.format(host))
    base_url = '{}://{}/predApi/v1.0/'.format(parsed.scheme,
                                              parsed.netloc)
    ui.debug('parse_host return value: {}'.format(base_url))
    return base_url 
开发者ID:datarobot,项目名称:batch-scoring,代码行数:14,代码来源:utils.py

示例7: get_endpoint

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def get_endpoint(host, api_version):
    parsed = urlparse(host)
    if not parsed.scheme and not parsed.netloc:
        raise ValueError(
            'Cannot parse "--host" argument. Host address must start '
            'with a protocol such as "http://" or "https://". '
            'Value given: {}'.format(host))

    return '{}://{}/{}/'.format(parsed.scheme, parsed.netloc, api_version) 
开发者ID:datarobot,项目名称:batch-scoring,代码行数:11,代码来源:utils.py

示例8: getBaseUrl

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def getBaseUrl(url):
        from urlparse import urlparse
        parsed_uri = urlparse( url )
        domain = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri)
        return domain 
开发者ID:j00zek,项目名称:crossplatform_iptvplayer,代码行数:7,代码来源:pCommon.py

示例9: iriToUri

# 需要导入模块: from urlparse import urlparse [as 别名]
# 或者: from urlparse.urlparse import urlparse [as 别名]
def iriToUri(self, iri):
        import urlparse
        parts = urlparse.urlparse(iri.decode('utf-8'))
        return urlparse.urlunparse(
            part.encode('idna') if parti==1 else self.urlEncodeNonAscii(part.encode('utf-8'))
            for parti, part in enumerate(parts)
        ) 
开发者ID:j00zek,项目名称:crossplatform_iptvplayer,代码行数:9,代码来源:pCommon.py


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