1)安装composer
参照该文档安装composer https://pkg.phpcomposer.com/
2)安装完后进入tp框架的根目录下,在根目录下的composer.json文件中的require中加入QueyListy和扩展如下
"jaeger/querylist": "^3.2",
"jaeger/querylist-ext-request":"^1.0",
"jaeger/querylist-ext-multi":"^1.0",
"jaeger/querylist-ext-login":"^1.0"
{
"name": "topthink/think",
"description": "the new thinkphp framework",
"type": "project",
"keywords": [
"framework",
"thinkphp",
"ORM"
],
"homepage": "http://thinkphp.cn/",
"license": "Apache-2.0",
"authors": [
{
"name": "liu21st",
"email": "liu21st@gmail.com"
}
],
"require": {
"php": ">=5.4.0",
"topthink/framework": "^5.0",
"jaeger/querylist": "^3.2",
"jaeger/querylist-ext-request":"^1.0",
"jaeger/querylist-ext-multi":"^1.0",
"jaeger/querylist-ext-login":"^1.0"
},
"extra": {
"think-path": "thinkphp"
},
"config": {
"preferred-install": "dist"
}
}
安装 composer require jaeger/querylist
更新 composer update jaeger/querylist
4)引入并测试
<?php
namespace app\index\controller;
use QL\QueryList;
class Index
{
public function index()
{
//采集某页面所有的图片
$data = QueryList::Query('http://cms.querylist.cc/bizhi/453.html',['image' => ['img','src']])->data;
//打印结果
print_r($data);
}
}