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


Python urllib.unquote_plus方法代码示例

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


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

示例1: play_url

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def play_url(params):
	torr_link=params['file']
	img=urllib.unquote_plus(params["img"])
	#showMessage('heading', torr_link, 10000)
	TSplayer=tsengine()
	out=TSplayer.load_torrent(torr_link,'TORRENT',port=aceport)
	if out=='Ok':
		for k,v in TSplayer.files.iteritems():
			li = xbmcgui.ListItem(urllib.unquote(k))
			uri = construct_request({
				'torr_url': torr_link,
				'title': k,
				'ind':v,
				'img':img,
				'mode': 'play_url2'
			})
			xbmcplugin.addDirectoryItem(handle, uri, li, False)
	xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
	xbmcplugin.endOfDirectory(handle)
	TSplayer.end() 
开发者ID:tdw1980,项目名称:tdw,代码行数:22,代码来源:default.py

示例2: extract_from_utmz

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def extract_from_utmz(self, utmz):
        parts = utmz.split('.', 4)

        if len(parts) != 5:
            raise ValueError('The given "__utmz" cookie value is invalid.')

        self.creation_time = utils.convert_ga_timestamp(parts[1])
        self.response_count = int(parts[3])
        params = parts[4].split(Campaign.CAMPAIGN_DELIMITER)

        for param in params:
            key, val = param.split('=')

            try:
                setattr(self, self.UTMZ_PARAM_MAP[key], unquote_plus(val))
            except KeyError:
                continue

        return self 
开发者ID:jmarth,项目名称:plugin.video.kmediatorrent,代码行数:21,代码来源:entities.py

示例3: match

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def match(self, path):
        '''Attempts to match a url to the given path. If successful, a tuple is
        returned. The first item is the matchd function and the second item is
        a dictionary containing items to be passed to the function parsed from
        the provided path.

        If the provided path does not match this url rule then a
        NotFoundException is raised.
        '''
        m = self._regex.search(path)
        if not m:
            raise NotFoundException

        # urlunencode the values
        items = dict((key, unquote_plus(val))
                     for key, val in m.groupdict().items())

        # unpickle any items if present
        items = unpickle_dict(items)

        # We need to update our dictionary with default values provided in
        # options if the keys don't already exist.
        [items.setdefault(key, val) for key, val in self._options.items()]
        return self._view_func, items 
开发者ID:jmarth,项目名称:plugin.video.kmediatorrent,代码行数:26,代码来源:urls.py

示例4: add_videos

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def add_videos(episode_tree, SITE):
	episodes = []
	episode_menu = episode_tree.find_all('div', class_ = 'media-module')
	show_name = episode_tree.find('h1').text
	for episode_item in episode_menu:
		episode_name = episode_item.a['data-title']
		episode_thumb = urllib.unquote_plus(episode_item.a.img['data-src'].split('url=')[1])
		try:
			episode_duration = common.format_seconds(episode_item.find('div', class_='timestamp').text.strip())
		except:
			episode_duration = -1
		url = episode_item.a['href']
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels = {	'title' : episode_name,
						'durationinseconds' : episode_duration,
						'TVShowTitle' : show_name }
		episodes.append((u, episode_name, episode_thumb, infoLabels, 'list_qualities', False, 'Full Episode'))
	return episodes 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:23,代码来源:main_natgeo.py

示例5: serveProxy

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def serveProxy(self, path, data):
		realpath = urllib.unquote_plus(path)[6:]
		proxyconfig = realpath.split('/')[-1]
		proxy_object = simplejson.loads(proxyconfig)
		if int(proxy_object['connectiontype']) == 1:
			proxies = proxy_object['dns_proxy']
			MyHTTPHandler._dnsproxy = proxies
			handler = MyHTTPHandler
		elif int(proxy_object['connectiontype']) == 2:
			proxy = proxy_object['proxy']
			us_proxy = 'http://' + proxy['us_proxy'] + ':' + proxy['us_proxy_port']
			proxy_handler = urllib2.ProxyHandler({'http' : us_proxy})
			handler = proxy_handler
		realpath = realpath.replace('/' + proxyconfig, '')
		fURL = base64.b64decode(realpath)
		self.serveFile(fURL, data, handler) 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:18,代码来源:proxy.py

