如何计算 torrent 的抓取 URL

发布于 2024-08-10 00:22:53 字数 784 浏览 5 评论 0原文

我已经阅读了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始终不够爱げ你 2024-08-17 00:22:53

您正在传递 info_hash 的十六进制字符表示形式。它应该是二进制表示。要将不可打印的字节放入 URL,请使用 URL 编码:(

/scrape?info_hash=%A8%C4%82%90%2B%1Cs%5D%E4bG%97%21%B0%11%DC%7B%3D5X

我还尝试避免在 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:

/scrape?info_hash=%A8%C4%82%90%2B%1Cs%5D%E4bG%97%21%B0%11%DC%7B%3D5X

(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.)

赴月观长安 2024-08-17 00:22:53

我的解决方案:

import binascii

binary_info_hash = binascii.unhexlify('79b193385de5b967175ca86073670fce0e45a324')
print binary_info_hash

结果:

y%B1%938%5D%E5%B9g%17%5C%A8%60sg%0F%CE%0EE%A3%24

更多信息: binascii.unhexlify

My solution:

import binascii

binary_info_hash = binascii.unhexlify('79b193385de5b967175ca86073670fce0e45a324')
print binary_info_hash

Result:

y%B1%938%5D%E5%B9g%17%5C%A8%60sg%0F%CE%0EE%A3%24

More info: binascii.unhexlify

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文