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


Python urllib.unquote_plus函数代码示例

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


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

示例1: get_clean_body

def get_clean_body(response):
    """
    :see: BlindSqliResponseDiff.get_clean_body()

    Definition of clean in this method:
        - input:
            - response.get_url() == http://host.tld/aaaaaaa/
            - response.get_body() == 'spam aaaaaaa eggs'

        - output:
            - self._clean_body( response ) == 'spam  eggs'

    The same works with file names.
    All of them, are removed encoded and "as is".

    :param response: The HTTPResponse object to clean
    :return: A string that represents the "cleaned" response body of the
             response.
    """
    body = response.body

    if response.is_text_or_html():
        url = response.get_url()
        to_replace = url.url_string.split('/')
        to_replace.append(url.url_string)

        for repl in to_replace:
            if len(repl) > 6:
                body = body.replace(repl, '')
                body = body.replace(urllib.unquote_plus(repl), '')
                body = body.replace(cgi.escape(repl), '')
                body = body.replace(cgi.escape(urllib.unquote_plus(repl)), '')

    return body
开发者ID:0x554simon,项目名称:w3af,代码行数:34,代码来源:fingerprint_404.py

示例2: processWithMap

def processWithMap(qs):
	r = {}
	for item in qs.split("&"):
		item = item.split("=", 1)
		if not item[1:]:
			item[1] = None
		key, val = item
		if "[" in key:
			brackets = key.split("[")
			# It's a Array, and it's recursive
			children = r  # Children is just a pointer to r
			c = 0  # Initialize at zero
			l = len(brackets) - 1  # Length-1 to detect end
			for bracket in brackets:
				key_child = bracket.split("]")[0]
				if not key_child and c > 0:
					key_child = str(len(children))
				children[key_child] = children.get(key_child, {})
				if c == l:
					children[key_child] = urllib.unquote_plus(val)
				else:
					children = children[key_child]  # Replaces the pointer
				c += 1
		else:
			# It's not a array \o/
			r[key] = urllib.unquote_plus(val)
	return convertToList(r)
开发者ID:fjorgemota,项目名称:Thupy,代码行数:27,代码来源:querystring.py

示例3: __init__

	def __init__(self):
		global action
		params = {}
		splitparams = sys.argv[2][sys.argv[2].find('?') + 1:].split('&')
		for param in splitparams:
			if (len(param) > 0):
				splitparam = param.split('=')
				key = splitparam[0]
				try:    value = splitparam[1].encode("utf-8")
				except: value = splitparam[1]
				params[key] = value

		try:        action = urllib.unquote_plus(params["action"])
		except:     action = None
		try:        categoryid = urllib.unquote_plus(params["categoryid"])
		except:     categoryid = None
		try:        offset = urllib.unquote_plus(params["offset"])
		except:     offset = 0
		try:        movie_id = urllib.unquote_plus(params["movie_id"])
		except:     movie_id = 0
		try:        episode = urllib.unquote_plus(params["episode"])
		except:     episode = 0


		if action == None:                            self.main_menu()
		elif action == 'list_movies':                 self.list_movies(categoryid, offset)
		elif action == 'play_movie':                  self.play_movie(movie_id, episode)
		elif action == 'list_seasons':                self.list_seasons(movie_id)
		elif action == 'list_episodes':               self.list_episodes(movie_id)
		elif action == 'Search':					  self.Search()
开发者ID:minhtuancn,项目名称:kodi-vietkeynet,代码行数:30,代码来源:default.py

示例4: parse_uri

def parse_uri(uri_string):
  """Creates a Uri object which corresponds to the URI string.
 
  This method can accept partial URIs, but it will leave missing
  members of the Uri unset.
  """
  parts = urlparse.urlparse(uri_string)
  uri = Uri()
  if parts[0]:
    uri.scheme = parts[0]
  if parts[1]:
    host_parts = parts[1].split(':')
    if host_parts[0]:
      uri.host = host_parts[0]
    if len(host_parts) > 1:
      uri.port = int(host_parts[1])
  if parts[2]:
    uri.path = parts[2]
  if parts[4]:
    param_pairs = parts[4].split('&')
    for pair in param_pairs:
      pair_parts = pair.split('=')
      if len(pair_parts) > 1:
        uri.query[urllib.unquote_plus(pair_parts[0])] = (
            urllib.unquote_plus(pair_parts[1]))
      elif len(pair_parts) == 1:
        uri.query[urllib.unquote_plus(pair_parts[0])] = None
  return uri
