2011-12-09 29 views
0

美好的一天,來自代理服務器的cURL內容

我有一個PHP腳本,它從URL獲取內容。我爲此使用了cURL。但是,我想從代理服務器獲取內容,例如http://www.canadaproxy.net/,並且腳本似乎沒有返回值。

這裏是我的PHP代碼:

$url = "http://www.canadaproxy.net/browse.php?u=Oi8vd3d3Lmdvb2dsZS5jYS8%3D&b=5";
$timeout = 5;
$useragent = "Googlebot/2.1 (http://www.googlebot.com/bot.html)";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$raw = curl_exec($ch);
curl_close($ch);

var_dump($raw);

任何建議將不勝感激。

謝謝!

回答

1

URL應該是:$ url =「http://www.canadaproxy.net/includes/process.php?action=update」;

添加

curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); 
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); 
curl_setopt($ch,CURLOPT_POST, true); 
curl_setopt($ch,CURLOPT_POSTFIELDS, "u=google.com"); 

,也將努力

+0

它的工作!非常感謝你! – acidpaul

相關問題