Я пытаюсь открыть страницу на своем собственном веб-сайте для поисковой системы. Я пытаюсь работать. Я попробовал несколько способов сделать это:
file_get_contentsPHP, читающий страницу на моем сайте
$temp = file_get_contents("http://www.mysite.com/example01/");
echo $temp;
возвращает:
Warning: file_get_contents(http://www.mysite.com/example01/) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\inetpub\wwwroot\mysite\example01\temp.php on line 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'";
возвращает:
Array ( [url] =>http://www.jlwarranty.com/example01/ [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => 0 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 0 [redirect_time] => 0)
cURL error number:0
cURL error:
''
Для загрузки страницы требуется около 30 секунд.
cURL включен в php.ini, а также allow_url_fopen.
В этом была проблема. Я обошел это, поставив IP-адрес наших сайтов в файл hosts как www.mysite.com, так что скрипт поиска не должен сильно изменяться. – AndyD273