小编Com*_*ion的帖子

使用python-libtorrent检索对等列表而不下载torrent

我使用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)

它或多或少起作用,但是我有两个问题:

  1. 种子下载。
  2. 在收到一个对等列表之前,循环执行了数十次。

你能帮助我吗?

非常感谢。

python libtorrent

3
推荐指数
1
解决办法
3447
查看次数

标签 统计

libtorrent ×1

python ×1