2013-02-20 59 views
0

我正在使用Windows 7.我已安裝XAMPP 1.8.0並啓用了CURL功能。但是,我仍然無法抓取網頁。Curl功能在XAMPP中不起作用1.8.0

我用下面的代碼段:

<?php 
// create a new cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/"); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

// grab URL and pass it to the browser 
curl_exec($ch); 

// close cURL resource, and free up system resources 
curl_close($ch); 
?> 

當我執行的程序,該錯誤消息是:

Fatal error: Maximum execution time of 30 seconds exceeded in 
C:\xampp\htdocs\testing\curl.php on line 14 

14行:curl_close($ch)

爲什麼我得到這樣的e RROR?我該如何調試它?請幫幫我。

回答

0

在你的頁面添加set_time_limit($seconds);

添加curl_setopt ($ch, CURLOPT_TIMEOUT, 60);並嘗試

+0

編輯答案請檢查一下:) – 2013-02-20 12:55:02

+0

參考鏈接:http://stackoverflow.com/questions/6935710/time -of-30-seconds-exceeded-error-file-get-contents – 2013-02-20 12:55:42

+0

[code] <?php //創建一個新的cURL資源 set_time_limit(120); [/ code] $ ch = curl_init(); //設置URL和其他適當的選項 curl_setopt($ ch,CURLOPT_TIMEOUT,120); curl_setopt($ ch,CURLOPT_URL,「http://www.google.com」); curl_setopt($ ch,CURLOPT_HEADER,0); //抓取URL並將其傳遞給瀏覽器 curl_exec($ ch)或die(curl_errno($ ch)。「:Can not execute it」); //關閉cURL資源,釋放系統資源 curl_close($ ch); ?> [/ code] – muneermunnar 2013-02-20 18:54:02