我搜索以及使用libtorrent和python檢索torrent的IP地址。我嘗試用代碼:在python-libtorrent檢索同樣沒有下載的torrent文件
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'
它的工作或多或少,但我有兩個問題:
- 洪流下載。
- 在我收到一個對等列表之前,循環會執行幾十次。
你能幫我嗎?
非常感謝。
我想檢索我的碩士論文的測量對象列表。你的意思是「你也可以一次又一次向跟蹤器宣佈並收集產生的IP。」 ?你有一些代碼或一些函數名稱來做到這一點? 非常感謝。 – Comtention 2013-03-18 13:30:42
libtorrent中沒有獨立的跟蹤器通告函數,但您可能會使用urllib。然後再次,你不會得到DHT或UDP跟蹤器同行。 – Arvid 2013-03-19 22:52:31
get_full_peer_list()返回通過PEX或DHT發現的內容嗎? – Kar 2014-11-13 19:35:45