下面这个地址我用file_get_contents取不到内容,而在浏览器里是可以打开的
$content=file_get_contents('http://istock.jrj.com.cn/d/ht/hottopic1.html');

解决方案 »

  1.   

    php.ini 的 allow_url_fopen 有没有打开
    看看防火墙有没冇封锁
      

  2.   

    php.ini里面
    allow_url_fopen 是否为on
    如果不是,重启apache.
      

  3.   

    没有防火墙,allow_url_fopen 也是开的
    另外,别的页面都可以取到的,就这个页面取不到
      

  4.   

    看看allow_url_fopen 打开没有
      

  5.   

    我试了...它的服务器限制了header
    你header 一定要指的的一些 User-Agent  才给下载
    否则 HTTP 503
      

  6.   


    $queryURL = "http://istock.jrj.com.cn/d/ht/hottopic1.html";   
    //user_agent   
    $useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";   
    //伪造header   
    $header = array('Accept-Language: zh-cn','Connection: Keep-Alive','Cache-Control: no-cache');    
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_REFERER, $queryURL);   
    curl_setopt($ch,CURLOPT_HTTPHEADER,$header);   
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
    curl_setopt($ch, CURLOPT_URL,$queryURL);    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   
    $result = curl_exec($ch);  
    echo $result;  用这种方式获取吧.
    应该是对方服务器做了限制.
    用file_get_contents类函数返回HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable错误,MS是
      

  7.   

    服务器由于维护或者负载过重未能应答.用浏览器可以,只能伪造useragent了.
      

  8.   

    php.ini里面 
    allow_url_fopen 是否为on 
    如果不是,重启apache. 
      

  9.   

    $opts = array(
    'http'=>array(
    'method'=>"GET",
    'header'=>"User-Agent: Mozilla/5.0\n"
    )
    );
    $context = stream_context_create($opts);
    echo file_get_contents("http://istock.jrj.com.cn/d/ht/hottopic1.html",false,$context);