I am trying to send GET requests but before starting the requests, I'd like to capture the traffic. Capturing traffic can be done with the command:
dumpcap -i eth0 -f "udp port 53" -w dns.cap
in the background. While I capture packets, I need to make some request by sending some URLs. For now, with the code below, it seems my capturing code does not work, I can not even see a dns.cap file in my folder.
What's the problem?
import requests
import os
import subprocess
import urllib
print "start capturing packets...\n"
#os.system("dumpcap -i eth0 -f \"udp port 53\" -w dns.cap"
os.spawnl(os.P_NOWAIT,'dumpcap -i eth0 -f \"udp port 53\" -w dns.cap')
print urllib.urlopen('http://www.google.com').read()
#resp = requests.get('http://httpbin.org')
#resp=requests.get('http://httpbin.org')
print "ok"