【发布时间】:2019-12-18 11:43:32
【问题描述】:
<?php
include ("simpel_html_dom.php");
$dom = new \DOMDocument();
$dom->loadHTML('http://www.arbworld.net/en/moneyway');
$xpath = new \DomXPath($dom);
// query the first column with class "value" of the table with class "attributes"
$elements = $xpath->query('(/table[@class="grid"]//tr[@class="belowHeader"])');
// iterate through all found td elements
foreach ($elements as $element) {
echo $element->nodeValue;
}
?>
我想抓取 HTML 表格,但是当我运行代码时,结果将是一个空页面。 我该如何解决?
【问题讨论】:
-
除非我弄错了
simpel_html_dom.php拼写错误 - 我认为它应该是simple_html_dom.php~ 但是如果你使用DOMDocument和DOMXPath,为什么还要包含它?
标签: php html web-scraping