发送抓取请求以获取 torrent 的种子和同级

发布于 2024-10-19 22:44:41 字数 1370 浏览 8 评论 0原文

我一直在尝试创建一个 torrent 网站,但我遇到了以下问题。 如何发送 torrent 抓取请求以获取其播种者和水蛭?

我有一个 PHP 类函数,它为我提供公告列表。

public function getTrackers() {
    // Load tracker list
    $trackerlist = array();

    if ( $this->torrent->get_value('announce-list') )
    {
        $trackers = $this->torrent->get_value('announce-list')->get_plain();
        while ( list( $key, $value ) = each( $trackers ) )
        {
            if ( is_array( $value->get_plain() ) ) {
                while ( list( $key, $value2 ) = each( $value ) )
                {
                    while ( list( $key, $value3 ) = each( $value2 ) )
                    {
                        array_push( $trackerlist, $value3->get_plain() );
                    }
                }
            } else {
                array_push( $trackerlist, $value->get_plain() );
            }
        }
    }
    else if ( $this->torrent->get_value('announce') )
    {
        array_push( $trackerlist, $this->torrent->get_value('announce')->get_plain() );
    }

    return $trackerlist;
}

该代码基于bencode.php编码的数据。如何像这样显示每个连续公告网址的种子同级

Annouce Url | Seeds : No. | Peers: No.     
Annouce Url | Seeds : No. | Peers: No.     
Annouce Url | Seeds : No. | Peers: No. 
and so on.....

I have been trying to create a torrent site but I'm stuck with the following.
How to send torrent scrape request to get its seeder and leechers?

I have a PHP class function that provides me announce list.

public function getTrackers() {
    // Load tracker list
    $trackerlist = array();

    if ( $this->torrent->get_value('announce-list') )
    {
        $trackers = $this->torrent->get_value('announce-list')->get_plain();
        while ( list( $key, $value ) = each( $trackers ) )
        {
            if ( is_array( $value->get_plain() ) ) {
                while ( list( $key, $value2 ) = each( $value ) )
                {
                    while ( list( $key, $value3 ) = each( $value2 ) )
                    {
                        array_push( $trackerlist, $value3->get_plain() );
                    }
                }
            } else {
                array_push( $trackerlist, $value->get_plain() );
            }
        }
    }
    else if ( $this->torrent->get_value('announce') )
    {
        array_push( $trackerlist, $this->torrent->get_value('announce')->get_plain() );
    }

    return $trackerlist;
}

This code is based on the data encoded by the bencode.php. How to show Seeds and Peers of every consecutive announce url like this?

Annouce Url | Seeds : No. | Peers: No.     
Annouce Url | Seeds : No. | Peers: No.     
Annouce Url | Seeds : No. | Peers: No. 
and so on.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

宁愿没拥抱 2024-10-26 22:44:41

由于我对 PHP 的经验有限,我无法帮助您编写代码,但是处理 HTTP 跟踪器应该相当容易。

获取公告 URL,搜索“announce”并将其替换为“scrape”,并添加 ?infohash= 作为参数(您可以将尽可能多的 infohash= 添加到您的查询中,除以 & 符号。对生成的 URL 进行 HTTP 调用并读取您的编码答案,它将包含所有请求的信息哈希及其各自的下载、播种器(跟踪器词汇中的“完整”)和 leechers(“不完整”)。 HTTP scrape 的记录非常详细。 处理 UDP 跟踪器有些复杂,因为这种二进制形式的

通信发生在较低的级别。 nofollow">UDP 跟踪器协议的完整描述。

I can't help you with code, due to my limited experience with PHP, but dealing with HTTP trackers should be fairly easy.

Get the announce URL, search and replace the word "announce" with "scrape" and add ?infohash=<url-encoded-binary-20-byte-long-infohash> as parameter (you may add as many infohash= to your query, divided by ampersand. Make a HTTP call to that resulting URL and read your bencoded answer. It will contain all the requested info-hashes with their respective downloads, seeders ('complete' in tracker's vocabulary) and leechers ('incomplete'). HTTP scrape is very well documented.

Dealing with UDP trackers is somewhat more complicated, because this binary form of communication happens at much lower level. Check the full description of UDP tracker protocol.

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