-1
所以我只是试图用PHP刮掉一个HTML页面。我在Google上查看了如何操作,并且我使用了file_get_contents()
方法。我写的代码一点点,但我已经收到,我想不通的错误:PHP刮掉一个html页面
$page = file_get_contents('http://php.net/supported-versions.php');
$doc = new DOMDocument($page);
//print_r($page);
foreach ($doc->getElementsByTagName('table') as $node) {
print_r($node);
}
第一,注释掉的print_r声明可以打印页面,但foreach循环应该会得到每个表$节点但它没有打印任何东西。我究竟做错了什么?
我的建议是使用Simple HTML Dom Parser; http://simplehtmldom.sourceforge.net/ – Kaylined
为什么你试图将javascript与javascript混合 –
我在写一个WordPress插件 – brothman