Здравствуйте Парсю страничку с помощью cURL во избежания 301 ошибки и т.п. В итоге у меня в исходном коде в самом начале почему-то появляется такая строчка: Код (Text): HTTP/1.1 200 OK Date: Sat, 09 Mar 2013 08:03:03 GMT Server: Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/1.0.1c PHP/5.3.13 X-Powered-By: PHP/5.3.13 Content-Length: 3541 Как убрать ее? На всякий случай вот cURL скрипт Код (Text): $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $site); curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Сколько сек. ждать ответ сервреа $html = curl_redir_exec($ch); $html = curl_exec($ch); curl_close($ch); function curl_redir_exec($ch) { static $curl_loops = 0; static $curl_max_loops = 20; if ($curl_loops >= $curl_max_loops) { $curl_loops = 0; return false; } curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); list($header, $data) = explode("\n\n", $data, 2); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_code == 301 || $http_code == 302) { $matches = array(); preg_match('/Location:(.*?)\n/', $header, $matches); $url = @parse_url(trim(array_pop($matches))); if (!$url) { $curl_loops = 0; return $data; } $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); if (!$url['scheme']) $url['scheme'] = $last_url['scheme']; if (!$url['host']) $url['host'] = $last_url['host']; if (!$url['path']) $url['path'] = $last_url['path']; $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query']?'?'.$url['query']:''); //echo 'Пожалуйста, укажите следующий URL для правильного отображения контенте - '.$new_url; curl_setopt($ch, CURLOPT_URL, $new_url); return curl_redir_exec($ch); } else { $curl_loops = 0; return $data; } } Заранее спасибо за помощь!
curl_setopt($ch, CURLOPT_HEADER, true); вот это убрать. если не знаете зачем эта опция - зачем включаете?