• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urllib.unquote函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: DownloadUpdate

	def DownloadUpdate(self, file):
		self.log('Downloading: %s' % file)
		dirfile = os.path.join(self.UpdateTempDir,file)
		dirname, filename = os.path.split(dirfile)
		if not os.path.isdir(dirname):
			try:
				os.makedirs(dirname)
			except:
				self.log('Error creating directory: '  +dirname)
		url = self.SVNPathAddress+urllib.quote(file)
		try:
			if re.findall(".xbt",url):
				self.totalsize = int(re.findall("File length: ([0-9]*)",urllib2.urlopen(url+"?view=log").read())[0])
				urllib.urlretrieve( url.decode("utf-8"), dirfile.decode("utf-8"))
			else: urllib.urlretrieve( url.decode("utf-8"), dirfile.decode("utf-8") )
			self.DownloadedFiles.append(urllib.unquote(url))
			return 1
		except:
			try:
				time.sleep(2)
				if re.findall(".xbt",url):
					self.totalsize = int(re.findall("File length: ([0-9]*)",urllib2.urlopen(url+"?view=log").read())[0])
					urllib.urlretrieve(url.decode("utf-8"), dirfile.decode("utf-8"))
				else: urllib.urlretrieve(url.decode("utf-8"), dirfile.decode("utf-8") )
				urllib.urlretrieve(url.decode("utf-8"), dirfile.decode("utf-8"))
				self.DownloadedFiles.append(urllib.unquote(url))
				return 1
			except:
				self.log("Download failed: %s" % url)
				self.DownloadFailedFiles.append(urllib.unquote(url))
				return 0
开发者ID:reversTeam,项目名称:sualfreds-repo,代码行数:31,代码来源:updater_class.py


示例2: render

	def render(self, request):
		if 'dir' in request.args:
			dir = unquote(request.args['dir'][0])
		elif 'root' in request.args:
			dir = unquote(request.args['root'][0])
		else:
			dir = ''

		if 'file' in request.args:
			filename = unquote(request.args["file"][0])
			path = dir + filename

			#dirty backwards compatibility hack
			if not os_path.exists(path):
				path = resolveFilename(SCOPE_HDD, filename)

			print "[WebChilds.FileStreamer] path is %s" %path

			if os_path.exists(path):
				basename = filename.decode('utf-8', 'ignore').encode('ascii', 'ignore')

				if '/' in basename:
					basename = basename.split('/')[-1]

				request.setHeader("content-disposition", "attachment;filename=\"%s\"" % (basename))
				file = static.File(path, defaultType = "application/octet-stream")
				return file.render_GET(request)

			else:
				return resource.NoResource(message="file '%s' was not found" %(dir + filename)).render(request)
		else:
			return resource.NoResource(message="no file given with file={filename}").render(request)

		return server.NOT_DONE_YET
开发者ID:Blacksens,项目名称:enigma2-plugins,代码行数:34,代码来源:FileStreamer.py


示例3: get_objs_to_delete

    def get_objs_to_delete(self, req):
        """
        Will populate objs_to_delete with data from request input.
        :params req: a Swob request
        :returns: a list of the contents of req.body when separated by newline.
        :raises: HTTPException on failures
        """
        line = ''
        data_remaining = True
        objs_to_delete = []
        if req.content_length is None and \
                req.headers.get('transfer-encoding', '').lower() != 'chunked':
            raise HTTPLengthRequired(request=req)

        while data_remaining:
            if '\n' in line:
                obj_to_delete, line = line.split('\n', 1)
                objs_to_delete.append(unquote(obj_to_delete))
            else:
                data = req.environ['wsgi.input'].read(MAX_PATH_LENGTH)
                if data:
                    line += data
                else:
                    data_remaining = False
                    if line.strip():
                        objs_to_delete.append(unquote(line))
            if len(objs_to_delete) > self.max_deletes_per_request:
                raise HTTPRequestEntityTooLarge(
                    'Maximum Bulk Deletes: %d per request' %
                    self.max_deletes_per_request)
            if len(line) > MAX_PATH_LENGTH * 2:
                raise HTTPBadRequest('Invalid File Name')
        return objs_to_delete
