<?php $url="武则天秘史";
$vod['vod_name']=urlencode($url);;
$contents_url_one=" http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];
$contents_url_html=ff_file_get_contents($contents_url_one);
print_r($contents_url_html);
function ff_file_get_contents($url){
for($i=0;$i<3;$i++){
$content = @file_get_contents($url);
if($content) break;
}
if($content){
return $content;
}
if(function_exists('curl_init')){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$content = curl_exec($ch);
curl_close($ch);
if($content){
return $content;
}
}
return false;
}
?>早在代码,在我这儿执行,是空的,啥都没有,
但是,给网上一个朋友运行一下,又有HTML代码。
现在我很苦恼。
$vod['vod_name']=urlencode($url);;
$contents_url_one=" http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];
$contents_url_html=ff_file_get_contents($contents_url_one);
print_r($contents_url_html);
function ff_file_get_contents($url){
for($i=0;$i<3;$i++){
$content = @file_get_contents($url);
if($content) break;
}
if($content){
return $content;
}
if(function_exists('curl_init')){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$content = curl_exec($ch);
curl_close($ch);
if($content){
return $content;
}
}
return false;
}
?>早在代码,在我这儿执行,是空的,啥都没有,
但是,给网上一个朋友运行一下,又有HTML代码。
现在我很苦恼。
}
加个 else{}试试, 是不是你本地没有开CURL
$contents_url_one=" http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];
=>
$contents_url_one="http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];地址开头处的空格
echo $url;看下输出的地址你能接受不