本文整理汇总了Python中core.data.parsers.url.URL.url_decode方法的典型用法代码示例。如果您正苦于以下问题:Python URL.url_decode方法的具体用法?Python URL.url_decode怎么用?Python URL.url_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.data.parsers.url.URL
的用法示例。
在下文中一共展示了URL.url_decode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_decode_encode
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_decode [as 别名]
def test_decode_encode(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')
decoded = original.url_decode()
encoded = decoded.url_encode()
self.assertEqual(original.url_encode(), encoded)
示例2: from_httplib_resp
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_decode [as 别名]
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)
示例3: from_httplib_resp
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_decode [as 别名]
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())
charset = getattr(resp, 'encoding', None)
return cls(code, body, hdrs, url_inst, original_url,
msg, charset=charset)