开发者ID:sun3shines,项目名称:swift-1.7.4,代码行数:33,代码来源:bulk.py


示例4: crack_action

def crack_action(params):
    if params[1] == 'search':
        load_search(params[2])
    elif params[1] == 'choose_file':
        callback = params[2]
        file_path = utils.open_file_chooser_dialog()
        webv.execute_script('%s("%s")' % (callback, file_path))
    elif params[1] == 'save_avatar':
        img_uri = urllib.unquote(params[2])
        avatar_file = urllib.unquote(params[3])
        avatar_path = os.path.join(config.AVATAR_CACHE_DIR, avatar_file)
        if not (os.path.exists(avatar_path) and avatar_file.endswith(img_uri[img_uri.rfind('/')+1:])):
            print 'Download:', img_uri , 'To' , avatar_path
            th = threading.Thread(
                target = save_file_proc, 
                args=(img_uri, avatar_path))
            th.start()
    elif params[1] == 'log':
        print '\033[1;31;40m[%s]\033[0m %s' % (urllib.unquote(params[2]) ,urllib.unquote(params[3]))
    elif params[1] == 'paste_clipboard_text':
        webv.paste_clipboard();
    elif params[1] == 'set_clipboard_text':
        clipboard = gtk.clipboard_get()
        text = list(params)
        del text[0:2]
        clipboard.set_text('/'.join(text))
开发者ID:fma16,项目名称:Hotot,代码行数:26,代码来源:agent.py


示例5: get

 def get(self):
   user = users.get_current_user()
   user_oauth = oauth.get_current_user()
   self.response.write(user_oauth)
   if user:
     client_id = "676481030478-0fi923mg6rbe1tqbvffr8n5ih56p63gg.apps.googleusercontent.com"
     client_secret = "AXSaN3iaVse0lL_GCRp7ioPQ"
     scope = urllib.unquote(self.request.get("scope")).decode("utf-8")
     redirect_uri = urllib.unquote(self.request.get("redirect_uri")).decode("utf-8")
     flow = Oauth2WebServerFlow(client_id, client_secret, scope,redirect_uri=redirect_uri)
     code = self.request.get("code")
     redirect_uri = "http://localhost:19080/oauth"
     grant_type = "authorization_code"
     form_fields = {
       "code" : code,
       "client_id" : client_id,
       "client_secret" : client_secret,
       "redirect_uri" : redirect_uri,
       "grant_type" : grant_type,
     }
     form_data = urllib.urlencode(form_fields)
     url_validator = "https://www.googleapis.com/oauth2/v1/tokeninfo"
     #url_validator = "https://www.googleapis.com/o/oauth2/token?access_token=" + code
     result = urlfetch.fetch(
       headers = {'Content-Type': 'application/x-www-form-urlencoded'},
       url = url_validator,
       payload = form_data,
       method = urlfetch.POST,
     )
     self.response.write(result.content)
开发者ID:fritzdenim,项目名称:gcdc2013-mapjobs,代码行数:30,代码来源:main2.py


示例6: PLAY

def PLAY(params):
    # -- get filter parameters
    par = Get_Parameters(params)

    # -- if requested continious play
    if Addon.getSetting("continue_play") == "true":
        # create play list
        pl = xbmc.PlayList(1)
        pl.clear()
        # -- get play list
        playlist = Get_PlayList(par.playlist)
        is_found = False
        for rec in playlist:
            name = rec["comment"].encode("utf-8")
            s_url = rec["file"]
            # -- add item to play list
            if s_url == par.url:
                is_found = True

            if is_found:
                i = xbmcgui.ListItem(name, path=urllib.unquote(s_url), thumbnailImage=par.img)
                i.setProperty("IsPlayable", "true")
                pl.add(s_url, i)

        xbmc.Player().play(pl)
    # -- play only selected item
    else:
        i = xbmcgui.ListItem(par.name, path=urllib.unquote(par.url), thumbnailImage=par.img)
        i.setProperty("IsPlayable", "true")
        xbmcplugin.setResolvedUrl(h, True, i)
