解决方案 »

  1.   


    $url = "http://item.taobao.com/item.htm?id=14861616067";
    echo curl_get($url);
    得到的数据中有
    <title>T浦力顿500g 成犬幼犬狗粮泰迪贵宾比熊金毛萨摩耶博美 批发散装-淘宝网</title>
    <h3 class="tb-item-title">T浦力顿500g 成犬幼犬狗粮泰迪贵宾比熊金毛萨摩耶博美 批发散装</h3>
    证明访问是没有问题的function curl_get($durl, $data=array()) {
      $cookiejar = realpath('cookie.txt');
      $t = parse_url($durl);
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,$durl);
      curl_setopt($ch, CURLOPT_TIMEOUT,5);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
      curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");
      curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
      curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
      if($data) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      }
      $r = curl_exec($ch);
      curl_close($ch);
      return $r;
    }
      

  2.   

    你可以在我的代码中逐个注释掉来判断少了什么
    估计是 少了 CURLOPT_REFERER