对第13行D:\xampp\htdocs\simplehtmldom\index.php中的非对象调用成员函数find()

对第13行D:\xampp\htdocs\simplehtmldom\index.php中的非对象调用成员函数find(),php,parsing,web-scraping,Php,Parsing,Web Scraping,我想从另一个站点提取数据,以便根据我站点中的该站点数据进行更新,但代码和我的代码中显示的上述错误如下:- include('simplehtmldom/simple_html_dom.php'); $html = new simple_html_dom(); $html->load_file("http://www.nepalstock.com/companydetail.php"); $table = $html->find('table[width="386"]'); $i

我想从另一个站点提取数据,以便根据我站点中的该站点数据进行更新,但代码和我的代码中显示的上述错误如下:-

include('simplehtmldom/simple_html_dom.php');
$html = new simple_html_dom();

$html->load_file("http://www.nepalstock.com/companydetail.php");

$table = $html->find('table[width="386"]');

$i = 0;
$data = array();
foreach ($table[0]->find('tr') as $tr) {<!--this is my line 13-->
$i++;
 if ($i == 1 || $i == 2) continue;
$td = $tr->find('td');
array_push($data, array(
'listed_share' => trim($td[0]->plaintext),
'paid_up_value' => trim($td[1]->plaintext),
'total_paid_Up_Value' => trim($td[2]->plaintext),
'closing_market_price' => trim($td[3]->plaintext),
  ));
}
 $html->clear();
unset($html);

if (empty($data)) exit('No data !!!');
print '<pre>';
print_r($data);
print '</pre>';

此错误通常发生在您使用实际不存在的对象时。尝试按以下方式更改代码,并记住在处理外来内容时特别要保留此编码行为:


在代码中使用了三次查找函数。请你告诉我它在哪一行给出了错误??你到底在找什么内容?我会评论我错误出现的那一行。尼泊尔证券交易所data@paucha我的意思是,具体内容是什么?内幕市场信息?
 if (!empty($html){
     $table = $html->find('table[width="386"]');
     if(!empty($table)){
         ...