dongmei3498 2019-03-03 08:25
浏览 60

PHP 7的路径 - 使用“|”字符

    $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);

In the above, $elementsn->length is not 0. But when

$rowxpath = '//*[@class="s-lg-az-result"] | //*[@class="s-lg-az-result s-lg-az-result-new"]'; 

it's always 0. The path doesn't seem to work when the | character is used.

How come, and how can I solve this?

NOTE: for what I used for $source, please see https://can-la.com/samplesforstackexc/test3.html.

Also note: if you are going to file_get_contents('https://can-la.com/samplesforstackexc/test3.html'); this would produce some errors related to 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

However, this is not the issue, as I am only uploading this file to can-la.com to serve as a sample for this question. Even if u download the file and file_get_contents('test3.html') directly, the problem still arises.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下stata17中这段代码哪里有问题呀
    • ¥15 flink cdc无法实时同步mysql数据
    • ¥100 有人会搭建GPT-J-6B框架吗?有偿
    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决