1 | # @ice/screenshot
|
2 |
|
3 | Take a screenshot of a web page in the terminal.
|
4 |
|
5 | Options:
|
6 |
|
7 | ```
|
8 | -V, --version output the version number
|
9 | -u, --url <url> The target url or path to local server
|
10 | -l, --local [local] Set up a local server in [local] directory and take screenshot, defaults set up in `./`
|
11 | -s, --selector <selector> Select a element through CSS selector
|
12 | -o, --output <output> Output path
|
13 | -h, --help output usage information
|
14 | ```
|
15 |
|
16 | ## Usage
|
17 |
|
18 | Install:
|
19 |
|
20 | ```bash
|
21 | $ npm i -g @ice/screenshot
|
22 | ```
|
23 |
|
24 | For ICE materials, you can take screenshot use following commands:
|
25 |
|
26 | ```bash
|
27 | # for scaffold
|
28 | $ npm run build && screenshot -l
|
29 |
|
30 | # for block
|
31 | $ npm run build && screenshot -l -s \#mountNode
|
32 | ```
|
33 |
|
34 | Others:
|
35 |
|
36 | ```bash
|
37 | # take a screenshot of taobao.com
|
38 | $ screenshot -u https://www.taobao.com
|
39 |
|
40 | # take screenshot of a element
|
41 | $ screenshot -u https://www.taobao.com -s .service.J_Service
|
42 |
|
43 | # take screenshot export to ~/taobao.jpg
|
44 | $ screenshot -u https://www.taobao.com -o ~/taboa.jpg
|
45 |
|
46 | # Set up local server in current working directory and take screenshot of http://localhost:8100/public/index.html
|
47 | # By default, this will run the contents of current directory on a local server, the URL is http://localhost:8100
|
48 | $ screenshot -u /public/index.html -l
|
49 |
|
50 | # Set up local server in ./public directory and take screenshot of http://localhost:8100/index.html
|
51 | # By default, this will run the contents of `public/` directory on a local server, the URL is http://localhost:8100
|
52 | $ screenshot -u /index.html -l ./public
|
53 | ```
|
54 |
|
55 | ## Puppeteer
|
56 |
|
57 | The CLI based on [Puppeteer](https://github.com/GoogleChrome/puppeteer). But we don't want to depend on puppeteer locally, because puppeteer takes a long to install, it's easy to install failed. So we will find puppeteer in the local node_modules, if not found, find in the global node_modules, if still not found, we will install it globally, and you don't need to install it again next time.
|