PHP code example of hanxiaoqingcheng / querylist

1. Go to this page and download the library: Download hanxiaoqingcheng/querylist library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hanxiaoqingcheng / querylist example snippets


//获取采集对象
$hj = QueryList::Query('http://www.baidu.com/s?wd=QueryList',array(
        'title'=>array('h3','text'),
        'link'=>array('h3>a','href')
    ));
//输出结果:二维关联数组
print_r($hj->data);

QueryList::Query(采集的目标页面,采集规则[,区域选择器][,输出编码][,输入编码][,是否移除头部])
//采集规则
$rules = array(
   '规则名' => array('jQuery选择器','要采集的属性'[,"标签过滤列表"][,"回调函数"]),
   '规则名2' => array('jQuery选择器','要采集的属性'[,"标签过滤列表"][,"回调函数"]),
    ..........
    [,"callback"=>"全局回调函数"]
);

//注:方括号括起来的参数可选