PHP 高级 HTMLDOM 错误

PHP Advanced HTMLDOM error

我让 php AdvancedHTMLDOM 长时间正常工作。然而,大约一周前,我注意到我正在抓取的数据由于某种原因没有更新。

我手动 运行 脚本并得到以下错误:

root@telemetry:/home/telemetry/scripts/pressure# php -f get_pressure_nodes.php                                                                  
PHP Fatal error:  Uncaught Error: Class 'DOMDocument' not found in /home/telemetry/scripts/pressure/advanced_html_dom-master/advanced_html_dom.php:171
Stack trace:
#0 /home/telemetry/scripts/pressure/advanced_html_dom-master/advanced_html_dom.php(167): AdvancedHtmlDom->load('<html>\n<head>\n<...', false)
#1 /home/telemetry/scripts/pressure/advanced_html_dom-master/advanced_html_dom.php(747): AdvancedHtmlDom->__construct('<html>\n<head>\n<...')
#2 /home/telemetry/scripts/pressure/advanced_html_dom-master/advanced_html_dom.php(748): str_get_html('<html>\n<head>\n<...')
#3 /home/telemetry/scripts/pressure/get_pressure_nodes.php(17): file_get_html('get_pressure_no...')
#4 {main}
  thrown in /home/telemetry/scripts/pressure/advanced_html_dom-master/advanced_html_dom.php on line 171
root@telemetry:/home/telemetry/scripts/pressure#

这是我的脚本(为了简单起见,我保留了基础知识,而且我从某个我不记得的地方得到了这段代码,所以如果是你的,请通知我,这样我就可以在它到期的地方给予信任):

<?php

require('advanced_html_dom-master/advanced_html_dom.php');
$html = file_get_html('get_pressure_nodes.html');
$table = $html->find('table', 1);

$rowData = array();

foreach($table->find('tr') as $row)
{
    // initialize array to store the cell data from each row
    $temp = array();

    foreach($row->find('td') as $cell)
    {
        // push the cell's text to the array
        $temp[] = $cell->plaintext;
    }

    $rowData[] = $temp;
}

foreach ( $rowData as $cell_contents )
{
    print ( $cell_contents ) ;
}
?>

如果 AdvancedHTMLDOM 突然停止工作, 可能有助于修复它。