亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

QueryList Collector-Entwicklungshandbuch / ThinkPHP中使用QueryList3

ThinkPHP中使用QueryList3

注:本文是基于ThinkPHP3.2.3進行講解

方法一:通過composer自動安裝

    直接在ThinkPHP根目錄執(zhí)行命令:

     composer require jaeger/querylist

    就安裝好了QueryList了,然后在index.php中引入composer的自動加載文件:

    <?php
    // 應(yīng)用入口文件
    //........
    //加上下面這一句話,用于自動加載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;
            //打印結(jié)果
            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.安裝

    根據(jù)TP官方教程:http://document.thinkphp.cn/manual_3_2.html#lib_extend

    假設(shè)你的網(wǎng)站根目錄為 www

    先列出安裝好后的目錄結(jié)構(gòu):

    www
    └── ThinkPHP
        ├── Library
        │   ├── QL
        │   │   ├── phpQuery.php
        │   │   └── QueryList.class.php
    安裝過程:
    1.下載`QueryList.php`和`phpQuery.php`這兩個文件。
    2.在` www/ThinkPHP/Library`下新建`QL`目錄。
    3.將下載好的`QueryList.php`和`phpQuery.php`這兩個文件復(fù)制到` www/ThinkPHP/Library/QL`目錄。
    4.重命名`QueryList.php`為`QueryList.class.php`。

    然后就可以在你的框架中任意使用QueryList了,但是運行你會發(fā)現(xiàn)提示沒有找到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;
            //打印結(jié)果
            print_r($data);
        }
    }

    4.附上ThinkPHP手動安裝好QueryList的壓縮包

    看完教程依舊不懂的話,可以下載我打包好的壓縮包,解壓看看:
    下載地址:http://source.querylist.cc/Querylist-demo/thinkphp3.2.3_QueryList3_custom.zip