|
|
|
|
|
|
|
| Re: Scrape...External [message #4086 is a reply to message #3236] |
Sat, 08 May 2010 12:06   |
LogIN  Messages: 6 Registered: May 2010 |
Leecher |
|
|
maybe i misunderstood you but if you wont to get seeds, peers stats from torrent (external trackers) you can do it like this:
lats say: $trackers is array of tracker urls:
<?php
include "functions.php";
function hexx2bin($RawInput){
$BinStr = "";
for ($i = 0; $i < strlen($RawInput); $i += 2)
$BinStr .= "%" . substr($RawInput, $i, 2);
return rawurldecode($BinStr);
}
function get_torrent($url, $time){
$ch = curl_init();
$header[0] = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$header[] = "Cache-Control: max-age=0";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Keep-Alive: 115";
$header[] = "Connection: keep-alive";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $time);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result_torrent = curl_exec($ch);
curl_close($ch);
return $result_torrent;
}
$seeds = 0;
$leechs = 0;
$downloads = 0;
$i = 0;
if (is_array($trackers)) {
foreach (array_unique($trackers) as $tracker) {
$scrape = str_replace("announce", "scrape", $tracker);
$sources = bdec(get_torrent($scrape . "?info_hash=" . urlencode(hex2bin($info)), 3));
$seeds = $seeds + $sources['files'][hex2bin($info)]['complete'];
$leechs = $leechs + $sources['files'][hex2bin($info)]['incomplete'];
$downloads = $downloads + $sources['files'][hex2bin($info)]['downloaded'];
$i++;
}
echo "Seeds: " . $seeds . "<br />";
echo "Leechs: " . $leechs . "<br />";
echo "Downloads: " . $downloads;
?>
More Info: URL
[Updated on: Sat, 08 May 2010 12:08] Report message to a moderator
|
|
|
|