Closed arnbunchen closed 5 months ago
选择器留空,表示自己,例子:
<?php
require 'querylist/vendor/autoload.php';
use QL\QueryList;
$html =<<<STR
<div>
<a href="http://xxx.com/1.html" alt="link1">
链接1
<span>文本1<span>
</a>
<a href="http://xxx.com/2.html" alt="link2">
链接2
<span>文本2<span>
</a>
<a href="http://xxx.com/3.html" alt="link3">
链接3
<span>文本3<span>
</a>
</div>
STR;
$data = QueryList::html($html)->rules([
'a_link' => ['','href'],
'a_text' => ['', 'text','-span'],
'a_alt' => ['', 'alt'],
'span' => ['span', 'text']
])->range('a')->queryData();
print_r($data);
/**
输出结果:
Array
(
[0] => Array
(
[a_link] => http://xxx.com/1.html
[a_text] => 链接1
[a_alt] => link1
[span] => 文本1
)
[1] => Array
(
[a_link] => http://xxx.com/2.html
[a_text] => 链接2
[a_alt] => link2
[span] => 文本2
)
[2] => Array
(
[a_link] => http://xxx.com/3.html
[a_text] => 链接3
[a_alt] => link3
[span] => 文本3
)
)
**/
这个列表 我使用了 range 获取列表,便我想获取 这个div本身的 shopid 我该怎么操作?请大神位指定一二。