发送抓取请求以获取 torrent 的种子和同级
我一直在尝试创建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于我对 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 manyinfohash=
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.