发现问题
在做爬虫的时候,用了QueryList,在运行的过程中查看日志,出现很多关于phpQuery单文件的error报错,问题是出在html非标准化格式
[ error ] [2]DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 1262[/home/querying/PhpstormProjects/xianlang10.com/EngineSeo/vendor/jaeger/phpquery-single/phpQuery.php:328][ error ] [2]DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 1262[/home/querying/PhpstormProjects/xianlang10.com/EngineSeo/vendor/jaeger/phpquery-single/phpQuery.php:328]
解决问题
在查看
php手册
关于DOMDocument
类loadHTML
方法的使用的时候,发现libxml_use_internal_errors
可以对此类错误,强制以libxml_get_errors()
进行获取,该函数返回内容一个迭代器
load('file.html')) { foreach (libxml_get_errors() as $error) { // handle errors here } libxml_clear_errors(); }?>