使用pyshark(版本为0.4.2.11)时报错:
lxml.etree.xmlsyntaxerror: invalid character in attribute value
解决:将tshark_xml.py中的方法替换为:
def packet_from_xml_packet(xml_pkt, psml_structure=None):
"""
Gets a TShark XML packet object or string, and returns a pyshark Packet objec.t
:param xml_pkt: str or xml object.
:param psml_structure: a list of the fields in each packet summary in the psml data. If given, packets will
be returned as a PacketSummary object.
:return: Packet object.
"""
if not isinstance(xml_pkt, lxml.objectify.ObjectifiedElement):
parser = lxml.objectify.makeparser(huge_tree=True, recover = True)
# 原parser为 parser = lxml.objectify.makeparser(huge_tree=True)
# 此时由于unicode转码出错导致程序报错
xml_pkt = lxml.objectify.fromstring(xml_pkt, parser)
if psml_structure:
return _packet_from_psml_packet(xml_pkt, psml_structure)
return _packet_from_pdml_packet(xml_pkt)
版权声明:本文为weixin_41468462原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。