开发者ID:enyst,项目名称:plexnet,代码行数:28,代码来源:http_core.py

示例5: __init__

    def __init__(self):
        global action
        params = {}
        splitparams = sys.argv[2][sys.argv[2].find('?') + 1:].split('&')
        for param in splitparams:
            if (len(param) > 0):
                splitparam = param.split('=')
                key = splitparam[0]
                try:    value = splitparam[1].encode("utf-8")
                except: value = splitparam[1]
                params[key] = value

        try:        action = urllib.unquote_plus(params["action"])
        except:     action = None
        try:        channel = urllib.unquote_plus(params["channel"])
        except:     channel = None

        if action == None:                          channels().get()
        elif action == 'dialog':                    channels().dialog()
        elif action == 'epg_menu':                  contextMenu().epg(channel)
        elif action == 'refresh':                   index().container_refresh()
        elif action == 'play':                      resolver().run(channel)

        xbmcplugin.setContent(int(sys.argv[1]), 'Episodes')
        xbmcplugin.setPluginFanart(int(sys.argv[1]), addonFanart)
        xbmcplugin.endOfDirectory(int(sys.argv[1]))
        return
开发者ID:1c0n,项目名称:lambda-xbmc-addons,代码行数:27,代码来源:default.py

示例6: get_clean_body

def get_clean_body(mutant, response):
    '''
    @see: Very similar to fingerprint_404.py get_clean_body() bug not quite
          the same maybe in the future I can merge both?

    Definition of clean in this method:
        - input:
            - response.get_url() == http://host.tld/aaaaaaa/?id=1 OR 23=23
            - response.get_body() == '...<x>1 OR 23=23</x>...'

        - output:
            - self._clean_body( response ) == '...<x></x>...'

    All injected values are removed encoded and "as is".

    :param mutant: The mutant where I can get the value from.
    :param response: The HTTPResponse object to clean
    :return: A string that represents the "cleaned" response body.
    '''

    body = response.body

    if response.is_text_or_html():
        mod_value = mutant.get_mod_value()

        body = body.replace(mod_value, '')
        body = body.replace(urllib.unquote_plus(mod_value), '')
        body = body.replace(cgi.escape(mod_value), '')
        body = body.replace(cgi.escape(urllib.unquote_plus(mod_value)), '')

    return body
开发者ID:HamzaKo,项目名称:w3af,代码行数:31,代码来源:blind_sqli_response_diff.py

示例7: remFav

def remFav(url):
    log("> remFav()")
    if url:
        try:
            favoritesRE=re.compile('(?i)name=(.+?)&url=(.+?)\n')
            favorites = favoritesRE.findall(url)
            for favorite in favorites:
                name = favorite[0]
                url = favorite[1]
            nameurl = 'name=%s&url=%s%s' % (name, url, '\n')
            if dialog.yesno( __plugin__ + ' v' + __version__, __language__(30009), '', urllib.unquote_plus(name).decode('utf-8') ):
                doc = open(FILE_FAVS, "rU")
                text = doc.read().decode('utf-8')
                doc.close()
                doc = open(FILE_FAVS, "w")
                doc.write(text.replace(nameurl, ''))
                doc.close()    
                xbmc.executebuiltin('Container.Refresh')
                dialog.ok( __plugin__ + ' v' + __version__, __language__(30010), '', urllib.unquote_plus(name).decode('utf-8') )
                doc = open(FILE_FAVS).read().decode('utf-8')
                if doc == 'This is your favorites file.\n':
                    dialog.ok( __plugin__ + ' v' + __version__, __language__(30016) )
        except:
            dialog.ok( __plugin__ + ' v' + __version__, __language__(30011), '', urllib.unquote_plus(name).decode('utf-8') )
    return True