开发者ID:Stevie-Bs,项目名称:ru,代码行数:30,代码来源:default.py


示例7: filter_headers

def filter_headers(headers, prefix):
    meta = {}
    for k, v in headers.iteritems():
        if not k.startswith(prefix):
            continue
        meta[unquote(k[len(prefix):])] = unquote(v)
    return meta
开发者ID:antonis-m,项目名称:synnefo,代码行数:7,代码来源:__init__.py


示例8: fromString

    def fromString(self, tagstring):
        """
        go from string to Tag class filled in
        
        @param tagstring: example "important customer:kristof"
        @type tagstring: string        
        """

        tagstring=j.tools.text.hrd2machinetext(tagstring)

        if not tagstring:
            return


        tags = tagstring.split()
        for tag in tags:                
            if tag.find(':') > 0:
                key = tag.split(':',1)[0]
                value = tag.split(':',1)[1]
                key=unquote(key)
                value = unquote(j.tools.text.machinetext2hrd(value))
                self.tags[key.lower()] = value
                self.tags[key] = value
            else:
                self.labels.add(unquote(j.tools.text.machinetext2hrd(tag)))

        self.tagstring=tagstring
开发者ID:jumpscale7,项目名称:jumpscale6_core,代码行数:27,代码来源:Tags.py


示例9: _lookup

 def _lookup(self, next, *rest):
     next = h.really_unicode(unquote(next))
     if not rest:
         # Might be a file rather than a dir
         filename = h.really_unicode(
             unquote(
                 request.environ['PATH_INFO'].rsplit('/')[-1]))
         if filename:
             try:
                 obj = self._tree[filename]
             except KeyError:
                 raise exc.HTTPNotFound()
             if isinstance(obj, M.repository.Blob):
                 return self.FileBrowserClass(
                     self._commit,
                     self._tree,
                     filename), rest
     elif rest == ('index', ):
         rest = (request.environ['PATH_INFO'].rsplit('/')[-1],)
     try:
         tree = self._tree[next]
     except KeyError:
         raise exc.HTTPNotFound
     return self.__class__(
         self._commit,
         tree,
         self._path + '/' + next,
         self), rest
开发者ID:apache,项目名称:allura,代码行数:28,代码来源:repository.py


示例10: _check_oob_iq

    def _check_oob_iq(self, iq_event):
        assert iq_event.iq_type == 'set'
        assert iq_event.connection == self.incoming
        self.iq = iq_event.stanza
        assert self.iq['to'] == self.contact_name
        query = self.iq.firstChildElement()
        assert query.uri == 'jabber:iq:oob'
        url_node = xpath.queryForNodes("/iq/query/url", self.iq)[0]
        assert url_node['type'] == 'file'
        assert url_node['size'] == str(self.file.size)
        assert url_node['mimeType'] == self.file.content_type
        self.url = url_node.children[0]
        _, self.host, self.filename, _, _, _ = urlparse.urlparse(self.url)
        urllib.unquote(self.filename) == self.file.name
        desc_node = xpath.queryForNodes("/iq/query/desc", self.iq)[0]
        self.desc = desc_node.children[0]
        assert self.desc == self.file.description

        # Metadata forms
        forms = extract_data_forms(xpath.queryForNodes('/iq/query/x', self.iq))

        if self.service_name:
            assertEquals({'ServiceName': [self.service_name]},
                         forms[ns.TP_FT_METADATA_SERVICE])
        else:
            assert ns.TP_FT_METADATA_SERVICE not in forms

        if self.metadata:
            assertEquals(self.metadata, forms[ns.TP_FT_METADATA])
        else:
            assert ns.TP_FT_METADATA not in forms
