2011-12-19 95 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