Добрый вечер форумчанам. Постала задача сделать скрипт который будет ходить по ссылкам на сайте barbars.ru (браузерная игра). Автризируется без вопросов, ссылки парсятся тоже без проблем но оно не заходит. Тоесть ввожу ссылку а оно остается на тойже странице что и было. Ссылка получается вида http://barbars.ru/?wicket:interface=:4:nearLocation:5:locationLink::ILinkListener::&action=1324201581718 Исполузую Curl, пробывал даже Сокеты, результат тотже. Часть кода: Код | $user_agents = UserAgents::GetRnd(); $agent = $user_agents[1];
$http = new Http; $http->SetCookie('cookies_'.$user_id.'.txt'); $http->Set_REFERER($ref); $http->Set_USERAGENT($agent); $http->SetHEADER(1); $http->EchoContent(1);
//.... заходим на страницу и получаем контент, парсим и находимые //необходимые ссылки. $page = $http->GetPageCurl("http://barbars.ru/game/towers");
//.... фильтруем ссылки и выбираем нужную //.... переходим по ссылке
$http->Set_REFERER("http://barbars.ru/game/towers"); $page2 = $http->GetPageCurl($New_url);
|
Вот на этом этапе и начинаются проблемы. $page2 возвращает страницу game/towers Выбор юзер-агента: Код | class UserAgents { public static function GetRnd() { return self::$user_agents[rand(0,sizeof(self::$user_agents)-1)]; } //Массив Aser-agent'ов public static $user_agents = array( 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17', 'Opera/9.50 (X11; Linux ppc; U; en)', 'Opera/9.63 (Macintosh; Intel Mac OS X; U; de) Presto/2.1.1', 'Opera/9.63 (X11; Linux i686; U; de) Presto/2.1.1', 'Opera/9.80 (Windows NT 5.1; U; Distribution 00; ru) Presto/2.8.131 Version/11.11', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24', ); }
|
Ну и сам курл: Код | public function GetPageCurl($url, $proxy=NULL){ //$user = UserAgents::GetRnd(); //$ref = Referer::GetRnd();
$ch = curl_init($url); curl_setopt($ch, CURLOPT_URL, $url); if(!empty($this->iOptions['HEADER'])){ curl_setopt($ch, CURLOPT_HEADER, $this->iOptions['HEADER']); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); //curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'setCookies'); } if(!empty($this->iOptions['CURLOPT_REFERER'])){ curl_setopt($ch, CURLOPT_REFERER, $this->iOptions['CURLOPT_REFERER']); } curl_setopt($ch, CURLOPT_AUTOREFERER, 1); if(!empty($this->iOptions['CURLOPT_USERAGENT'])){ curl_setopt($ch, CURLOPT_USERAGENT, $this->iOptions['CURLOPT_USERAGENT']); } curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if(!empty($this->iOptions['CURLOPT_COOKIEFILE'])){ curl_setopt($ch, CURLOPT_COOKIEFILE, $this->iOptions['CURLOPT_COOKIEFILE']); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->iOptions['CURLOPT_COOKIEJAR']); } // if(!empty($this->iOptions['CURLOPT_CONNECTTIMEOUT'])){ // curl_setopt($ch, CURLOPT_COOKIEFILE, $this->iOptions['CURLOPT_CONNECTTIMEOUT']); // curl_setopt($ch, CURLOPT_COOKIEJAR, $this->iOptions['CURLOPT_TIMEOUT']); // } //curl_setopt($ch, CURLOPT_USERAGENT, $user); if(!empty($proxy)){ curl_setopt($ch, CURLOPT_PROXY, $proxy); }
if($this->iOptions['EchoContent']==1){ $page = curl_exec($ch); }else{ $page = NULL; curl_exec($ch); } if($this->iOptions['EchoInfo']==1){ $info = curl_getinfo($ch); }
//$page = $this->curl_redirect($ch); $this->iError = curl_error ($ch); $this->iHttpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->iErrorNo = curl_errno($ch); curl_close($ch);
return array('Error'=>$this->iError, 'ErrorNo'=>$this->iErrorNo, 'status'=>$this->iHttpStatus, 'content'=>$page,'info'=>$info); }
|
CURLOPT_COOKIEFILE и CURLOPT_COOKIEJAR один и тот же файл. Ps: сдесь ведь используется QUERY_STRING? Каким макаром у них сайт работает не понимаю. Вечно они усложняют жизнь. Зарание благодарен
|