提问人:Igor P. 提问时间:10/27/2023 最后编辑:Igor P. 更新时间:10/27/2023 访问量:31
从 curl_multi_getcontent() 输入结果时,DOMDocument::loadHTML() 源不能为空错误
DOMDocument::loadHTML() Source must not be empty error when inputting result from curl_multi_getcontent()
问:
在 php 环境中使用 和 querypath,我正在查询多个网站,然后读取查询结果,这些结果应该都是 HTML 格式。我使用 .当使用结果作为 Querypath 的输入来手动解析结果时,我收到以下错误:curl_multi_init
curl_multi_getcontent()
DOMDocument::loadHTML(): Argument #1 ($source) must not be empty ...
这是我的代码:
[... running in a loop for every request]
$results = curl_multi_getcontent ($curl_arr[$i]);
$htmlString = (string) $results; //casting the result to string
//echo $htmlString; //gives me the correct html result!
//echo strlen($htmlString); //proves that string is not empty!?
$qp = QueryPath::withHTML($htmlString); //this line is causing the error
我不知道我可能错过了什么。有什么提示吗?
答:
0赞
Igor P.
10/27/2023
#1
看来我遇到了编码问题。一旦我换成$htmlString = (string) $results;
$htmlString = utf8_decode($results);
评论