Zend Framework 2 KpGrab 模块

  • 发布时间 2015-02-09
  • 分类 php

KpGrab是一个基于Zend Framweork 2模块,主要功能是抓取整站静态页面

2.安装

github下载 或者 composer require "kittencup/kp-grab": "dev-master"

#application.config.php
return [
    'modules' => [
        // ...
        'KpGrab',
    ],
];

3.使用

php public/index.php grab site <url> [--save-dir=] [--save-name=]

例子

php public/index.php grab site http://admindesigns.com/framework/dashboard.html  --save-dir=/Users/Kittencup/WebServer/zf2/data --save-name=admindesigns

4.配置

具体的配置内容在KpGrab/config/module.config.php内,使用kp_grab键值

例子

'kp_grab' => [
        'http_adapter' => 'Zend\Http\Client\Adapter\Curl',
        'http_adapter_options' => [
            'curloptions' => [
                CURLOPT_ENCODING => 'gzip',
                CURLOPT_FOLLOWLOCATION => false,
                CURLOPT_TIMEOUT => 20,
                CURLOPT_NOSIGNAL => 1
            ]
        ],
        'console_error_message_color' => \Zend\Console\ColorInterface::RED,
        'show_message' => true,
        'max_reconnection_count' => 5,
        'xdebug_max_nesting_level' => 600,
        'default_save_dir' => realpath(__DIR__ . '/../data'),
        'grab_allow_page_suffix' => ['html'],
        'grab_allow_static_suffix' => ['png', 'jpeg', 'jpg', 'gif', 'css', 'js', 'woff', 'ttf', 'eot', 'svg'],
        'output_error' => true,
        'output_error_filename' => 'error.md'
    ]