我正在尝试发送 GET 请求,但在开始请求之前,我想捕获流量。可以使用以下命令捕获流量:
dumpcap -i eth0 -f "udp port 53" -w dns.cap
在后台。当我捕获数据包时,我需要通过发送一些 URL 来发出一些请求。现在,使用下面的代码,我的捕获代码似乎不起作用,我什至在我的文件夹中都看不到 dns.cap 文件。
有什么问题?
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"