本文整理汇总了Python中w3af.core.data.parsers.doc.sgml.SGMLParser.get_clear_text_body方法的典型用法代码示例。如果您正苦于以下问题:Python SGMLParser.get_clear_text_body方法的具体用法?Python SGMLParser.get_clear_text_body怎么用?Python SGMLParser.get_clear_text_body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w3af.core.data.parsers.doc.sgml.SGMLParser
的用法示例。
在下文中一共展示了SGMLParser.get_clear_text_body方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_clear_text_body
# 需要导入模块: from w3af.core.data.parsers.doc.sgml import SGMLParser [as 别名]
# 或者: from w3af.core.data.parsers.doc.sgml.SGMLParser import get_clear_text_body [as 别名]
def test_get_clear_text_body(self):
html = 'header <b>ABC</b>-<b>DEF</b>-<b>XYZ</b> footer'
clear_text = 'header ABC-DEF-XYZ footer'
headers = Headers([('Content-Type', 'text/html')])
r = build_http_response(self.url, html, headers)
p = SGMLParser(r)
p.parse()
self.assertEquals(clear_text, p.get_clear_text_body())
示例2: test_get_clear_text_issue_4402
# 需要导入模块: from w3af.core.data.parsers.doc.sgml import SGMLParser [as 别名]
# 或者: from w3af.core.data.parsers.doc.sgml.SGMLParser import get_clear_text_body [as 别名]
def test_get_clear_text_issue_4402(self):
"""
:see: https://github.com/andresriancho/w3af/issues/4402
"""
test_file_path = 'core/data/url/tests/data/encoding_4402.php'
test_file = os.path.join(ROOT_PATH, test_file_path)
body = file(test_file, 'rb').read()
sample_encodings = [encoding for _, (_, encoding) in TEST_RESPONSES.iteritems()]
sample_encodings.extend(['', 'utf-8'])
for encoding in sample_encodings:
encoding_header = 'text/html; charset=%s' % encoding
headers = Headers([('Content-Type', encoding_header)])
r = build_http_response(self.url, body, headers)
p = SGMLParser(r)
p.parse()
p.get_clear_text_body()
示例3: test_get_clear_text_body_encodings
# 需要导入模块: from w3af.core.data.parsers.doc.sgml import SGMLParser [as 别名]
# 或者: from w3af.core.data.parsers.doc.sgml.SGMLParser import get_clear_text_body [as 别名]
def test_get_clear_text_body_encodings(self):
raise SkipTest('Not sure why this one is failing :S')
for lang_desc, (body, encoding) in TEST_RESPONSES.iteritems():
encoding_header = 'text/html; charset=%s' % encoding
headers = Headers([('Content-Type', encoding_header)])
encoded_body = body.encode(encoding)
r = build_http_response(self.url, encoded_body, headers)
p = SGMLParser(r)
p.parse()
ct_body = p.get_clear_text_body()
# These test strings don't really have tags, so they should be eq
self.assertEqual(ct_body, body)