Search code examples
python-3.xscapy

how do I parse a varible do isolate a singular piece of data in python?


when I output the variable p using p[0] it outputs

<Ether  dst=4a:aa:ac:d6:57:00 src=99:c3:88:b0:56:2e type=IPv4 |<IP  version=4 ihl=5 tos=0x0 len=32 id=1 flags= frag=0 ttl=64 proto=icmp chksum=0x83e5 src=192.168.50.73 dst=1.2.3.4 |<ICMP  type=echo-request code=0 chksum=0x1026 id=0x0 seq=0x0 unused='' |<Raw  load='test' |>>>>

and I want to isolate the test in <Raw load='test' but that wont always be the same string.


Solution

  • You can access the data by using:

    p[0][Raw].load
    

    The [Raw] accesses the Raw layer, and the .load accesses the load field (from the Raw layer).