$doc = new DOMDocument();
$doc->loadHTML($source);
$xpath = new DOMXpath($doc);
//$rowxpath = $post->xpath;
$rowxpath = '//*[@class="s-lg-az-result s-lg-az-result-new"]';
$elementsn = $xpath->query($rowxpath);
在上面,$ elementsn-> length不为0。但是当
$rowxpath = '//*[@class="s-lg-az-result"] | //*[@class="s-lg-az-result s-lg-az-result-new"]';
它始终为0。当| | |时,该路径似乎不起作用。使用字符。
为什么会出现,我该如何解决?
注意:有关我用于$ source的信息,请参见https://can-la.com/samplesforstackexc/test3.html。
还请注意:如果您要使用file_get_contents('https://can-la.com/samplesforstackexc/test3.html');这会产生一些与SSL相关的错误:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /Users/user/HoldingForDO/libTOdatabases/index.php on line 48
Warning: file_get_contents(): Failed to enable crypto in /Users/user/HoldingForDO/libTOdatabases/index.php on line 48
Warning: file_get_contents(https://can-la.com/samplesforstackexc/test3.html): failed to open stream: operation failed in /Users/user/HoldingForDO/libTOdatabases/index.php on line 48
但是,这不是问题,因为我仅将此文件上传到can-la.com作为该问题的样本。即使您直接下载文件和file_get_contents('test3.html'),问题仍然存在。