我使用Python的libtorrent搜索以检索torrent的对等方IP。我尝试使用代码:
import libtorrent as lt
import time
ses = lt.session()
ses.listen_on(6881, 6891)
info = lt.torrent_info('test.torrent')
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()
while (not h.is_seed()):
s = h.status()
p = h.get_peer_info()
for i in p:
print i.ip
print "\n\n"
sys.stdout.flush()
time.sleep(1)
print h.name(), 'complete'
Run Code Online (Sandbox Code Playgroud)
它或多或少起作用,但是我有两个问题:
你能帮助我吗?
非常感谢。