<?php
set_time_limit(0);
$pages = 1; #количество страниц парсинга
function getID($pages) {
global $links;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://redtube.com/?page=$pages");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2 (.NET CLR 3.5.30729)");
curl_setopt($ch, CURLOPT_REFERER, 'http://google.com');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'redtube');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
preg_match_all('#redtube.com/(\d{5})#i',$res, $links);
}
function getPages($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://$url");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2 (.NET CLR 3.5.30729)");
curl_setopt($ch, CURLOPT_REFERER, 'http://redtube.com');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'redtube');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
preg_match("#hashlink=(.*)\" \/>#i",$res, $url_file);
$gg = preg_replace("#%3A#", ":", $url_file[1]);
$gg = preg_replace("#%2F#", "/", $gg);
$gg = preg_replace("#%3D#", "=", $gg);
$gg = preg_replace("#%3F#", "?", $gg);
$gg = preg_replace("#%26#", "&", $gg);
@file_put_contents('parse_tube.txt', $gg . "\r\n", FILE_APPEND);
}
for ($i=0; $i<$pages; $i++) {
getID($pages);
foreach ($links[0] as $url)
getPages($url);
}
?>