0
두 개의 특정 html 테이블에서 필요한 모든 데이터를 얻는 데 문제가 있습니다. 이 게시물 하단의 표.테이블 내의 모든 데이터 스크래핑 문제
위의 코드는 html 테이블 ID "table1"을 나타냅니다. 또한 정확한 형식으로 "table2"라는 테이블에서 값을 가져와야합니다. 이 코드를 시도했지만 td 값을 추출 할 수는 있지만 td 내의 범위 지정자 내에있는 값은 거의 없습니다. 나는 이것을하기 위해 여러 가지 방법을 시도했지만, 나는 그것을 얻지 못하고있다.
$dom = file_get_html("internets.html);
//not sure how to specify the table exactly!? because this code didn't work.
//$tds = $dom->find('table[id=table1]',0)->find('tr');
foreach($dom->find('tr') as $key => $tr)
{
$td = $tr->find('td');
echo $td[0]->innertext . "</br>";
}
어떤 도움이 많이 감사 : 내 코드를 같이 보입니다. 나는 여기에서 검색을 한 적이 있고 또한 간단한 PHP DOM 매뉴얼을 사용했다.
<table id="table1">
<tbody>
<tr>
<th width="48%" scope="row">
Prev Close:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Open:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Bid:
</th>
<td class="yfnc_tabledata1">
<span id="yfs_b00_pgo.ax">
0.0180
</span>
</td>
</tr>
<tr>
<th width="48%" scope="row"></th>
<td class="yfnc_tabledata1"></td>
</tr>
<tr>
<th width="48%" scope="row">
1y Target Est:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="48%" scope="row">
Beta:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="54%" scope="row">
Next Earnings Date:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
</tbody>
</table>