示例6: test_unquoting

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def test_unquoting(self):
        # Make sure unquoting of all ASCII values works
        escape_list = []
        for num in range(128):
            given = hexescape(chr(num))
            expect = chr(num)
            result = urllib.unquote(given)
            self.assertEqual(expect, result,
                             "using unquote(): %s != %s" % (expect, result))
            result = urllib.unquote_plus(given)
            self.assertEqual(expect, result,
                             "using unquote_plus(): %s != %s" %
                             (expect, result))
            escape_list.append(given)
        escape_string = ''.join(escape_list)
        del escape_list
        result = urllib.unquote(escape_string)
        self.assertEqual(result.count('%'), 1,
                         "using quote(): not all characters escaped; %s" %
                         result)
        result = urllib.unquote(escape_string)
        self.assertEqual(result.count('%'), 1,
                         "using unquote(): not all characters escaped: "
                         "%s" % result) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_urllib.py

示例7: _parse_options

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def _parse_options(opts, delim):
    """Helper method for split_options which creates the options dict.
    Also handles the creation of a list for the URI tag_sets/
    readpreferencetags portion."""
    options = {}
    for opt in opts.split(delim):
        key, val = opt.split("=")
        if key.lower() == 'readpreferencetags':
            options.setdefault('readpreferencetags', []).append(val)
        else:
            # str(option) to ensure that a unicode URI results in plain 'str'
            # option names. 'normalized' is then suitable to be passed as
            # kwargs in all Python versions.
            if str(key) in options:
                warnings.warn("Duplicate URI option %s" % (str(key),))
            options[str(key)] = unquote_plus(val)

    # Special case for deprecated options
    if "wtimeout" in options:
        if "wtimeoutMS" in options:
            options.pop("wtimeout")
        warnings.warn("Option wtimeout is deprecated, use 'wtimeoutMS'"
                      " instead")

    return options 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:27,代码来源:uri_parser.py

示例8: print_var_node

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def print_var_node(xml_node, stream):
    name = xml_node.getAttribute('name')
    value = xml_node.getAttribute('value')
    val_type = xml_node.getAttribute('type')

    found_as = xml_node.getAttribute('found_as')
    stream.write('Name: ')
    stream.write(unquote_plus(name))
    stream.write(', Value: ')
    stream.write(unquote_plus(value))
    stream.write(', Type: ')
    stream.write(unquote_plus(val_type))
    if found_as:
        stream.write(', Found as: %s' % (unquote_plus(found_as),))
    stream.write('\n')


#===================================================================================================
# print_referrers
#=================================================================================================== 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:22,代码来源:pydevd_referrers.py

示例9: GetImports

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def GetImports(module_name):
    try:
        processor = pycompletionserver.Processor()
        data = urllib.unquote_plus(module_name)
        def_file, completions = _pydev_imports_tipper.GenerateTip(data)
        return processor.formatCompletionMessage(def_file, completions)
    except:
        s = StringIO.StringIO()
        exc_info = sys.exc_info()

        traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file=s)
        err = s.getvalue()
        pycompletionserver.dbg('Received error: ' + str(err), pycompletionserver.ERROR)
        raise


#=======================================================================================================================
# main
#======================================================================================================================= 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:21,代码来源:pycompletion.py

示例10: do

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def do(self, pc):
        dlink = self.get_dlink(pc)
        name = re.search(r'/([^/]+?)\?', dlink).group(1)
        name = urllib.unquote_plus(name)
        t = os.path.join(os.getcwd(), name)
        infos = {
            'file': t,
            'dir_': os.path.split(t)[0],
            'dlink': dlink,
            #'purl': self._get_play_purl(pc) \
            #   if args.play and self.is_vip else None,
            'purl': self._get_play_purl(pc) if args.play else None,
            'name': name,
            'nn': 1,
            'total_file': 1
        }
        self.download(infos) 
开发者ID:PeterDing,项目名称:iScript,代码行数:19,代码来源:115.py

示例11: do4

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def do4(self, paths):
        for path in paths:
            r = ss.get(path, allow_redirects=False)
            t = re.search(r'fin=(.+?)(&|$)', r.headers['location']).group(1)
            name = urllib.unquote_plus(t)
            self.infos = {
                'name': name,
                'file': os.path.join(os.getcwd(), name),
                'dir_': os.getcwd(),
                'dlink': fast_pcs_server(path)
            }

            if args.play:
                panbaiducom_HOME._play_do(self.infos)
            else:
                panbaiducom_HOME._download_do(self.infos)
            break 