开发者ID:Xycl,项目名称:plugin.audio.listenliveeu,代码行数:25,代码来源:default.py

示例8: variable_edit

def variable_edit(name=None, scope=None):
  from models.variable import Variable
  
  if name and scope:
    variable = Variable.query.filter_by(name=urllib.unquote_plus(name), scope=urllib.unquote_plus(scope)).first_or_404()
  else:
    variable = Variable()
  
  errors = []
  
  if request.method == 'POST' and request.values.get( 'csrf_token', None ):
    variable.scope = request.form.get('variable_scope')
    variable.name = request.form.get('variable_name')
    variable.raw_value = request.form.get('variable_raw_value')
    errors = variable.validate()
    if not len(errors):
      variable.save()
      flash( g._t('variable submit success'))
      return redirect(url_for('variable_index'))
  
  if name:
    title = g._t('edit')
  else:
    title = g._t('add')
  breadcrumbs = (
    (g._t('administration'), url_for('administration_index')),
    (g._t('variables'), url_for('variable_index')),
    (title, "#")
  )
  
  return render_template('administration/variable/edit.html', title=title, breadcrumbs=breadcrumbs, variable=variable, errors=errors)
开发者ID:timur-glushan,项目名称:tt,代码行数:31,代码来源:variable.py

示例9: parse

    def parse(self):
        """Call feed first"""
        track = self.cut_content_simple('%2C+', '+%2A')[0]
        artist, title = track.split('%2C+')

        self.artist = self.capstext(urllib.unquote_plus(artist))
        self.title = urllib.unquote_plus(title)
开发者ID:Leonidas-from-XIV,项目名称:whatsonair,代码行数:7,代码来源:gong.py

示例10: mirrors

def mirrors(params,url,category):
	logger.info("[capitancinema.py] mirrors")

	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = urllib.unquote_plus( params.get("plot") )

	# Descarga la página
	data = scrapertools.cachePage(url)
	patronvideos  = '<li><strong>DISPONIBLE EN EL FORO</strong>[^<]+<a href="([^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	if len(matches)>0:
		url = matches[0]
		data = scrapertools.cachePage(url)

		# ------------------------------------------------------------------------------------
		# Busca los enlaces a los videos
		# ------------------------------------------------------------------------------------
		listavideos = servertools.findvideos(data)

		for video in listavideos:
			videotitle = video[0]
			url = video[1]
			server = video[2]
			xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , title.strip() + " - " + videotitle , url , thumbnail , plot )
		# ------------------------------------------------------------------------------------

	# Cierra el directorio
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
开发者ID:HackJoues,项目名称:pelisalacarta-personal-fork,代码行数:31,代码来源:capitancinema.py

示例11: playDM

def playDM(id):
    try:
        if xbox:
            addToHistory("plugin://video/My Music TV/?url="+id+"&mode=playDM")
        else:
            addToHistory("plugin://"+addonID+"/?url="+id+"&mode=playDM")
        content = opener.open("http://www.dailymotion.com/embed/video/"+id).read()
        if '"statusCode":410' in content or '"statusCode":403' in content:
            xbmc.executebuiltin('XBMC.Notification(Dailymotion:, Video is not available,5000)')
        else:
            matchFullHD = re.compile('"stream_h264_hd1080_url":"(.+?)"', re.DOTALL).findall(content)
            matchHD = re.compile('"stream_h264_hd_url":"(.+?)"', re.DOTALL).findall(content)
            matchHQ = re.compile('"stream_h264_hq_url":"(.+?)"', re.DOTALL).findall(content)
            matchSD = re.compile('"stream_h264_url":"(.+?)"', re.DOTALL).findall(content)
            matchLD = re.compile('"stream_h264_ld_url":"(.+?)"', re.DOTALL).findall(content)
            url = ""
            if matchFullHD and resolutionDM == "1080p":
                url = urllib.unquote_plus(matchFullHD[0]).replace("\\", "")
            elif matchHD and (resolutionDM == "720p" or resolutionDM == "1080p"):
                url = urllib.unquote_plus(matchHD[0]).replace("\\", "")
            elif matchHQ:
                url = urllib.unquote_plus(matchHQ[0]).replace("\\", "")
            elif matchSD:
                url = urllib.unquote_plus(matchSD[0]).replace("\\", "")
            elif matchLD:
                url = urllib.unquote_plus(matchLD[0]).replace("\\", "")
            listitem = xbmcgui.ListItem(path=url)
            xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
            if infoEnabled:
                showInfo()
    except:
        pass
