jae-jae / QueryList

:spider: The progressive PHP crawler framework! 优雅的渐进式PHP采集框架。
https://querylist.cc
2.65k stars 440 forks source link

例子与预期不符 #130

Closed Ciroygo closed 3 years ago

Ciroygo commented 3 years ago

文档地址:http://www.querylist.cc/docs/guide/v4/processing-data

软件版本:v4.2.7

原文:

例子 采集所有图片链接,采集目标:

$html =<<<STR
    <div class="xx">
        <img data-src="/path/to/1.jpg" alt="">
    </div>
    <div class="xx">
        <img data-src="/path/to/2.jpg" alt="">
    </div>
    <div class="xx">
        <img data-src="/path/to/3.jpg" alt="">
    </div>
STR;

采集代码:

 $data = QueryList::html($html)->rules(array(
        'image' => array('.xx>img','data-src')
    ))->query()->getData(function($item){
        return $item;
    });
print_r($data->all());

采集预期结果:

Array
(
    [0] => Array
        (
            [image] => /path/to/1.jpg
        )
    [1] => Array
        (
            [image] => /path/to/2.jpg
        )
    [2] => Array
        (
            [image] => /path/to/3.jpg
        )
)

采集实际结果:

Array
(
    [image] => /path/to/1.jpg
)
jae-jae commented 3 years ago

文档例子已修复,感谢提醒

Ciroy notifications@github.com 于2021年1月5日周二 下午5:47写道:

文档地址:http://www.querylist.cc/docs/guide/v4/processing-data 软件版本:v4.2.7 原文:

例子 采集所有图片链接,采集目标:

$html =<<<STR

<div class="xx">

    <img data-src="/path/to/1.jpg" alt="">

</div>

<div class="xx">

    <img data-src="/path/to/2.jpg" alt="">

</div>

<div class="xx">

    <img data-src="/path/to/3.jpg" alt="">

</div>

STR;

采集代码:

$data = QueryList::html($html)->rules(array(

    'image' => array('.xx>img','data-src')

))->query()->getData(function($item){

    return $item;

});

print_r($data->all());

采集预期结果:

Array

(

[0] => Array

    (

        [image] => /path/to/1.jpg

    )

[1] => Array

    (

        [image] => /path/to/2.jpg

    )

[2] => Array

    (

        [image] => /path/to/3.jpg

    )

)

采集实际结果:

Array

(

[image] => /path/to/1.jpg

)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jae-jae/QueryList/issues/130, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABK4FTO4OIF7QC3FYX4OA43SYLN43ANCNFSM4VUXJHZQ .