2017-12-19 1 views
0

이 웹 사이트를 구문 분석하려고하는데 : http://www.mz.gov.kz/ru/news,하지만 504 오류가 발생합니다. connection_timeout을 60 초로 변경하면 28 error: connect timed out이됩니다. 다른 서버에서 제대로 작동합니다. 어쩌면 내 IP가 차단 되었을지 모르겠다. 내 기능은curl exec 500 timeout nginx

function get_web_page($url) 
    { 
     $uagent = "Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14"; 
     $ch = curl_init($url); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
     curl_setopt($ch, CURLOPT_USERAGENT, $uagent); 
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); 
     curl_setopt($ch, CURLOPT_TIMEOUT, 120);   
     curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
     curl_setopt($ch, CURLOPT_COOKIEFILE,"d://coo.txt");  
    $content = curl_exec($ch); 
    $err = curl_errno($ch); 
     $errmsg = curl_error($ch); 
     $header = curl_getinfo($ch); 
     curl_close($ch); 
     $header['errno'] = $err; 
     $header['errmsg'] = $errmsg; 
     $header['content'] = $content; 
    //echo $errmsg.'s<br>'; 
     /*foreach($header as $key=>$value){ 
      echo $key.' -- > '.$value.'<br>'; 
     }*/ 
     return $header; 
    } 

답변

0

코드가 유효합니다.

504 오류는 어떤 문제가 서버 측과 발생한 것을 의미 구체적 작성한 요청은 60 내지 120이 경우 무언가 서버 구성에 의해 허용되는 최대 값보다 (실행되는) 시간을 필요로한다는 초.

응답 오류 코드가 "정품"인 경우 서버가 과부하되었거나 실제로 시간 초과를 유발하는 특정 요청을하고 있습니다.

또 다른 옵션은 IP가 금지되어 있고 서버가 "방어"측정으로 연결 시간 초과를 허용 할 수 있습니다.하지만 이는 내 경험에 비추어 볼 때 매우 드뭅니다. 일반적으로 IP가 금지되면 연결이 거부됩니다. 구현이 쉬우 며 리소스 소모가 적습니다.

관련 문제