【发布时间】:2010-09-27 15:57:54
【问题描述】:
我正在尝试在我自己的网站上打开一个页面,以查找我正在尝试使用的搜索引擎。
我尝试了几种方法:
file_get_contents
$temp = file_get_contents("http://www.mysite.com/example01/");
echo $temp;
返回:
警告: file_get_contents(http://www.mysite.com/example01/) [function.file-get-contents]:失败 打开流:连接尝试 失败是因为关联方做了 一段时间后无法正确响应 时间,或建立连接失败 因为连接的主机未能 回应。在 C:\inetpub\wwwroot\mysite\example01\temp.php 在第 66 行
卷曲
function curl($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true); // Display headers
curl_setopt($ch, CURLOPT_VERBOSE, true); // Display communication with server
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
print "<pre>\n";
print_r(curl_getinfo($ch)); // get error info
echo "\n\ncURL error number:" .curl_errno($ch); // print error info
echo "\n\ncURL error:" . curl_error($ch);
print "</pre>\n";
return curl_exec($ch);
curl_close($ch);
}
$temp = curl("http://www.mysite.com/example01/");
echo "'$temp'";
返回:
数组 ( [网址] => http://www.jlwarranty.com/example01/ [http_code] => 0 [header_size] => 0 [请求大小] => 0 [文件时间] => 0 [ssl_verify_result] => 0 [redirect_count] => 0 [总时间] => 0 [名称查找时间] => 0 [连接时间] => 0 [pretransfer_time] => 0 [大小上传] => 0 [大小下载] => 0 [速度下载] => 0 [速度上传] => 0 [下载内容长度] => 0 [上传内容长度] => 0 [starttransfer_time] => 0 [redirect_time] => 0)
cURL 错误号:0
cURL 错误:
''
页面重新加载大约需要 30 秒。
cURL 在 php.ini 中启用,allow_url_fopen 也是如此。
【问题讨论】:
标签: php