Mar*_*jes 8 php html-parsing fatal-error simple-html-dom
我正在尝试解析一个HTML文件,该文件具有可怕的(相信我,它是)HTML结构,由于这个和我缺乏知识,我无法编写自己的解析器.后来我尝试使用Simple HTML Dom解析器,因为很多人(也在SO上)推荐它.
我需要simple_html_dom.php,然后创建了对象.它们似乎工作,require()函数返回"1"和var_dump() - 对象返回一个对象.
在此之后,我尝试加载URL,就像在手册中一样,但是无论我尝试了什么URL,我都会遇到致命的错误.错误如下:
Fatal error: Call to undefined function mb_detect_encoding() in 
             /home/fema/web/subdomain/devel/www_root/parser/
             simplehtmldom_1_5/simple_html_dom.php on line 988
我检查了988号线上的内容,它是以下内容:
// Have php try to detect the encoding from the text given to us.
        $charset = mb_detect_encoding($this->root->plaintext . "ascii", 
                   $encoding_list = array( "UTF-8", "CP1252" ) );
我知道这是关于字符编码的,但这就是全部.我还没有发现谷歌或SO上的任何相关信息.
我的整个代码是(占位符网址):
<?php
require('simplehtmldom_1_5/simple_html_dom.php');
// Create a DOM object
$dom = new simple_html_dom();
$dom->load_file('http://www.google.com/');
?>
有人可以告诉我该怎么办?或者在发生类似这样的事情时给出某种建议.
提前致谢.
我使用Amazon EC2和标准的PHP安装时遇到了同样的问题.我做了以下(在http://php.net/manual/en/mbstring.installation.php上找到)解决了这个问题:
yum install php-mbstring httpd -k restart
| 归档时间: | 
 | 
| 查看次数: | 6979 次 | 
| 最近记录: |