pyshark无法在Windows 7(python)上捕获数据包

Doo*_*hoi 5 python windows networking capture pyshark

我想用pyshark捕获数据包.但我无法在Windows 7上捕获数据包.

这是我的python代码


import pyshark
def NetCap():
    print 'capturing...'
    livecapture = pyshark.LiveCapture(interface="eth0", output_file='./test.pcapng')
    livecapture.sniff(packet_count=10)
    print 'end of capture.'
    print livecapture

if __name__ == "__main__":
    NetCap()
Run Code Online (Sandbox Code Playgroud)

这是结果


capturing...
end of capture.
<LiveCapture (0 packets)>
Run Code Online (Sandbox Code Playgroud)

Livecapture是0包.我不知道是怎么回事.请帮我.

小智 2

windows 没有任何名为 eth0 的接口。他们使用以太网适配器的全称“Ethernet”。请使用 str() 命令并尝试解决它。