o2o-capture

0.1.8 • Public • Published

o2o-capture —— online page to offline assets

给线上页面拍照并『复印』到本地。

安装

支持命令行方式和 lib 方式调用。

  1. 安装到全局:

    npm i -g o2o-capture
    
  2. 安装为依赖包:

    npm i o2o-capture --save
    
  3. o2o-capture 的依赖

o2o-capture 依赖 phantomjscasperjsawpp@0.4.1+,运行时会自动安装:

npm install -g phantomjs casperjs awpp@latest

使用方法

  1. 命令行方式:

    o2oc -u http://h5.m.taobao.com/market/trip/act/xfzlh5.html -d ./codes

    其中:

    • -u: 指定线上 url;
    • -d: 指定保存到本地的目录

    更多配置项:

    o2o ➤ o2oc --help
     
      Usage: o2oc [options]
      
      Options:
     
        -h, --help             output usage information
        -V, --version          output the version number
        -u, --url <url>        线上页面 url
        -d, --dir <path>       本地目标目录,默认当前工作目录
        -p, --pageDir <path>   页面存放目录,默认 `pages`
        -n, --pageName <name>  页面名,默认从 url 截取
        -i, --imgDir <path>    图片存放目录,默认 `img`
        -j, --jsDir <path>     js 存放目录,默认 `js`
        -c, --cssDir <path>    css 存放目录,默认 `css`
        -e, --pageExt <path>   页面后缀名,默认 `html`
        -h, --handleCss        是否处理 css 中的图片引用
        -r, --removeComment    是否移除页面中的注释,默认 `true`
        -a, --aplusHack        是否 hack 处理 aplus 埋点,默认 `false`
        -w, --waitPageLoadTime <number> 等待页面加载时间(秒),默认 `5`
        -o, --override         是否覆盖目标路径已有页面
  2. lib 方式调用:

    var o2o = require('o2o-capture');
    o2o('http://h5.m.taobao.com/market/trip/act/xfzlh5.html', {
        dir: './test',            // 加载到本地目录
        pageName: 'xfzlh5',       // 页面名
        pageDir: 'pages',         // 页面存放目录
        pageExt: 'html',          // 页面后缀
        jsDir: 'js',              // js 存放目录
        cssDir: 'css',            // css 存放目录
        handleCss: false,         // 是否处理 css 中的图片路径
        removeComment: true,      // 是否移除页面中的注释
        aplusHack: true,          // 是否 hack 处理 aplus 埋点
        waitPageLoadTime: 10,     // 等待页面加载时间
        ignoreAssets: [],         // 需要忽略处理的资源路径
        preserveSelectors: [],    // DOM 中需要保留为源码的 DOM 节点 selector
        removeSelectors: [],      // DOM 中需要移除的源码的 DOM 节点 selector
        userAgentMap: {},         // userAgent 映射表,对 PC 和无线页面区分
        override: true            // 是否覆盖之前生成的页面
    }/*, console*/);

版本历史

  • [0.1.0-0.1.3]
    • init version
  • [0.1.4]
    • Bufix for awpp path
  • [0.1.6]
    • 修复 url 后缀与 pageExt 不一致时,保存两份不同后缀的文件
  • [0.1.7]
    • 加入 options.preserveSelectorsoptions.removeSelectorsoptions.userAgentMapoptions.override 等配置项
  • [0.1.8]
    • fix for request 302 https redirect.

Readme

Keywords

none

Package Sidebar

Install

npm i o2o-capture

Weekly Downloads

0

Version

0.1.8

License

MIT

Last publish

Collaborators

  • dickeylth