开发者ID:DayVeeBoi,项目名称:addonscriptorde-beta-repo,代码行数:32,代码来源:default.py

示例12: parse

def parse(query_string, unquote=True):
    '''
    Main parse function
    @param query_string:
    @param unquote: unquote html query string ?
    '''
    mydict = {}
    plist = []
    if query_string == "":
        return mydict
    for element in query_string.split("&"):
        try:
            if unquote:
                (var, val) = element.split("=")
                var = urllib.unquote_plus(var)
                val = urllib.unquote_plus(val)
            else:
                (var, val) = element.split("=")
        except ValueError:
            raise MalformedQueryStringError
        plist.append(parser_helper(var, val))
    for di in plist:
        (k, v) = di.popitem()
        tempdict = mydict
        while k in tempdict and type(v) is dict:
            tempdict = tempdict[k]
            (k, v) = v.popitem()
        if k in tempdict and type(tempdict[k]).__name__ == 'list':
            tempdict[k].append(v)
        elif k in tempdict:
            tempdict[k] = [tempdict[k], v]
        else:
            tempdict[k] = v
    return mydict
开发者ID:goldsoft1206,项目名称:querystring-parser,代码行数:34,代码来源:parser.py

示例13: playLiveVideo

def playLiveVideo(id):
    content = getUrl2("http://www.dailymotion.com/sequence/"+id)
    if content.find('"statusCode":410') > 0 or content.find('"statusCode":403') > 0:
        xbmc.executebuiltin('XBMC.Notification(Info:,'+translation(30022)+' (DailyMotion)!,5000)')
    else:
        matchFullHD = re.compile('"hd1080URL":"(.+?)"', re.DOTALL).findall(content)
        matchHD = re.compile('"hd720URL":"(.+?)"', re.DOTALL).findall(content)
        matchHQ = re.compile('"hqURL":"(.+?)"', re.DOTALL).findall(content)
        matchSD = re.compile('"sdURL":"(.+?)"', re.DOTALL).findall(content)
        matchLD = re.compile('"video_url":"(.+?)"', re.DOTALL).findall(content)
        url = ""
        if matchFullHD and maxVideoQuality == "1080p":
            url = urllib.unquote_plus(matchFullHD[0]).replace("\\", "")
        elif matchHD and (maxVideoQuality == "720p" or maxVideoQuality == "1080p"):
            url = urllib.unquote_plus(matchHD[0]).replace("\\", "")
        elif matchHQ:
            url = urllib.unquote_plus(matchHQ[0]).replace("\\", "")
        elif matchSD:
            url = urllib.unquote_plus(matchSD[0]).replace("\\", "")
        elif matchLD:
            url = urllib.unquote_plus(matchSD2[0]).replace("\\", "")
        if url:
            url = getUrl(url)
            listitem = xbmcgui.ListItem(path=url)
            xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
开发者ID:AddonScriptorDE,项目名称:plugin.video.dailymotion_com,代码行数:25,代码来源:default.py