开发者ID:freedesktop-unofficial-mirror,项目名称:telepathy__telepathy-salut,代码行数:31,代码来源:file_transfer_helper.py


示例11: parse_args

def parse_args(args=""):
    "Parse input args"

    out_args = {
       "verb"             : "",
       "metadataPrefix"   : "",
       "from"             : "",
       "until"            : "",
       "set"              : "",
       "identifier"       : "",
       "resumptionToken"  : ""
    }

    if args == "" or args is None:
        pass
    else:

        list_of_arguments = args.split('&')

        for item in list_of_arguments:
            keyvalue = item.split('=')
            if len(keyvalue) == 2:
                if (out_args.has_key(keyvalue[0])):
                    if(out_args[keyvalue[0]] != ""):
                        out_args[keyvalue[0]] = "Error"
                    else:
                        out_args[keyvalue[0]] = urllib.unquote(keyvalue[1])
                else:
                    out_args[keyvalue[0]] = urllib.unquote(keyvalue[1])
            else:
                out_args['verb'] = ""

    return out_args
开发者ID:NikolaYolov,项目名称:invenio_backup,代码行数:33,代码来源:oai_repository_server.py


示例12: basicauth_decode

def basicauth_decode(encoded_str):
    """Decode an encrypted HTTP basic authentication string. Returns a tuple of
    the form (username, password), and raises a DecodeError exception if
    nothing could be decoded.
    """
    split = encoded_str.strip().split(' ')

    # If split is only one element, try to decode the username and password
    # directly.
    if len(split) == 1:
        try:
            username, password = b64decode(split[0]).split(':', 1)
        except:
            raise DecodeError

    # If there are only two elements, check the first and ensure it says
    # 'basic' so that we know we're about to decode the right thing. If not,
    # bail out.
    elif len(split) == 2:
        if split[0].strip().lower() == 'basic':
            try:
                username, password = b64decode(split[1]).split(':', 1)
            except:
                raise DecodeError
        else:
            raise DecodeError

    # If there are more than 2 elements, something crazy must be happening.
    # Bail.
    else:
        raise DecodeError

    return unquote(username), unquote(password)
开发者ID:mayblue9,项目名称:react-django-admin,代码行数:33,代码来源:utils_basicauth.py


示例13: _form_uri_parts

 def _form_uri_parts(self, netloc, path):
     if netloc != '':
         # > Python 2.6.1
         if '@' in netloc:
             creds, netloc = netloc.split('@')
         else:
             creds = None
     else:
         # Python 2.6.1 compat
         # see lp659445 and Python issue7904
         if '@' in path:
             creds, path = path.split('@')
         else:
             creds = None
         netloc = path[0:path.find('/')].strip('/')
         path = path[path.find('/'):].strip('/')
     if creds:
         cred_parts = creds.split(':')
         if len(cred_parts) < 2:
             reason = _("Badly formed credentials in Swift URI.")
             LOG.info(reason)
             raise exceptions.BadStoreUri(message=reason)
         key = cred_parts.pop()
         user = ':'.join(cred_parts)
         creds = urllib.unquote(creds)
         try:
             self.user, self.key = creds.rsplit(':', 1)
         except exceptions.BadStoreConfiguration:
             self.user = urllib.unquote(user)
             self.key = urllib.unquote(key)
     else:
         self.user = None
         self.key = None
     return netloc, path
开发者ID:saeki-masaki,项目名称:glance_store,代码行数:34,代码来源:store.py


