【发布时间】:2020-02-05 12:42:05
【问题描述】:
我正在研究 bittorrent 协议,并想尝试一些跟踪器请求以获取有关对等点和东西的信息,但我无法从我尝试过的任何跟踪器收到任何适当的响应
这些是我的参数的样子
{'info_hash': '7bf74c4fd609bf288523f7cd51af3bdbc19df610', 'peer_id': '139a3f2ff0143c9f24c19c4f95ed1378aaf449d2', 'port': '6881', 'uploaded': '0', 'downloaded': '0', 'left': '931135488', 'compact': '1', 'no_peer_id': '0', 'event': 'started'}
import bencoding
import hashlib
import secrets
import requests
import urllib
file = open('../altlinux.torrent', 'rb')
data = bencoding.bdecode(file.read())
info_hash = hashlib.sha1(bencoding.bencode(data[b'info'])).hexdigest()
params = {
'info_hash': info_hash,
'peer_id': secrets.token_hex(20),
'port': '6881',
'uploaded': '0',
'downloaded': '0',
'left': str(data[b'info'][b'length']),
'compact': '1',
'no_peer_id': '0',
'event': 'started'
}
print(params)
page = requests.get(data[b'announce'], params=params)
print(page.text
这就是我写的,我得到了同样的错误,
d14:failure reason50:Torrent is not authorized for use on this tracker.e
我什至尝试将 info_hash 编码为
urllib.parse.quote_plus(info_hash)
只是为了使它成为 hexdigest 的 url 编码格式
我不确定我哪里出错了 有人可以帮忙吗?
【问题讨论】:
标签: python-requests bittorrent hashlib tracker libtorrent