示例14: get_media_url

    def get_media_url(self, host, media_id):
        if self.get_setting('login') == 'true':
            if self.login_stale():
                self.login()
        self.net.set_cookies(self.cookie_file)
        web_url = self.get_url(host, media_id)
        if web_url[-1:1]=="#": web_url.replace("#",""); 

        #find session_hash
        try:
            html = self.net.http_GET(web_url).content
            if ">This file doesn't exist, or has been removed.<" in html: raise Exception (host+": This file doesn't exist, or has been removed.")
            elif "This file might have been moved, replaced or deleted.<" in html: raise Exception (host+": This file might have been moved, replaced or deleted.")
            #Shortcut for logged in users
            pattern = '<a href="(/.+?)" class="download_file_link" style="margin:0px 0px;">Download File</a>'
            link = re.search(pattern, html)
            if link:
                common.addon.log('Direct link found: %s' % link.group(1))
                if 'putlocker' in host:
                    return 'http://www.filedrive.com%s' % link.group(1)
                    #return 'http://www.putlocker.com%s' % link.group(1)
                elif 'filedrive' in host:
                    return 'http://www.filedrive.com%s' % link.group(1)
                elif 'firedrive' in host:
                    return 'http://www.firedrive.com%s' % link.group(1)

            if ('firedrive' in host) or ('filedrive' in host) or ('putlocker' in host):
                try:
                	data = {}; r = re.findall(r'type="hidden" name="(.+?)"\s* value="?(.+?)"/>', html); #data['usr_login']=''
                	for name, value in r: data[name] = value
                	#data['imhuman']='Proceed to video'; data['btn_download']='Proceed to video'
                	#xbmc.sleep(2000)
                	html = self.net.http_POST(web_url, data).content
                except urllib2.URLError, e:
                    common.addon.log_error(host+': got http error %d fetching 2nd url %s' % (e.code, web_url))
                    return self.unresolvable(code=3, msg='Exception: %s' % e) #return False
                if "file: '" in html:
                    r = re.search("file\s*:\s*'(.+?)'", html)
                    if r: return urllib.unquote_plus(r.group(1))
                if '" target="_blank" '+"id='top_external_download' title='Download This File'>" in html:
                    r = re.search('<a href="(.+?)" target="_blank" '+"id='top_external_download' title='Download This File'>", html)
                    if r: return urllib.unquote_plus(r.group(1))
                if "id='external_download' title='Download This File'>" in html:
                    r = re.search('<a href="(.+?)" id=\'external_download\' title=\'Download This File\'>', html)
                    if r: return urllib.unquote_plus(r.group(1))
                if "<a id='fd_vid_btm_download_front' title='Copy to my computer' class='video_bottom_buttons' target='_blank' href='" in html:
                    r = re.search("<a id='fd_vid_btm_download_front' title='Copy to my computer' class='video_bottom_buttons' target='_blank' href='(.+?)'>", html)
                    if r: return urllib.unquote_plus(r.group(1))
                #if r:
                #    return urllib.unquote_plus(r.group(1))
                #else:
                #    common.addon.log_error(host+': stream url not found')
                #    return self.unresolvable(code=0, msg='no file located') #return False
                r = re.search("$.post('(.+?)', function(data) {", html)
                if r:
                    return urllib.unquote_plus(r.group(1))
                else:
                    common.addon.log_error(host+': stream url not found')
                    return self.unresolvable(code=0, msg='no file located') #return False
            else:
开发者ID:irfancharania,项目名称:script.module.urlresolver,代码行数:60,代码来源:putlocker.py

示例15: parse_params

def parse_params(param_str):
    param_dic = {}
    # Parameters are on the 3rd arg passed to the script
    param_str = sys.argv[2]
    if len(param_str) > 1:
        param_str = param_str.replace('?', '')

        # Ignore last char if it is a '/'
        if param_str[len(param_str) - 1] == '/':
            param_str = param_str[0:len(param_str) - 2]

        # Processing each parameter splited on  '&'
        for param in param_str.split('&'):
            try:
                # Spliting couple key/value
                key, value = param.split('=')
            except:
                key = param
                value = ''

            key = urllib.unquote_plus(key)
            value = urllib.unquote_plus(value)

            # Filling dictionnary
            param_dic[key] = value

    return param_dic
开发者ID:Konubinix,项目名称:weboob,代码行数:27,代码来源:common_xbmc.py


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