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


Python url.URL类代码示例

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


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

示例1: test_url_join_case01

 def test_url_join_case01(self):
     u = URL('http://w3af.com/foo.bar')
     self.assertEqual(u.url_join('abc.html').url_string,
                      u'http://w3af.com/abc.html')
     
     self.assertEqual(u.url_join('/abc.html').url_string,
                      u'http://w3af.com/abc.html')
开发者ID:3rdDegree,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例2: test_url_join_case03

 def test_url_join_case03(self):
     u = URL('http://w3af.com/def/jkl/')
     self.assertEqual(u.url_join('/def/abc.html').url_string,
                      u'http://w3af.com/def/abc.html')
     
     self.assertEqual(u.url_join('def/abc.html').url_string,
                      u'http://w3af.com/def/jkl/def/abc.html')
开发者ID:3rdDegree,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例3: test_encode_decode

 def test_encode_decode(self):
     """Encode and Decode should be able to run one on the result of the
     other and return the original"""
     original = URL(u"https://w3af.com:443/file.asp?id=1%202")
     encoded = original.url_encode()
     decoded = URL(encoded).url_decode()
     self.assertEqual(original, decoded)
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:7,代码来源:test_url.py

示例4: test_can_be_pickled

    def test_can_be_pickled(self):
        # Pickle a URL object that contains a cache
        u = URL('http://www.w3af.com/')
        domain_path = u.get_domain_path()

        cPickle.dumps(u)
        cPickle.dumps(domain_path)
开发者ID:3rdDegree,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例5: test_simplest_url

    def test_simplest_url(self):
        u = URL("http://w3af.com/foo/bar.txt")

        self.assertEqual(u.path, "/foo/bar.txt")
        self.assertEqual(u.scheme, "http")
        self.assertEqual(u.get_file_name(), "bar.txt")
        self.assertEqual(u.get_extension(), "txt")
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:7,代码来源:test_url.py

示例6: do_ALL

    def do_ALL(self):
        global global_first_request
        if global_first_request:
            global_first_request = False
            om.out.information(
                'The user is navigating through the spider_man proxy.')

        # Convert to url_object
        path = URL(self.path)

        if path == TERMINATE_URL:
            om.out.information('The user terminated the spider_man session.')
            self._send_end()
            self._spider_man.stop_proxy()
            return

        om.out.debug("[spider_man] Handling request: %s %s" %
                    (self.command, path))
        #   Send this information to the plugin so it can send it to the core
        freq = self._create_fuzzable_request()
        self._spider_man.append_fuzzable_request(freq)

        grep = True
        if path.get_domain() != self.server.w3afLayer.target_domain:
            grep = False

        try:
            response = self._send_to_server(grep=grep)
        except Exception, e:
            self._send_error(e)
开发者ID:carriercomm,项目名称:w3af_analyse,代码行数:30,代码来源:spider_man.py

示例7: test_default_proto

 def test_default_proto(self):
     """
     http is the default protocol, we can provide URLs with no proto
     """
     u = URL("w3af.com")
     self.assertEqual(u.get_domain(), "w3af.com")
     self.assertEqual(u.get_protocol(), "http")
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:7,代码来源:test_url.py

示例8: from_httplib_resp

    def from_httplib_resp(cls, httplibresp, original_url=None):
        """
        Factory function. Build a HTTPResponse object from a
        httplib.HTTPResponse instance
    
        :param httplibresp: httplib.HTTPResponse instance
        :param original_url: Optional 'url_object' instance.
    
        :return: A HTTPResponse instance
        """
        resp = httplibresp
        code, msg, hdrs, body = (resp.code, resp.msg, resp.info(), resp.read())
        hdrs = Headers(hdrs.items())

        if original_url:
            url_inst = URL(resp.geturl(), original_url.encoding)
            url_inst = url_inst.url_decode()
        else:
            url_inst = original_url = URL(resp.geturl())

        httplib_time = DEFAULT_WAIT_TIME
        if hasattr(httplibresp, 'get_wait_time'):
            # This is defined in the keep alive http response object
            httplib_time = httplibresp.get_wait_time()

        if isinstance(resp, urllib2.HTTPError):
            # This is possible because in errors.py I do:
            # err = urllib2.HTTPError(req.get_full_url(), code, msg, hdrs, resp)
            charset = getattr(resp.fp, 'encoding', None)
        else:
            # The encoding attribute is only set on CachedResponse instances
            charset = getattr(resp, 'encoding', None)
        
        return cls(code, body, hdrs, url_inst, original_url,
                   msg, charset=charset, time=httplib_time)