示例14: createMediaRequest

    def createMediaRequest(self,stream):
        if stream == None:
            self.error_str = "No event-id present to create media request."
            raise

        try:
            sessionKey = urllib.unquote(self.session.cookies['ftmu'])
        except:
            sessionKey = None
      
        # Query values
        query_values = {
            'contentId': self.content_id,
            'sessionKey': sessionKey,
            'fingerprint': urllib.unquote(self.session.cookies['fprt']),
            'identityPointId': self.session.cookies['ipid'],
            'playbackScenario': self.scenario,
            'subject': self.subject
        }
        # Build query
        url = self.base_url + urllib.urlencode(query_values)
        
        # And make the request
        req = urllib2.Request(url)
        response = urllib2.urlopen(req)
        reply = xml.dom.minidom.parse(response)
        return reply
开发者ID:HyShai,项目名称:mlbviewer,代码行数:27,代码来源:milbMediaStream.py


示例15: download

def download(url, path_to_directory):
    print "starting download with", url, path_to_directory
    if "geoserver/wfs" in url:
        filename = unquote(search("(?<=typename=)[^&]*",url).group(0)).replace(":","_")
        extension = "zip"
        filename_with_extension = filename + "." + extension
    else:
        filename_with_extension = unquote(url.split("?")[0].split("/")[-1])
        print "filename_with_extension = ", filename_with_extension
        filename = filename_with_extension.split(".")[0]
        
    print "filename is", filename
    print "filename_with_extension = ", filename_with_extension
    path_to_directory_of_downloadable = path_to_directory + "/" + filename
    if not isdir(path_to_directory_of_downloadable):
        mkdir(path_to_directory_of_downloadable)
    path_to_downloaded_file = path_to_directory_of_downloadable + "/" + filename_with_extension
    if not isfile(path_to_downloaded_file):
        urlretrieve(url, path_to_downloaded_file)
        print "saved file to ", path_to_downloaded_file
    if path_to_downloaded_file.endswith("zip"):         
        if is_zipfile(path_to_downloaded_file):    
            with zipfile.ZipFile(path_to_downloaded_file, "r") as z:
                z.extractall(path_to_directory_of_downloadable)
                print "unzipped", path_to_downloaded_file
        else:
            remove(path_to_downloaded_file)
            print "removed file because it wasn't a zip file eventhough had zip extension"
开发者ID:DanielJDufour,项目名称:firstdraft,代码行数:28,代码来源:load.py


示例16: proxy_open

    def proxy_open(self, req, proxy, type):
        orig_type = req.get_type()
        proxy_type, user, password, hostport = _parse_proxy(proxy)

        if proxy_type is None:
            proxy_type = orig_type

        if req.get_host() and self._proxy_bypass(req.get_host()):
            return None

        if user and password:
            user_pass = '%s:%s' % (unquote(user), unquote(password))
            creds = base64.b64encode(user_pass).strip()
            req.add_header('Proxy-authorization', 'Basic ' + creds)
        hostport = unquote(hostport)
        req.set_proxy(hostport, proxy_type)
        if orig_type == proxy_type or orig_type == 'https':
            # let other handlers take care of it
            return None
        else:
            # need to start over, because the other handlers don't
            # grok the proxy's URL type
            # e.g. if we have a constructor arg proxies like so:
            # {'http': 'ftp://proxy.example.com'}, we may end up turning
            # a request for http://acme.example.com/a into one for
            # ftp://proxy.example.com/a
            return self.parent.open(req)
开发者ID:ufal,项目名称:lindat-aai-shibbie,代码行数:27,代码来源:_urllib2_fork.py


