import os import pyshark path = "C:./BGP/BGP\\" files = os.listdir(path) print(files) for file in files: ps = pyshark.FileCapture(path+file,tshark_path="C:\\Wireshark\\Wireshark.exe") for pkt in ps: try: print(pkt.ip.get_field_by_showname('Protocol')) print(pkt.ETH.get_field_by_showname('Source')) print(pkt.ip.get_field_by_showname('Source')) print(pkt.ip.get_field_by_showname('Destination')) print(pkt.ip.get_field_by_showname('Flags')) print(pkt.tcp.get_field_by_showname('Source Port')) print(pkt.bgp.get_field_by_showname('Length')) except Exception as e: print("ETH/IP/BGP不存在")