2011-12-19 110 views
0

我收到了一些链接,一些在rapidshare上,一些在其他上传主机上。 我试着用curl和file_get_contents获得源代码,然后搜索“已删除”左右,但我无法获得某些主机上的源代码。在php中获取html源代码

在某些主机上,curl正在工作,而其他file_get_contents正在工作,但大多数不会返回源代码。

这里是我的代码为卷曲:在您的卷曲代码

function curl_download($Url){ 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $Url); 
$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; 
curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch,CURLOPT_VERBOSE,false); 
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch,CURLOPT_SSLVERSION,3); 
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE); 
curl_setopt($ch, CURLOPT_TIMEOUT, 0); 
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); 
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); 
$output = curl_exec($ch); 
curl_close($ch); 
return $output; 

回答

0

尝试增加以下内容:

 

//after -- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 

希望它为你工作

+0

仍然没有工作。 我得到的源代码,但它不像我得到的源代码,如果我打开该网站,看看源代码,它是不同的。 我在源代码之前得到: HTTP/1.1 200 OK Cache-Control:private Content-Length:7036 Content-Type:text/html; charset = utf-8服务器:Microsoft-IIS/7.5 X-AspNet-Version:2.0.50727 Set-Cookie: – user1104615 2011-12-19 01:48:23

+0

这些是HTTP标头。 – ceejayoz 2011-12-19 02:05:33