如何转换 torrent 信息哈希以进行抓取?
我有一个来自磁力链接的种子哈希。例如:fda164e7af470f83ea699a529845a9353cc26576 当我尝试获取有关水蛭和同行的信息时,我应该请求: http://tracker.publicbt.com /scrape?info_hash=??? 我应该如何转换此请求的信息哈希?是url编码还是becoding?如何?在 PHP 中。
I have a torrent hash from the magnet link. For example: fda164e7af470f83ea699a529845a9353cc26576
When I try to get information about leechers and peers I should request: http://tracker.publicbt.com/scrape?info_hash=???
How should I convert info hash for this request? Is it url encoding or becoding? how? In PHP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它是原始的十六进制表示形式。将
pack()
与H 一起使用
来转换它。然后对其进行 URL 编码。It's a raw hexadecimal representation. Use
pack()
withH
to convert it. Then URL encode it.从同事那里得到这个Python片段,
输出:%FD%A1%64%E7%AF%47%0F%83%EA%69%9A%52%98%45%A9%35%3C%C2%65%76
就像魅力一样。
编辑:就像一个魅力,可以让跟踪器返回状态 200(好的),但仍然无法检索 torrent 详细信息...
Got this python snippet from a colleague,
Output: %FD%A1%64%E7%AF%47%0F%83%EA%69%9A%52%98%45%A9%35%3C%C2%65%76
Works like a charm.
Edit: Works like a charm for getting the tracker to give back status 200 (ok) but still doesn't work for retrieving the torrent details...
如果将来有人遇到麻烦并遇到此线程:解决整个问题的技巧是使用 PHP: sha1 函数,将其设置为“true”。
BDecode/DEncode 类可以在此处找到。这个名为 Trackon 的项目还包括许多其他有用的类,用于与 torrent 跟踪器和文件进行交互。
因此,在 PHP 中,类似这样的事情将有助于获取正确信息哈希以抓取跟踪器以获取详细信息:
然后只需像这样调用它:
希望这可以帮助那里的人。在阅读了许多有关如何获取正确信息哈希的文章后,我仍然摸不着头脑。我明白为什么现在没有在任何地方提到这一点,这个参数是在 PHP 5 中添加的。如果您没有运行 PHP 5,则在计算后必须将 sha1 哈希转换为原始二进制文件。
In case someone is having trouble and comes across this thread in the future: the trick to this whole issue is to use the
bool $raw_output
argument of the PHP: sha1 function, setting it to "true".The BDecode/DEncode classes can be found HERE. This project, called Trackon, also includes many other helpful classes to interact with torrent trackers and files.
So, in PHP, something like this will work to obtain the correct info hash for scraping the tracker for details:
Then merely call it like so:
Hope this helps someone out there. I was still scratching my head after reading many posts about how to obtain the correct info hash. I understand why this wasn't mentioned anywhere now though, this argument was added in PHP 5. If you're not running PHP 5, you will have to convert the sha1 hash to raw binary after you calculate it.