2012-10-24 1 views
2

오류 보고서를 잠시 후 정지를 실행 스크래핑에 필요한 용기.
2/db에서 URL 대상을 가져옵니다.
3/CURL 또는 file_get_content를 사용하여 콘텐츠를 가져옵니다.
4/simple_html_dom과 함께 "$ html"을 설정하십시오.
5/컨텐츠를 긁어 조작하는 "엔진"이 포함됩니다.
6/마지막으로 - 확인하고 내용을 최적화하고 db에 저장하십시오.
7/X 링크에서 수행하십시오. X 링크가 페이지를 새로 고치고 크롤링 프로세스를 계속하면

PHP 스크립트 내가 않는 것을 일반적으로 4 봇 동시에, 각 봇이 새 탭에서 열립니다 실행하고 크롤러 스크립트가

모든 것이 마법처럼 작동했습니다! 하지만 최근에 몇 분 (같은 시간이 아님)의 모든 봇은
(오류없이 깜박임) 몇 번만 그 중 3 번 ...
페이지가 Y 분마다 새로 고침되는 시간 간격을 설정하는 스크립트가 있습니다 . 그건 내
로봇이 걸렸을 때 작동하지만이 문제에 대한 답변이 아니라면 keepig입니다.

나는 아파치 오류 로그를 확인했으며 이상한 메시지가 없음을 확인했다.

어떤 생각이 있습니까 ???
수축 코드 : (의견) 편집

ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'); 
error_reporting(E_ALL); 
include ("peulot/stations1.php");//with connection and vars 
include_once('simple_html_dom.php'); 

//DEFINE VALUES: 
/* 
here vars are declared and set 
*/ 

     echo " 
      <script language=javascript> 

      var int=self.setInterval(function(){ refresh2(); },".$protect."); 

      var counter; 

      function refresh2() { 
       geti(); 
       link = 'store_url_beta.php?limit_link=".$limit_link."&storage_much=".$dowhile."&jammed=".($jammed_count+=1)."&bot=".$sbot."&counter='; 
       link = link+counter; 
       window.location=link; 
       } 

      function changecolor(answer) 
        { 
       document.getElementById(answer).style.backgroundColor = \"#00FF00\"; 
        } 
      </script>";//this is the refresh if jammed 


//some functions: 
/* 
function utf8_encode_deep --> for encoding 
function hexbin --> for simhash fingerprint 
function Charikar_SimHash --> for simhash fingerprint 
function SimHashfingerprint --> for simhash fingerprint 
*/    

     while ($i<=$dowhile) 
      { 

      //final values after crawling: 
      $link_insert=""; 
      $p_ele_insert=""; 
      $title_insert=""; 
      $alt_insert=""; 
      $h_insert=""; 
      $charset=""; 
      $text=""; 
      $result_key=""; 
      $result_desc=""; 
      $note=""; 

      ///this connection is to check that there are links to crawl in data base... + grab the line for crawl. 
      $sql = "SELECT * FROM $table2 WHERE crawl='notyet' AND flag_avoid $regex $bot_action"; 
      $rs_result = mysql_query ($sql); 
      $idr = mysql_fetch_array($rs_result);       
      unset ($sql); 
      unset ($rs_result); 

       set_time_limit(0); 

       $qwe++; 

        $target_url = $idr['live_link'];//set the link we are about to crawl now. 
        $matches_relate = $idr['relate'];//to insert at last 
        $linkid = $idr['id'];//link id to mark it as crawled in the end 
        $crawl_status = $idr['crawl'];//saving this to check if we update storage table or insert new row 
        $bybot_status = $idr['by_bot'];//saving this to check if we update storage table or insert new row 

        $status ="UPDATE $table2 SET crawl='working', by_bot='".$bot."', flag_avoid='$stat' WHERE id='$linkid'"; 
        if(!mysql_query($status)) die('problem15');     

        $ch = curl_init(); 

        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'); 
        curl_setopt($ch, CURLOPT_URL, $target_url); 
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); 
        curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
        curl_setopt($ch, CURLOPT_HEADER, 0); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        $str = curl_exec($ch); 
        curl_close($ch); 

        if (strlen($str)<100) 
          { 
          //do it with file get content 
          }    
     if (strlen($html)>500) 
     { 

          require("engine.php");//GENERATE FATAL ERROR IF CRAWLER ENGINE AND PARSER NOT AVAILABLE 

         flush();//that will flush a result without any refresh 
         usleep(300);         

           //before inserting into table storage check if it was crawled before and then decide if to insert or update: 
           if ($crawl_status=="notyet"&&$bybot_status=="notstored") 
              { 
              //insert values 
              } 
              else 
              { 
              //update values 
              } 

         flush();//that will flush a result without any refresh 
         usleep(300); 


         if ($qwe>=$refresh) //for page refresh call 
          { 
          $secounter++;//counter for session 
          //optimize data       
          echo "<script type='text/javascript'>function refresh() { window.location='store_url_beta.php?limit_link=".$limit_link."&counter=".$i."&secounter=".$secounter."&storage_much=".$dowhile."&jammed=".$jammed."&bot=".$sbot."'; } refresh(); </script>";       
          } 
      }//end of if html is no empty. 
      else 
      {//mark a flag @4 and write title jammed! 

      //here - will update the table and note that its not possible to crawl 

         if ($qwe>=$refresh) 
          { 
          $secounter++;//counter for session 
          //optimize data       
          echo "<script type='text/javascript'>function refresh() { window.location='store_url_beta.php?limit_link=".$limit_link."&counter=".$i."&secounter=".$secounter."&storage_much=".$dowhile."&jammed=".$jammed."&bot=".$sbot."'; } refresh(); </script>";       

          } 
      }//end of else cant grab nothing 
      unset($html); 
     }//end of do while 
      mysql_close(); 
      echo "<script language=javascript> window.clearInterval(int); </script>"; 

