2017-08-12 34 views
0

我設置了代碼以鏈接到php中的代理列表。命中成功生成。我在html中獲取輸出。但是這個html不能在browswer中正確顯示。我想要從代理返回確切的HTML。任何身體知道如何做到這一點,請給我一些想法吧這裏是我使用如何以html格式顯示curl輸出在php

<?php 
$curl = curl_init(); 
$timeout = 30; 
$proxies = file("proxy.txt"); 
$r="https://www.abcdefgth.com"; 
// Not more than 2 at a time 
for($x=0;$x<2000; $x++){ 
//setting time limit to zero will ensure the script doesn't get timed out 
set_time_limit(30); 

//now we will separate proxy address from the port 
//$PROXY_URL=$proxies[$getrand[$x]]; 
echo $proxies[$x]; 
curl_setopt($curl, CURLOPT_URL,$r); 
curl_setopt($curl , CURLOPT_PROXY , preg_replace('/\s+/', '',$proxies[$x])); 
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt($curl, CURLOPT_REFERER, "http://google.com/"); 
$text = curl_exec($curl); 

echo "Hit Generated:"; 


} 

?> 
+0

我們不知道__proper__是什麼格式。所以,__沒有,沒有人不知道。 –

+0

<?php後,添加header(「content-type:text/plain; charset = utf8」);' - 它顯示正確嗎? – hanshenrik

回答

1

簡約的外觀到使用函數的文檔會回答你的問題的代碼:

http://php.net/manual/en/function.curl-exec.php它清楚地說明了在「返回值」部分的權利,您從該函數返回布爾值值。 除了如果你已經指定了CURLOPT_RETURNTRANSFER標誌,那麼你在而不是你是否在代碼中。

所以有一個嘗試添加

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 

通過遵循的企圖實際上輸出$text收到結果,你也忘了。

+0

這是我得到的輸出http://youtube.chandigarhpropertyonline.com/ –

+0

它的所有爛攤子我想在這裏得到好的html回報 –

+0

@azadchouhan看起來像「nice html」給我。我假設你參考了缺少的樣式規則。但這些不是html的一部分,你必須添加它們。 – arkascha