file_get_contents獲取不到網頁內容的解決方法
更新時間:2013年03月07日 11:54:08 作者:
file_get_contents獲取不到網頁內容的解決方法,需要的朋友可以參考一下
復制代碼 代碼如下:
<?php
$url = "http://jb51.net/index.html";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//在需要用戶檢測的網頁里需要增加下面兩行
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
?>
您可能感興趣的文章:
- 探討file_get_contents與curl效率及穩(wěn)定性的分析
- 深入php函數file_get_contents超時處理的方法詳解
- 詳解PHP內置訪問資源的超時時間 time_out file_get_contents read_file
- 比file_get_contents穩(wěn)定的curl_get_contents分享
- PHP-CGI進程CPU 100% 與 file_get_contents 函數的關系分析
- php中使用Curl、socket、file_get_contents三種方法POST提交數據
- PHP下通過file_get_contents的代理使用方法
- php file_get_contents函數輕松采集html數據
- PHP file_get_contents 函數超時的幾種解決方法
- 關于file_get_contents返回為空或函數不可用的解決方案
相關文章
PHP中空字符串介紹0、null、empty和false之間的關系
用PHP開發(fā)那么久,PHP中空字符串、0、null、empty和false之間的關系總是有些不確定的東西。遇到它們應該用哪個方法函數去處理2012-09-09深思 PHP 數組遍歷的差異(array_diff 的實現)
深思 PHP 數組遍歷的差異(array_diff 的實現)...2006-06-06