获取<;表>;外部页面中的元素作为htmltext


Get <table> element from external page as htmltext

我正试图使用Simple Html-Dom从外部页面中以明文的形式获取元素。

<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
include('simple_html_dom.php');  
$html = new simple_html_dom();
// Create DOM from URL or file
$html = file_get_html('http://www.vedora.sk/obchodnici/index.php');
$myContent = $html->find('table')->plaintext;
echo $myContent;
$html->clear();  
    unset($html);  
?>

只有一个。如果我运行代码,我会得到错误:

注意:试图在第12行的/var/www/tmp.php中获取非对象的属性

编辑:有什么方法可以得到html(原样)吗?

非常确定$html->find('table')返回一个元素数组,即使只有一个。如果只想找到一个元素,可以使用$html->find('table', 0)(0表示索引0)。

http://simplehtmldom.sourceforge.net/manual.htm