pcapng.scanner

class pcapng.scanner.FileScanner(stream)[source]

pcap-ng file scanner.

This object can be iterated to get blocks out of a pcap-ng stream (a file or file-like object providing a .read() method).

Example usage:

from pcapng import FileScanner

with open('/tmp/mycapture.pcap') as fp:
    scanner = FileScanner(fp)
    for block in scanner:
        pass  # do something with the block...
Parameters:stream – a file-like object from which to read the data. If you need to parse data from some string you have entirely in-memory, just wrap it in a io.BytesIO object.