from scapy.all import * import re filename = 'final.pcap' count = 0 readthis = PcapReader('final.pcap') #readthis = PacketList([p for p in readthis if p[IP].src == '172.17.0.2']) for p in readthis: if TCP in p and p[IP].src == '10.100.28.4' and p[TCP].payload: deliver = p[TCP].payload deliver_string = str(deliver) if 'HTTP/1.0 200 OK' in deliver_string: print deliver_string[-5:] fname='compmove.txt' with open(fname, 'a') as f: f.write("") f.write(deliver_string[-4:]) f.write("") f.close()