from scapy.all import * PORT = 80 def handler(pkt): print(pkt) if __name__ == "__main__": sniff(filter=f"tcp port {PORT}", prn=handler)