테스트 사이트 - 개발 중인 베타 버전입니다

simple_html_dom.php 를 이용한 크롤링

조강 4년 전 조회 11,101

simple_html_dom.php 를 크롤링을 하려고하는데요
#소스시작
 <table id="list_tabl" class="chart">
 <thead>
  <tr>
  <th rowspan="2">번호</th>
  <th rowspan="2">금액</th>
  </tr>
  </thead>
  <tbody id="list_body">
        <tr>
            <td class="round">
                11 <strong>22</strong>
            </td>
            <td class="sums">33<b>44</b></td>
        </tr>
  </tbody>
</table>
소스끝#
$urls = 소스
$data = file_get_html($urls);
$table = $data->find("#list_tabl");
foreach($table as $td){
      echo $td->plaintext;
}
이렇게 하니 항목(번호,금액)만 나옵니다.
제가원하는 것은
<td class="round">의  1122 값과
<td class="sums">의  33<b>44 입니다.
어떻게 해야 할까요? 고수님들의 조언부탁드립니다.
 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

세크티
4년 전

$data = file_get_html($urls);
$table = $data->find("#list_tabl tbody tr");
foreach($table as $tr){
      echo $tr->find(".round",0)->plaintext;

      echo $tr->find(".sums",0)->plaintext;
}

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인