2015-01-20 2 views
0

구문 분석 된 데이터를 데이터베이스에 저장하는 간단한 html dom 파서가 있습니다. 그러나 여기 dom은 첫 번째 행을 건너 뛰고 다른 모든 데이터는 계속 파싱합니다. 데이터를 파싱 할 URL은 http://krushimitra.co.in/4.html입니다. PHP 스크립트가 첫 행만 건너 뜁니다.

또한 내 PHP 스크립트 같은입니다

...

............ 
ini_set('max_execution_time', 0); 

error_reporting(E_ALL); 
ini_set('display_errors', '1'); 
$url='http://krushimitra.co.in/4.html'; 
include('dom.php'); 
$html=file_get_html($url); 


    $record_find='first'; 
    foreach($html->find('table#GridView1') as $e){ 

       if($record_find=='first'){ $record_find="second";continue;} 
     $i=1; 
       foreach($e->find('tr') as $e1){ 
        if($i<4){$i++;continue;} 
           $some=trim($e1->find('td', 0)->innertext); 
           $somea=trim($e1->find('td', 1)->innertext); 
           $someb=trim($e1->find('td', 6)->innertext); 

           $col=trim($e1->find('td', 0)->colspan); 
           if($col == 10){...... 
........... 

내 DOM은 http://sourceforge.net/projects/simplehtmldom/files/ @입니다. 나는 define('MAX_FILE_SIZE', 60000000); 님을 체포했습니다.

내 스크립트가 첫 번째 행을 고려하지 않는 이유를 모르겠다. 여기서는 colspan이 10 인 "Bhatiya (NIL Transaction)"입니다.이 문제를 해결하는 데 도움을주십시오.

+0

http://sscce.org/ –

답변

0

마지막으로 이렇게 많은 방법을 시도한 후, 나는 많은 쉬운 단계입니다 최고의 솔루션에 도달한다. 동일한 인스턴스에서 두 가지 작은 변경 사항 만 필요합니다. 스 니펫 :

.... 

       if($record_find=='first') 
//{ $record_find="second";continue;} // Removed this line 
     $i=1; 
       foreach($e->find('tr') as $e1){ 
        if($i<3){$i++;continue;} //made changes here as suggested by @legiero. 
           $some=trim($e1->find('td', 0)->innertext); 
........ 
0

첫 3 행은

if($i<3){$i++;continue;} 

$i=1; 
if($i<4){$i++;continue;} 

변경에 의해 건너 뛰고 당신은 당신이 필요로하는 또 하나 개의 행을 얻을.

+0

이 문제는 여전히 동일한 문제가 발생했습니다. 또한 나는이 코드를 제거하려고 시도했다 "{$ record_find ="second; "계속;}"다음 나는 또한 같은 문제에 붙어 .. 제발 도와주세요 @legiero –

관련 문제