开发者ID:BioSoundSystems,项目名称:w3af,代码行数:35,代码来源:HTTPResponse.py

示例9: test_simplest_url

 def test_simplest_url(self):
     u = URL('http://w3af.com/foo/bar.txt')
     
     self.assertEqual(u.path, '/foo/bar.txt')
     self.assertEqual(u.scheme, 'http')
     self.assertEqual(u.get_file_name(), 'bar.txt')
     self.assertEqual(u.get_extension(), 'txt')
开发者ID:3rdDegree,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例10: test_from_url_keep_form

    def test_from_url_keep_form(self):
        o = URL('http://w3af.com/foo/bar.txt')
        o.querystring = URLEncodedForm()

        u = URL.from_URL(o)
        self.assertIsInstance(u.querystring, URLEncodedForm)
        self.assertIsNot(u.querystring, o.querystring)
        self.assertEqual(u.querystring, o.querystring)
开发者ID:ElAleyo,项目名称:w3af,代码行数:8,代码来源:test_url.py

示例11: test_remove_fragment

 def test_remove_fragment(self):
     u = URL('http://w3af.com/foo/bar.txt?id=3#foobar')
     self.assertEqual(u.remove_fragment().url_string,
                      u'http://w3af.com/foo/bar.txt?id=3')
     
     u = URL('http://w3af.com/foo/bar.txt#foobar')
     self.assertEqual(u.remove_fragment().url_string,
                      u'http://w3af.com/foo/bar.txt')
开发者ID:3rdDegree,项目名称:w3af,代码行数:8,代码来源:test_url.py

示例12: http_request

    def http_request(self, req):
        url_instance = URL(req.get_full_url())
        url_instance.set_param(self._url_parameter)

        new_request = HTTPRequest(url_instance, headers=req.headers,
                                  origin_req_host=req.get_origin_req_host(),
                                  unverifiable=req.is_unverifiable())
        return new_request
开发者ID:3rdDegree,项目名称:w3af,代码行数:8,代码来源:url_parameter.py

示例13: test_memoized

    def test_memoized(self):
        u = URL('http://www.w3af.com/')
        self.assertEqual(u._cache, dict())

        url = u.uri2url()
        self.assertNotEqual(u._cache, dict())
        self.assertIn(url, u._cache.values())

        second_url = u.uri2url()
        self.assertIs(url, second_url)

        self.assertIsInstance(url, URL)
        self.assertIsInstance(second_url, URL)
开发者ID:ElAleyo,项目名称:w3af,代码行数:13,代码来源:test_url.py

示例14: test_from_url

 def test_from_url(self):
     o = URL('http://w3af.com/foo/bar.txt')
     u = URL.from_URL(o)
     
     self.assertEqual(u.path, '/foo/bar.txt')
     self.assertEqual(u.scheme, 'http')
     self.assertEqual(u.get_file_name(), 'bar.txt')
     self.assertEqual(u.get_extension(), 'txt')
     
     o = URL('w3af.com')
     u = URL.from_URL(o)
     self.assertEqual(u.get_domain(), 'w3af.com')
     self.assertEqual(u.get_protocol(), 'http')
开发者ID:3rdDegree,项目名称:w3af,代码行数:13,代码来源:test_url.py

示例15: test_from_url

    def test_from_url(self):
        o = URL("http://w3af.com/foo/bar.txt")
        u = URL.from_URL(o)

        self.assertEqual(u.path, "/foo/bar.txt")
        self.assertEqual(u.scheme, "http")
        self.assertEqual(u.get_file_name(), "bar.txt")
        self.assertEqual(u.get_extension(), "txt")

        o = URL("w3af.com")
        u = URL.from_URL(o)
        self.assertEqual(u.get_domain(), "w3af.com")
        self.assertEqual(u.get_protocol(), "http")
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:13,代码来源:test_url.py


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