资源说明:WebPageTest API wrapper for NodeJS
Learn about more WebPageTest API Integrations in our docs
# WebPageTest API Wrapper for NodeJS [](https://travis-ci.com/WebPageTest/webpagetest-api) [](https://www.npmjs.org/package/webpagetest) [](https://www.npmjs.org/package/webpagetest) WebPageTest API Wrapper is a [NPM](https://npmjs.org) package that wraps [WebPageTest](https://github.com/WPO-Foundation/webpagetest) API for [NodeJS](https://nodejs.org) as a module and a command-line tool. ## Getting started ```bash $ npm install webpagetest -g ``` ## Basics ### Command line ```bash $ webpagetest test https://docs.webpagetest.org/api/integrations/ ``` ### Docker #### Build ```bash $ docker build -t webpagetest-api . ``` #### Run ```bash $ docker run -it --rm webpagetest-api -k YOURAPIKEY test https://docs.webpagetest.org/api/integrations/ ``` ### Module ```javascript const WebPageTest = require("webpagetest"); const wpt = new WebPageTest("www.webpagetest.org"); wpt.runTest("https://docs.webpagetest.org/api/integrations/", (err, data) => { console.log(err || data); }); ``` ## Command Line ### Help ```bash $ webpagetest --help ``` ### Commands - **status** _[options] \_: check test status - **results** _[options] \ _: get test results - **locations** _[options]_: list locations and the number of pending tests - **testers** _[options]_: list testers status and details - **test** _[options] \ _: run test, _\ _ can also be a path to a script file - **testAndWait** _[options] \ _: run test and waits for the result, _\ _ can also be a path to a script file - **testBalance** _[options]_: get remaining tests for the account - **restart** _\ _: restart test - **cancel** _\ _: cancel running/pending test - **har** _\ _: get the HTTP Archive (HAR) from test - **pagespeed** _[options] \ _: get the Google Page Speed results (if available) from test - **utilization** _[options] \ _: get the CPU, bandwidth and memory utilization data from test - **request** _[options] <\id\>_: get the request data from test - **timeline** _[options] \ _: get the Chrome Developer Tools Timeline data (if available) from test - **netlog** _[options] \ _: get the Chrome Developer Tools Net log data (if available) from test - **chrometrace** _[options] \ _: get the Chrome Trace data (if available) from test - **console** _[options] \ _: get the browser console log data (if available) from test - **testinfo** _\ _: get test request info/details - **history** _[days]_: get history of previously run tests - **googlecsi** _[options] \ _: get Google CSI data (Client Side Instrumentation) - **response** _[options] \ _: get response body for text resources - **waterfall** _[options] \ _: get the waterfall PNG image - **screenshot** _[options] \ _: get the fully loaded page screenshot in JPG format (PNG if in full resolution) - **video** _[options] \ _: create a video from _\ _ (comma separated test ids) - **player** _\ _: get a html5 player for a video _\ _ - **listen** _[options]_ _[port]_: start webpagetest-api server on port _[7791_] - **batch** _\ _: run commands in batch, i.e. one command per line from _\ _ in parallel ### Options #### Common (works for all commands) - **-s, --server** _\ _: the WPT server URL [https://www.webpagetest.org] - **-d, --dryrun**: just return the RESTful API URL - **-o, --out** _\ _: place the output into \ . Defaults to stdout _The default WPT server can also be specified via environment variable `WEBPAGETEST_SERVER`_ #### Test (works for **test** command only) - **-l, --location** _\ _: location to test from - **-y, --connectivity** _\ _: connectivity profile -- requires location to be specified -- (Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom) [Cable] - **-r, --runs** _\ _: number of test runs [1] - **-f, --first**: skip the Repeat View test - **-v, --video**: capture video - **-p, --private**: keep the test hidden from the test log - **-L, --label** _\
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。