: (잭 조언 다음) 끝없는 테스트 및 로깅 방법 후
내가 아무것도 찾을 수 없습니다! 봇이 정지 될 때 발생 유일한 것은 아파치 로그에 있습니다

[Thu Oct 25 01:01:33 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico 
zend_mm_heap corrupted 
[Thu Oct 25 01:01:51 2012] [notice] Parent: child process exited with status 1 -- Restarting. 
[Thu Oct 25 01:01:51 2012] [notice] Apache/2.2.22 (Win64) mod_ssl/2.2.22 OpenSSL/1.0.1c PHP/5.3.13 configured -- resuming normal operations 
[Thu Oct 25 01:01:51 2012] [notice] Server built: May 13 2012 19:41:17 
[Thu Oct 25 01:01:51 2012] [notice] Parent: Created child process 736 
[Thu Oct 25 01:01:51 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] 
[Thu Oct 25 01:01:51 2012] [notice] Child 736: Child process is running 
[Thu Oct 25 01:01:51 2012] [notice] Child 736: Acquired the start mutex. 
[Thu Oct 25 01:01:51 2012] [notice] Child 736: Starting 200 worker threads. 
[Thu Oct 25 01:01:51 2012] [notice] Child 736: Starting thread to listen on port 80. 
[Thu Oct 25 01:01:51 2012] [notice] Child 736: Starting thread to listen on port 80. 
[Thu Oct 25 01:01:51 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico 

이 줄 난 정말 저를 도와주세요 어떻게 해야할지 잘 모릅니다 신비입니다!
[목요일 10 월 25 일 01:01:51 2012] [주의] 상위 : 상태 1로 종료 된 하위 프로세스 - 다시 시작.

+0

무엇이 엉망입니다. 코드를 정확하게 들여 씁니다. – OptimusCrime

+3

그것은 사람들이 당신에게 대답을주기 위해 기다리고있는 많은 코드입니다. 문제가있는 곳을 좁힐 수 있는지 먼저 스스로 디버깅 해보십시오. –

+0

죄송합니다. 지금 – shlomix

답변

0

이러한 문제를 찾는 방법은 일반적으로 일반적인 이전 로깅으로 이어집니다.

디버그 메시지, 행 번호, 메모리 사용량 등 필요한 긴 작업 전후에 각 작업자가 자신의 로그 파일에 항목을 작성하도록해야합니다. 그것을 몇 번 잼과 로그를 분석하자.

패턴 (예 : 로그가 같은 지점에 데이터를 표시하지 않음) 인 경우 검색 범위를 좁힐 수 있습니다. 그렇지 않은 경우 메모리 문제 또는 기타 치명적인 충돌을 처리 할 수 ​​있습니다.

관련성이없는 것처럼 보일 수도 있지만 최근 설정에서 변경 한 사항을 추적하는 데 도움이됩니다.

+0

빠른 응답에 감사드립니다! 나는 아파치 로그를 다시 확인했으나 에러는 없다. [error] [client 127.0.0.1] 파일이 존재하지 않는다. C : /wamp/www/favicon.ico – shlomix

+0

은 최근에 이러한 설정을 아파치 : KeepAlive를 MaxKeepAliveRequests 2000 의 MaxRequestsPerChild 2000 KeepAliveTimeout을 내가 충분히 자신을 분명히했다고 생각하지 않습니다 user1769877 @ – shlomix

+0

오프 350 개 는 HostnameLookups; * 당신은 로깅을해야합니다. –

관련 문제