php之数据采集

1.利用Composer安装

composer require jaeger/querylist
命名空间引入:use QL\QueryList;
$url = 'https://www.php1314.cn/';
// 定义采集规则
$rules = [
    // 采集文章
    'title' => ['strong','html'],
    // 'head'=>['.entry-content','html'],
    // 'num'=>['.thumbnail-wrap>img','src']
];
$rt = QueryList::get($url)->rules($rules)->queryData();
       $this->assign('ok',$rt);
        return $this->fetch();

更高级操作 :http://www.querylist.cc/docs/guide/v4/installation

为您推荐