<?php
//$url = 'http://www.1717ba.com';
$url = 'http://www.jingzhituan.com/team.aspx?id=126';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
$curl_result = curl_exec($ch);
var_dump($curl_result);
?>
上面的代码运行得到的总是false,但是把$url换成其他地址,比如 http://www.1717ba.com 是能获取到内容的,请问是什么原因?是不是人家网站做限制了?有什么办法能获取到他的内容?

解决方案 »

  1.   

    其他可以就他不行,就是限制了,用httpfox之类的检测访问是发送了什么内容,再依葫芦画瓢curl发送
      

  2.   

    用httpfox查了下,没发现有什么特别的内容,谁能帮忙查下看看是什么原因?
      

  3.   

    貌似我这里没问题string 'HTTP/1.1 200 OKDate: Sat, 28 May 2011 12:17:17 GMTServer: Microsoft-IIS/6.0X-Powered-By: ASP.NETX-AspNet-Version: 2.0.50727P3P: CP=CAO PSA OURP3P: CP=CAO PSA OURSet-Cookie: ASP.NET_SessionId=xxxxxxxxxxxxxxxxx; path=/; HttpOnlySet-Cookie: gourl=%e7%9b%b4%e6%8e%a5%e8%be%93%e5%85%a5%e7%bd%91%e5%9d%80; path=/Set-Cookie: fromdomain=; path=/Cache-Control: privateContent-Type: text/html; charset=utf-8Content-Length: 59503……