开发者ID:PeterDing,项目名称:iScript,代码行数:19,代码来源:pan.baidu.com.py

示例12: parse_userinfo

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def parse_userinfo(userinfo):
    """Validates the format of user information in a MongoDB URI.
    Reserved characters like ':', '/', '+' and '@' must be escaped
    following RFC 2396.

    Returns a 2-tuple containing the unescaped username followed
    by the unescaped password.

    :Paramaters:
        - `userinfo`: A string of the form <username>:<password>

    .. versionchanged:: 2.2
       Now uses `urllib.unquote_plus` so `+` characters must be escaped.
    """
    if '@' in userinfo or userinfo.count(':') > 1:
        raise InvalidURI("':' or '@' characters in a username or password "
                         "must be escaped according to RFC 2396.")
    user, _, passwd = _partition(userinfo, ":")
    # No password is expected with GSSAPI authentication.
    if not user:
        raise InvalidURI("The empty string is not valid username.")
    user = unquote_plus(user)
    passwd = unquote_plus(passwd)

    return user, passwd 
开发者ID:leancloud,项目名称:satori,代码行数:27,代码来源:uri_parser.py

示例13: url_unescape

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def url_unescape(value, encoding='utf-8', plus=True):
        """Decodes the given value from a URL.

        The argument may be either a byte or unicode string.

        If encoding is None, the result will be a byte string.  Otherwise,
        the result is a unicode string in the specified encoding.

        If ``plus`` is true (the default), plus signs will be interpreted
        as spaces (literal plus signs must be represented as "%2B").  This
        is appropriate for query strings and form-encoded values but not
        for the path component of a URL.  Note that this default is the
        reverse of Python's urllib module.

        .. versionadded:: 3.1
           The ``plus`` argument
        """
        unquote = (urllib_parse.unquote_plus if plus else urllib_parse.unquote)
        if encoding is None:
            return unquote(utf8(value))
        else:
            return unicode_type(unquote(utf8(value)), encoding) 
开发者ID:tp4a,项目名称:teleport,代码行数:24,代码来源:escape.py

示例14: _stubbornly_unquote

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def _stubbornly_unquote(self, value):
        # Note: we can assume that the value has been unquoted (from
        # %-encoding) by the Pyramid stuff, but the following stubborn
        # unquoting is added for cases when data have been quoted by
        # the client "too many times"; we try to be "liberal in what we
        # accept" because, indeed, it is quite easy to get lost in all
        # this encoding stuff :-).  But, on the other hand, we would
        # not like to allow for any ambiguities, so we accept *only*
        # URL-safe-Base64-encoding, not standard-Base64-encoding (as
        # the latter involves '+' whose meaning would not be clear:
        # it could be interpreted as a plus sign or as a space which,
        # then, could be interpreted just as an "ignorable filler"...).
        # Note, therefore, that it becomes *not* crucial whether we use
        # `urllib.unquote()` or `urllib.unquote_plus()` here -- because
        # URL-safe-Base64-encoding does *not* allow plus signs (and we
        # also *forbid* spaces, even as "ignorable fillers").
        for _ in xrange(10):
            # ^ limited number of steps because we do not like allowing
            #   API clients to make us go into an infinite loop... :-]
            value = urllib.unquote_plus(value)
            if '%' not in value and '+' not in value:
                break
        return value 
开发者ID:CERT-Polska,项目名称:n6,代码行数:25,代码来源:fields.py

示例15: play_url2

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import unquote_plus [as 别名]
def play_url2(params):
	#torr_link=params['torr_url']
	torr_link=urllib.unquote_plus(params["torr_url"])
	img=urllib.unquote_plus(params["img"])
	title=urllib.unquote_plus(params["title"])
	#showMessage('heading', torr_link, 10000)
	TSplayer=tsengine()
	out=TSplayer.load_torrent(torr_link,'TORRENT',port=aceport)
	if out=='Ok':
		TSplayer.play_url_ind(int(params['ind']),title, icon, img)
	TSplayer.end()

#======================================= 
开发者ID:tdw1980,项目名称:tdw,代码行数:15,代码来源:default.py


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