[英]Torrent Scrape in PHP
i'm trying to scrape a torrent tracker for seeders and leechers using PHP. 我正在尝试使用PHP搜寻种子和水虫的洪流跟踪器。 This is the hash value returned by torcahche: 7026AB638744F2BD2444033A8730DA146E15A886
Following trackers come with the torrent: 这是torcahche返回的哈希值: 7026AB638744F2BD2444033A8730DA146E15A886
torrent 7026AB638744F2BD2444033A8730DA146E15A886
以下跟踪器:
udp://tracker.openbittorrent.com:80/announce
udp://tracker.publicbt.com:80/announce
udp://tracker.ccc.de:80/announce
these are the methods that i have tried to get the info i need: 这些是我尝试获取所需信息的方法:
$orig="7026AB638744F2BD2444033A8730DA146E15A886";
$infoHash=$orig;
$nfo='udp://tracker.openbittorrent.com:80/scrape?hash_id='.$infoHash;
echo '<br>'.$nfo;
$gitsl=$this->input->get($nfo);
print_r($gitsl);
$infoHash=pack('H',$orig);
$nfo='udp://tracker.openbittorrent.com:80/scrape?hash_id='.$infoHash;
echo '<br>'.$nfo;
$gitsl=$this->input->get($nfo);
print_r($gitsl);
$infoHash=hex2bin($orig);
$nfo='udp://tracker.openbittorrent.com:80/scrape?hash_id='.$infoHash;
echo '<br>'.$nfo;
$gitsl=$this->input->get($nfo);
print_r($gitsl);
$infoHash='%70%26%AB%63%87%44%F2%BD%24%44%03%3A%87%30%DA%14%6E%15%A8%86% ';
$nfo='udp://tracker.openbittorrent.com:80/scrape?hash_id='.$infoHash;
echo '<br>'.$nfo;
$gitsl=$this->input->get($nfo);
print_r($gitsl);
So getting nothing, the following questions have risen: 因此一无所获,出现了以下问题:
I've also tried multiple sites that allow you to manually type in hash info for a scrape, all unsucessful. 我还尝试了多个站点,这些站点允许您手动输入哈希信息以进行刮取,所有操作均未成功。
Hope somebody can help, cheers. 希望有人可以帮助,加油。
Well, first of all, you don't to a GET
request like that. 好吧,首先,您不需要像这样的GET
请求。 This is how you READ the value of input. 这就是您读取输入值的方式。
Second, you are trying to perform a request through UDP. 其次,您尝试通过UDP执行请求。 So you cannot just GET
it, as the browser, or whatever, will do an HTTP request instead. 因此,您不能只GET
它,因为浏览器或其他任何东西都将执行HTTP请求。
As stated in a comment in this site 如本网站评论中所述
The problem with UDP is that in case of TCP you have a tunnel, inside of which all data goes in both directions, but in case of UDP you send the UDP packet and have to open the port to listen for the answer (if it would come back). UDP的问题是,在TCP情况下,您有一个隧道,其中的所有数据都在两个方向上传输;但是在UDP的情况下,您发送UDP数据包并必须打开端口以侦听答案(如果可以回来)。 And if you get some data back, the packets can return in different order - you have to deal with this too. 而且,如果您返回一些数据,则数据包可以以不同的顺序返回-您也必须处理此问题。
That's why a normal GET
or file_get_contents()
won't do much good for you. 这就是为什么普通的GET
或file_get_contents()
对您没有多大好处的原因。
You can use stream_wrapper_register() to implement the wrapper for the UDP request. 您可以使用stream_wrapper_register()来实现UDP请求的包装器。
Additionally, you should use $infoHash = urlencode(pack("H*", $orig))
to get the string needed to give to the tracker. 另外,您应该使用$infoHash = urlencode(pack("H*", $orig))
来获取需要提供给跟踪器的字符串。
Repeating my answer from this question: UDP Tracker Scraping 1 script working other Not 重复我对这个问题的回答: UDP Tracker Scraping 1脚本工作其他Not
The problem is that you are sending a http- scrape
to a UDP-tracker. 问题是您正在将http- scrape
发送到UDP-tracker。
UDP-trackers uses an entirely diffrent protocol: BEP15 - UDP Tracker Protocol for BitTorrent UDP跟踪器使用完全不同的协议: BEP15-BitTorrent的UDP跟踪器协议
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.