示例17: get_video

    def get_video(self, video=None):
        if video is None:
            video = DailymotionVideo(self.group_dict['id'])

        div = self.parser.select(self.document.getroot(), 'div#content', 1)

        video.title = unicode(self.parser.select(div, 'span.title', 1).text).strip()
        video.author = unicode(self.parser.select(div, 'a.name, span.name', 1).text).strip()
        try:
            video.description = html2text(self.parser.tostring(self.parser.select(div, 'div#video_description', 1))).strip() or unicode()
        except BrokenPageError:
            video.description = u''
        for script in self.parser.select(self.document.getroot(), 'div.dmco_html'):
            # TODO support videos from anyclip, cf http://www.dailymotion.com/video/xkyjiv for example
            if 'id' in script.attrib and script.attrib['id'].startswith('container_player_') and \
               script.find('script') is not None:
                text = script.find('script').text
                mobj = re.search(r'(?i)addVariable\(\"video\"\s*,\s*\"([^\"]*)\"\)', text)
                if mobj is None:
                    mobj = re.search('"sdURL":.*?"(.*?)"', urllib.unquote(text))
                    mediaURL = mobj.group(1).replace("\\", "")
                else:
                    mediaURL = urllib.unquote(mobj.group(1))
                video.url = mediaURL

        video.set_empty_fields(NotAvailable)

        return video
开发者ID:eirmag,项目名称:weboob,代码行数:28,代码来源:pages.py


示例18: create_form

    def create_form(self, params, tg_errors=None):

        params.id = params.o2m_id
        params.model = params.o2m_model
        params.view_mode = ['form', 'tree']
        params.view_type = 'form'
        
        #XXX: dirty hack to fix bug #401700
        if not params.get('_terp_view_ids'):
            params['_terp_view_ids'] = []

        # to get proper view, first generate form using the view_params
        vp = params.view_params
                
        form = tw.form_view.ViewForm(vp, name="view_form", action="/openo2m/save")
        cherrypy.request.terp_validators = {}
        wid = form.screen.widget.get_widgets_by_name(params.o2m)[0]

        # save view_params for later phazes
        vp = vp.make_plain('_terp_view_params/')
        hiddens = map(lambda x: tw.form.Hidden(name=x, default=ustr(vp[x])), vp)

        params.prefix = params.o2m
        params.views = wid.view
        
        # IE hack, get context from cookies (see o2m.js)
        o2m_context = {}
        parent_context = {}
        try:
            o2m_context = urllib.unquote(cherrypy.request.cookie['_terp_o2m_context'].value)
            parent_context = urllib.unquote(cherrypy.request.cookie['_terp_parent_context'].value)
            cherrypy.request.cookie['_terp_o2m_context']['expires'] = 0
            cherrypy.response.cookie['_terp_o2m_context']['expires'] = 0
            cherrypy.request.cookie['_terp_parent_context']['expires'] = 0
            cherrypy.response.cookie['_terp_parent_context']['expires'] = 0
        except:
            pass
        
        params.o2m_context = params.o2m_context or o2m_context
        params.parent_context = params.parent_context or parent_context
        
        ctx = params.context or {}
        ctx.update(params.parent_context or {})
        ctx.update(params.o2m_context or {})
        p, ctx = TinyDict.split(ctx)

        params.context = ctx or {}
        params.hidden_fields = [tw.form.Hidden(name='_terp_parent_model', default=params.parent_model),
                                tw.form.Hidden(name='_terp_parent_id', default=params.parent_id),
                                tw.form.Hidden(name='_terp_parent_context', default=ustr(params.parent_context)),
                                tw.form.Hidden(name='_terp_o2m', default=params.o2m),
                                tw.form.Hidden(name='_terp_o2m_id', default=params.id or None),
                                tw.form.Hidden(name='_terp_o2m_model', default=params.o2m_model),
                                tw.form.Hidden(name='_terp_o2m_context', default=ustr(params.o2m_context or {})),
                                tw.form.Hidden(name=params.prefix + '/__id', default=params.id or None)] + hiddens

        form = tw.form_view.ViewForm(params, name="view_form", action="/openo2m/save")
        form.screen.string = wid.screen.string
        
        return form
开发者ID:KDVN,项目名称:KDINDO.OpenERP,代码行数:60,代码来源:openo2m.py


示例19: findVideoFrameLink

