如何计算 torrent 的抓取 URL
我已经阅读了 Bit-torrent 规范并进行了多次搜索,试图找出如何从 torrent 跟踪器(使用 Python)获取种子/对等点/下载的数据。我可以毫无问题地从 Torrent 计算信息哈希值,它与各种正在运行的 Torrent 应用程序给出的信息哈希值相匹配。
但是,当我尝试从跟踪器获取信息时,我要么超时(跟踪器正在工作),要么得到空数据,具体取决于我输入 URL 的形式:
http://tracker.openbittorrent.com/scrape?info_hash=a8c482902b1c735de462479721b011dc7b3d3558 - 超时
我被告知这应该是 20 个字符long,所以采用了一个子字符串,但这给出了空数据。
http://tracker.openbittorrent.com/scrape?info_hash=a8c482902b1c735de462 - d5:filesdee
我想我误解了我应该如何编码或为抓取 URL 创建 infohash,但我一生都看不到在哪里。
I've read the Bit-torrent specification and done a number of searches, trying to find out how I can get the seeds/peers/downloaded data from a torrent tracker (using Python). I can calculate the info hash from a Torrent no problem, which matches up with the info hash given by various working torrent applications.
However, when I try to get the information from the tracker I either timeout (the tracker is working) or get empty data, depending on what form I put the URL in:
http://tracker.openbittorrent.com/scrape?info_hash=a8c482902b1c735de462479721b011dc7b3d3558 - timeout
I was told that this should be 20 characters long, so took a substring, but this gives empty data.
http://tracker.openbittorrent.com/scrape?info_hash=a8c482902b1c735de462 - d5:filesdee
I think I have misunderstood something with how I should encode or make the infohash for the scrape URL, but can't for the life of me see where.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在传递 info_hash 的十六进制字符表示形式。它应该是二进制表示。要将不可打印的字节放入 URL,请使用 URL 编码:(
我还尝试避免在 info_hash 参数中对
_
进行编码...并不是说它不正确,而是一种我希望一些为速度追踪器而编写的东西会搞砸。)You're passing in a hex-character representation of the info_hash. It should be a binary representation. To get unprintable bytes into the URL use URL-encoding:
(I'd also try to avoid encoding the
_
in the info_hash parameter... not that it isn't correct, but it's the sort of thing I would expect some written-for-speed trackers to mess up.)我的解决方案:
结果:
更多信息: binascii.unhexlify
My solution:
Result:
More info: binascii.unhexlify