php querylist,ThinkPHP中使用QueryList3
注:本文是基于ThinkPHP3.2.3進行講解
方法一:通過composer自動安裝
直接在ThinkPHP根目錄執行命令:composer?require?jaeger/querylist
就安裝好了QueryList了,然后在index.php中引入composer的自動加載文件:<?php
//?應用入口文件
//........
//加上下面這一句話,用于自動加載QueryList
require?'vendor/autoload.php';
//?引入ThinkPHP入口文件
require?'./ThinkPHP/ThinkPHP.php';
//?親^_^?后面不需要任何代碼了?就是如此簡單
只需這兩步就可以在你的框架中任意使用QueryList了:<?php
namespace?Home\Controller;
use?Think\Controller;
use?QL\QueryList;
class?IndexController?extends?Controller?{
public?function?index(){
//采集某頁面所有的圖片
$data?=?QueryList::Query('http://cms.querylist.cc/bizhi/453.html',['image'?=>?['img','src']])->data;
//打印結果
print_r($data);
}
}
thinkphp3.2.3集成QueryList3和所有插件打包
打包下載:http://source.querylist.cc/Querylist-demo/thinkphp3.2.3_QueryList3_full.zip
方法二:手動安裝
1.下載
QueryList下載地址:https://github.com/jae-jae/QueryList
phpQuery下載地址:https://github.com/jae-jae/phpQuery-single
2.安裝
根據TP官方教程:http://document.thinkphp.cn/manual_3_2.html#lib_extend假設你的網站根目錄為 www
先列出安裝好后的目錄結構:www
└──?ThinkPHP
├──?Library
│???├──?QL
│???│???├──?phpQuery.php
│???│???└──?QueryList.class.php安裝過程:
1.下載`QueryList.php`和`phpQuery.php`這兩個文件。
2.在` www/ThinkPHP/Library`下新建`QL`目錄。
3.將下載好的`QueryList.php`和`phpQuery.php`這兩個文件復制到` www/ThinkPHP/Library/QL`目錄。
4.重命名`QueryList.php`為`QueryList.class.php`。
然后就可以在你的框架中任意使用QueryList了,但是運行你會發現提示沒有找到phpQuery,此時有兩個解決方案:
方案一:在每次使用QueryList之前手動引入phpQuery
方案二:修改QueryList源碼,加上下面這句話:require?'phpQuery.php';
這樣就不用每次手動引入phpQuery了
3.用例<?php
namespace?Home\Controller;
use?Think\Controller;
use?QL\QueryList;
class?IndexController?extends?Controller?{
public?function?index(){
//采集某頁面所有的超鏈接
$data?=?QueryList::Query('http://cms.querylist.cc/bizhi/453.html',['link'?=>?['a','href']])->data;
//打印結果
print_r($data);
}
}
4.附上ThinkPHP手動安裝好QueryList的壓縮包
看完教程依舊不懂的話,可以下載我打包好的壓縮包,解壓看看:
下載地址:http://source.querylist.cc/Querylist-demo/thinkphp3.2.3_QueryList3_custom.zip
總結
以上是生活随笔為你收集整理的php querylist,ThinkPHP中使用QueryList3的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: “京台高铁”亮相百度地图,真能在2035
- 下一篇: otrs安装mysql_otrs安装配置