def findVideoFrameLink(page, data):

    minheight = 300
    minwidth = 300

    frames = findFrames(data)
    if not frames:
        return None

    iframes = regexUtils.findall(
        data,
        "(frame(?![^>]*cbox\.ws)(?![^>]*Publi)(?![^>]*chat\d*\.\w+)(?![^>]*ad122m)(?![^>]*adshell)(?![^>]*capacanal)(?![^>]*blacktvlive\.com)[^>]*\sheight\s*=\s*[\"']*([\%\d]+)(?:px)?[\"']*[^>]*>)",
    )

    if iframes:
        for iframe in iframes:
            if iframe[1] == "100%":
                height = minheight + 1
            else:
                height = int(iframe[1])
            if height > minheight:
                m = regexUtils.findall(iframe[0], "[\"' ]width\s*=\s*[\"']*(\d+[%]*)(?:px)?[\"']*")
                if m:
                    if m[0] == "100%":
                        width = minwidth + 1
                    else:
                        width = int(m[0])
                    if width > minwidth:
                        m = regexUtils.findall(iframe[0], "['\"\s]src=[\"']*\s*([^>\"' ]+)\s*[>\"']*")
                        if m:
                            return urlparse.urljoin(urllib.unquote(page), m[0]).strip()

    # Alternative 1
    iframes = regexUtils.findall(
        data, '(frame(?![^>]*cbox\.ws)(?![^>]*capacanal)(?![^>]*blacktvlive\.com)[^>]*["; ]height:\s*(\d+)[^>]*>)'
    )
    if iframes:
        for iframe in iframes:
            height = int(iframe[1])
            if height > minheight:
                m = regexUtils.findall(iframe[0], '["; ]width:\s*(\d+)')
                if m:
                    width = int(m[0])
                    if width > minwidth:
                        m = regexUtils.findall(iframe[0], '["; ]src=["\']*\s*([^>"\' ]+)\s*[>"\']*')
                        if m:
                            return urlparse.urljoin(urllib.unquote(page), m[0]).strip()

    # Alternative 2 (Frameset)
    m = regexUtils.findall(data, '<FRAMESET[^>]+100%[^>]+>\s*<FRAME[^>]+src="([^"]+)"')
    if m:
        return urlparse.urljoin(urllib.unquote(page), m[0]).strip()

    m = regexUtils.findall(
        data, '<a href="([^"]+)" target="_blank"><img src="[^"]+" height="450" width="600" longdesc="[^"]+"/></a>'
    )
    if m:
        return urlparse.urljoin(urllib.unquote(page), m[0]).strip()

    return None
开发者ID:BirdsofaFeather,项目名称:husham.com,代码行数:60,代码来源:scrapingUtils.py


示例20: canonicalize_rootpath

def canonicalize_rootpath(rootpath):
  # Try to canonicalize the rootpath using Subversion semantics.
  rootpath = _canonicalize_path(rootpath)
  
  # ViewVC's support for local repositories is more complete and more
  # performant than its support for remote ones, so if we're on a
  # Unix-y system and we have a file:/// URL, convert it to a local
  # path instead.
  if os.name == 'posix':
    rootpath_lower = rootpath.lower()
    if rootpath_lower in ['file://localhost',
                          'file://localhost/',
                          'file://',
                          'file:///'
                          ]:
      return '/'
    if rootpath_lower.startswith('file://localhost/'):
      rootpath = os.path.normpath(urllib.unquote(rootpath[16:]))
    elif rootpath_lower.startswith('file:///'):
      rootpath = os.path.normpath(urllib.unquote(rootpath[7:]))

  # Ensure that we have an absolute path (or URL), and return.
  if not re.search(_re_url, rootpath):
    assert os.path.isabs(rootpath)
  return rootpath
开发者ID:manuvaldi,项目名称:viewvc-wiki,代码行数:25,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urllib.unquote_plus函数代码示例发布时间:2022-05-27
下一篇:
Python urllib.splituser函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap