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


Python url.URL类代码示例

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


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

示例1: 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:Adastra-thw,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例2: search

    def search(self, query, start, count=10):
        '''
        Search the web with Bing.

        This method is based from the msn.py file from the massive enumeration toolset,
        coded by pdp and released under GPL v2.
        '''
        url = 'http://www.bing.com/search?'
        query = urllib.urlencode({'q': query,
                                  'first': start + 1,
                                  'FORM': 'PERE'})
        url_instance = URL(url + query)
        response = self._uri_opener.GET(url_instance, headers=self._headers,
                                        cache=True, grep=False)

        # This regex might become outdated, but the good thing is that we have
        # test_bing.py which is going to fail and tell us that it's outdated
        re_match = re.findall('<a href="((http|https)(.*?))" h="ID=SERP,',
                              response.get_body())

        results = set()

        for url, _, _ in re_match:
            try:
                url = URL(url)
            except:
                pass
            else:
                
                if url.get_domain() not in self.BLACKLISTED_DOMAINS:
                    bing_result = BingResult(url)
                    results.add(bing_result)

        return results
开发者ID:Adastra-thw,项目名称:w3af,代码行数:34,代码来源:bing.py

示例3: 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:Adastra-thw,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例4: 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:Adastra-thw,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例5: 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:Adastra-thw,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例6: 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:Adastra-thw,项目名称:w3af,代码行数:7,代码来源:test_url.py

示例7: 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:zhuyue1314,项目名称:w3af,代码行数:28,代码来源:spider_man.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())
 
     
     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)
开发者ID:Adastra-thw,项目名称:w3af,代码行数:31,代码来源:HTTPResponse.py

示例9: 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:Adastra-thw,项目名称:w3af,代码行数:8,代码来源:test_url.py

示例10: 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:HamzaKo,项目名称:w3af,代码行数:8,代码来源:urlParameterHandler.py

示例11: 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:Adastra-thw,项目名称:w3af,代码行数:13,代码来源:test_url.py

示例12: test_set_params

 def test_set_params(self):
     u = URL('http://w3af.com/;id=1')
     u.set_param('file=2')
     
     self.assertEqual(u.get_params_string(), 'file=2')
     
     u = URL('http://w3af.com/xyz.txt;id=1?file=2')
     u.set_param('file=3')
     
     self.assertEqual(u.get_params_string(), 'file=3')
     self.assertEqual(u.get_path_qs(), '/xyz.txt;file=3?file=2')
开发者ID:Adastra-thw,项目名称:w3af,代码行数:11,代码来源:test_url.py

示例13: xssed_dot_com

class xssed_dot_com(InfrastructurePlugin):
    '''
    Search in xssed.com to find xssed pages.

    :author: Nicolas Crocfer ([email protected])
    :author: Raul Siles: set "." in front of the root domain to limit search
    '''
    def __init__(self):
        InfrastructurePlugin.__init__(self)

        #
        #   Could change in time,
        #
        self._xssed_url = URL("http://www.xssed.com")
        self._fixed = "<img src='http://data.xssed.org/images/fixed.gif'>&nbsp;FIXED</th>"

    @runonce(exc_class=w3afRunOnce)
    def discover(self, fuzzable_request):
        '''
        Search in xssed.com and parse the output.

        :param fuzzable_request: A fuzzable_request instance that contains
                                    (among other things) the URL to test.
        '''
        target_domain = fuzzable_request.get_url().get_root_domain()

        try:
            check_url = self._xssed_url.url_join(
                "/search?key=." + target_domain)
            response = self._uri_opener.GET(check_url)
        except w3afException, e:
            msg = 'An exception was raised while running xssed_dot_com'\
                  ' plugin. Exception: "%s".' % e
            om.out.debug(msg)
        else:
开发者ID:Adastra-thw,项目名称:w3af,代码行数:35,代码来源:xssed_dot_com.py

示例14: __init__

    def __init__(self):
        InfrastructurePlugin.__init__(self)

        #
        #   Could change in time,
        #
        self._xssed_url = URL("http://www.xssed.com")
        self._fixed = "<img src='http://data.xssed.org/images/fixed.gif'>&nbsp;FIXED</th>"
开发者ID:Adastra-thw,项目名称:w3af,代码行数:8,代码来源:xssed_dot_com.py

示例15: test_from_parts

 def test_from_parts(self):
     u = URL.from_parts('http', 'w3af.com', '/foo/bar.txt', None, 'a=b',
                        'frag')
     
     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:Adastra-thw,项目名称:w3af,代码行数:8,代码来源:test_url.py


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