[英]CURL returns blank page
我已經編寫了這段代碼,以從Google獲取所有數據,但返回空白。 該代碼是
$page = "http://www.google.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec ($ch);
curl_close ($ch);
echo $contents;
有人能找到這段代碼有什么問題嗎? 我已經檢查了php信息,我的curl已啟用。
就我而言,Google http服務器的答案包含重定向到http://www.google.ru/ :
HTTP/1.1 302 Found
Location: http://www.google.ru/
讓curl跟隨此“ Location:”標題:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.