在使用Composer管理的项目中安装
如果项目框架本身就是使用Composer来管理包的话,直接在项目根目录执行Composer安装命令后,即可在项目控制器中调用QueryList来使用,这种框架有:
Laravel、ThinkPHP5等。
在项目根目录执行composer命令安装QueryList:
composer require jaeger/querylist
然后就可以在控制器中使用QueryList了:
<?php
namespace app\index\controller;
use QL\QueryList;
class Index
{public function index(){//DOM解析某页面所有的图片$data = QueryList::get('http://cms.querylist.cc/bizhi/453.html')->find('img')->attrs('src');//打印结果print_r($data->all());}
}