使用"simple html parser"拉取表数据



嘿,伙计们正试图从网站上获取表格信息。我一直在关注其他类似问题的回复,但似乎无法让它为有问题的网站工作。我正试图提取";Ex Date Record Date Pay Date Declared Date Type Amount;这是我目前正在尝试的代码,谢谢你的帮助!

<?php
require_once('libs/simple_html_dom.php');
$html = file_get_html('https://ycharts.com/companies/WFC/dividend');
$table = $html->find('div[id=dataTableBox] table', 1);
$data = array();
foreach($table->find('tr') as $row) {
$rowData = array();
foreach($row->find('td') as $cell) {
// push the cell's text to the array
$rowData[] = $cell->innertext;
}
$data[] = $rowData;
}
echo '<pre>';
print_r($data);
echo '</pre>';

?>

您必须使用class"histDispidendDataTable";下面,所以试试:

$table = $html->find('table.histDividendDataTable',0);

最新更新