Чем заменить CURLOPT_FOLLOWLOCATION?
Привет.
Вот код:
function get_web_page( $url )
{
$uagent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
$ch = curl_init( $url );
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
// ключевое слово
$keyword = 'casino';
// избавляемся от пробелов, если они есть
$keyword = strtr($keyword, ' ', '+');
$url = 'http://search-key.com/keywords.php?keywords='.$keyword.'';
$result = get_web_page( $url );
$err = 0;
if ( $result['errno'] != 0 )
{
$err = 1;
}
if ( $result['http_code'] != 200 )
{
$err = 1;
}
$page = $result['content'];
$a_pattern = '#<a href="(.*?)">(.*?)</a>#sm';
if (preg_match_all($a_pattern, $page,$a_matches, PREG_SET_ORDER))
{
foreach ($a_matches as $a)
echo $a[2].'<br>';
}
else echo 'ni 4ego ne naideno!';
Пытаюсь запустить, выдает ошибку:
(Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in)
Чем можно заменить функцию
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
Выложил полный код
Источник: Stack Overflow на русском