2014-12-14 1 views
-1

다음은 일부 데이터를 다듬는 데 필요한 표의 스키마입니다. html dom 파서를 사용하고 있습니다. 방금 작성한 스크립트로 각 테이블 데이터에서 데이터를 검색 할 수 있지만 두 번째 및 세 번째 즉, proxyip 및 proxyport에서 데이터를 가져와 'proxyip : proxyport'형식으로 나열하는 방법을 파악할 수 없습니다.간단한 html dom 파서로 특정 테이블 데이터 검색

<table> 
<tbody> 
<tr> 
    <td> 
     data 
    </td> 

    <td> 
     <span> 
      proxyip 
     </span> 
    </td> 

    <td>poxyport</td> 

    <td>data</td> 

    <td>data</td> 

    <td>data</td> 
</tr> 
</tbody> 
</table> 

내 스크립트

include('simple_html_dom.php'); 

$html = file_get_html('http://domain.com/'); 


foreach($html->find('tr') as $e) 
{ 
    foreach($e->find('td') as $d) 
    { 
    echo $d->innertext . '<br>'; 
    } 
} 

답변

0

 $table =$html->find('table',0) ; // Getting the table from scraped HTML content 

//For each row, echo 2nd and 3rd td 

    foreach($table->find('tr') as $key=>$value) { 
     echo trim(strip_tags($value->find('td',1)->plaintext)).":".trim(strip_tags($value->find('td',2)->plaintext)); 

     } 
같은 시도