2012-09-14 6 views
0

cURL 요청을 실행하고 있지만 대부분의 경우 작동하지만 일부 사이트의 경우 아무것도 반환하지 않으며 오류가 없습니다. 아무도 도와 줄 수 없나요? http://www.convurgency.com/tools/googlebot.php일부 사이트에 대해 cURL이 반환되지 않습니다.

이동이이 사이트에 입력 : 여기

내 작은 응용 프로그램입니다 http://www.beemak.com

당신이 사이트 많이 작동 볼 수 있지만 선택된 것들 ... 어떤 아이디어를 해달라고으로? $의 CONNECTTIME와 $ 다운로드 시간과 요청이 시간 초과되지 않은 경우 확인에

<?php 
//Bot Curl Request 


$handle = curl_init(); 

curl_setopt_array($handle,array(
     CURLOPT_URL => $_GET['site'], 
     CURLOPT_USERAGENT => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', 
     CURLOPT_RETURNTRANSFER => true, 
     CURLOPT_FOLLOWLOCATION => true 
    )); 

    $output = curl_exec($handle); 

    $httpcode = curl_getinfo($handle, CURLINFO_TOTAL_TIME); 
    $connecttime = curl_getinfo($handle, CURLINFO_CONNECT_TIME); 
    $downloadtime = curl_getinfo($handle, CURLINFO_SPEED_DOWNLOAD); 
    $downloadsize = curl_getinfo($handle, CURLINFO_SIZE_DOWNLOAD); 

    if(curl_errno($handle)){ 
     echo '<img class="errorlogo" src="http://www.convurgency.com/images/logo103.png" />'; 
     echo '<p style="text-align:center;">There was an error finding your site, are you sure it exists?</p>'; 
     echo '<p style="text-align:center;"><a href="http://www.convurgency.com/tools/googlebot.php">Back to GoogleBot View</a></p>'; 
     echo 'Curl error: ' . curl_error($handle); 

    } else { 

     echo 'No Errors'; 

    }; 

    if (curl_error($handle)) { 
    print "ERROR ". curl_error($handle) ."\n<br/>"; 
    } 


    curl_close($handle); 


    $output2 = preg_replace(
     array(
     // Remove invisible content 
     '@<head[^>]*?>.*?</head>@siu', 
     '@<style[^>]*?>.*?</style>@siu', 
     '@<script[^>]*?.*?</script>@siu', 
     '@<object[^>]*?.*?</object>@siu', 
     '@<embed[^>]*?.*?</embed>@siu', 
     '@<applet[^>]*?.*?</applet>@siu', 
     '@<noframes[^>]*?.*?</noframes>@siu', 
     '@<noscript[^>]*?.*?</noscript>@siu', 
     '@<noembed[^>]*?.*?</noembed>@siu', 
     // Add line breaks before and after blocks 
     '@</?((address)|(blockquote)|(center)|(del))@iu', 
     '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu', 
     '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu', 
     '@</?((table)|(th)|(td)|(caption))@iu', 
     '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu', 
     '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu', 
     '@</?((frameset)|(frame)|(iframe))@iu', 
     ), 
        array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",), $output); 

echo preg_replace('/<(\w+) [^>]+>/', '<$1>', $output2); 

?> 
+0

고마워요 ... 코드를 수정했습니다 ... 왜 어떤 사이트에서 돌아 오지 않는 이유는 무엇입니까? – onei0120

+0

일반 데스크톱 사용자 에이전트를 사용해 보셨습니까? 만약 작동한다면 그들은 당신의 요청을 필터링하고 있습니다. – Maks3w

+0

그냥 일반 사용자 에이전트 문자열로 시도했지만, 여전히 작동하지 않았습니다. 컬 에러가 없습니다. – onei0120

답변

0

봐 :

여기 내 코드입니다. 명령 행 curl 또는 wget을 사용하여 스크립트를 실행중인 서버에서 웹 사이트에 연결할 수 있는지 확인하십시오.

+0

요청이 시간 초과되지 않습니다. 다운로드가 완료된 시간과 다운로드 시간이 반환됩니다. – onei0120

관련 문제