【发布时间】:2012-03-28 06:42:22
【问题描述】:
我一直在尝试使用不同的工具解析this 站点的底部表格。
到目前为止,我使用 Simple HTML Dom 库取得了最大的成功,但我仍然无法弄清楚如何仅解析最后一个表。
到目前为止,我的代码大致如下:
<?php
require('simple_html_dom.php');
$table = array();
$html = file_get_html('http://www.waterlevels.gc.ca/cgi-bin/tide-shc.cgi?zone=20®ion=1& language=english&station=9635&queryType=predict&year=2012&month=2&day=9&view=table&TZ=PST');
foreach($html->find('tr') as $row)
{
//confused as what to do there to parse only last table in given URL
}
echo '<pre>';
print_r($table);
echo '</pre>';
?>
如果有人对如何让库只解析最后一个表有任何建议,我们将不胜感激。
谢谢
【问题讨论】:
标签: php html parsing dom simple-html-dom