@browserless/cli 10.10.2 → 10.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +0 -0
- package/README.md +13 -0
- package/package.json +6 -6
- package/src/commands/capture.js +24 -0
- package/src/index.js +7 -1
package/LICENSE.md
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ This package provides a **command-line interface** for interacting with browserl
|
|
|
30
30
|
The `@browserless/cli` package allows you to:
|
|
31
31
|
|
|
32
32
|
- **Take screenshots** from URLs with gradient backgrounds, browser overlays, and device emulation
|
|
33
|
+
- **Record captures** as video/audio using the `tabCapture` extension flow
|
|
33
34
|
- **Generate PDFs** from web pages
|
|
34
35
|
- **Extract content** as HTML or plain text
|
|
35
36
|
- **Run Lighthouse audits** for performance analysis
|
|
@@ -40,6 +41,7 @@ The `@browserless/cli` package allows you to:
|
|
|
40
41
|
|
|
41
42
|
| Command | Description |
|
|
42
43
|
|---------|-------------|
|
|
44
|
+
| `capture <url>` | Record a page and return video buffer (use `--path` to save file) |
|
|
43
45
|
| `screenshot <url>` | Capture a screenshot with optional overlay and background |
|
|
44
46
|
| `pdf <url>` | Generate a PDF document from a web page |
|
|
45
47
|
| `html <url>` | Serialize the page content to HTML |
|
|
@@ -50,6 +52,16 @@ The `@browserless/cli` package allows you to:
|
|
|
50
52
|
| `status <url>` | Get the HTTP status code |
|
|
51
53
|
| `goto <url>` | Navigate to a URL and return page/response info |
|
|
52
54
|
|
|
55
|
+
### Capture examples
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
# webm (default)
|
|
59
|
+
browserless capture https://example.com --path=./capture.webm
|
|
60
|
+
|
|
61
|
+
# mp4 using friendly output type
|
|
62
|
+
browserless capture https://example.com --type=mp4 --path=./capture.mp4
|
|
63
|
+
```
|
|
64
|
+
|
|
53
65
|
> **Note:** The `lighthouse` command requires an extra installation.
|
|
54
66
|
>
|
|
55
67
|
> Please make sure to install the standalone package by running:<br>
|
|
@@ -60,6 +72,7 @@ This package depends on:
|
|
|
60
72
|
|
|
61
73
|
| Dependency | Purpose |
|
|
62
74
|
|---------------------------|---------------------------------------------------------|
|
|
75
|
+
| @browserless/capture | Extension-based tab capture for CLI video recording |
|
|
63
76
|
| browserless | Core API for all browser automation operations |
|
|
64
77
|
| @browserless/lighthouse | Lighthouse audit integration (used by lighthouse command) |
|
|
65
78
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@browserless/cli",
|
|
3
3
|
"description": "Command-line interface for headless browser automation. Take screenshots, generate PDFs, and extract content from websites.",
|
|
4
4
|
"homepage": "https://browserless.js.org",
|
|
5
|
-
"version": "10.
|
|
5
|
+
"version": "10.11.0",
|
|
6
6
|
"bin": {
|
|
7
7
|
"browserless": "src/index.js"
|
|
8
8
|
},
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"tool"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@browserless/capture": "^10.11.0",
|
|
37
38
|
"beauty-error": "~1.2.21",
|
|
38
|
-
"browserless": "^10.
|
|
39
|
+
"browserless": "^10.11.0",
|
|
39
40
|
"dark-mode": "~3.0.0",
|
|
40
41
|
"dset": "~3.1.4",
|
|
41
42
|
"mri": "~1.2.0",
|
|
@@ -54,10 +55,9 @@
|
|
|
54
55
|
"files": [
|
|
55
56
|
"src"
|
|
56
57
|
],
|
|
58
|
+
"license": "MIT",
|
|
57
59
|
"scripts": {
|
|
58
60
|
"coverage": "exit 0",
|
|
59
61
|
"test": "exit 0"
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
"gitHead": "ec6a614923a1a692bd717ecc8e6f1b09417801d9"
|
|
63
|
-
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const prettyBytes = require('pretty-bytes')
|
|
4
|
+
|
|
5
|
+
module.exports = async ({ url, browserless, opts }) => {
|
|
6
|
+
const { path: outputPath, ...captureOpts } = opts
|
|
7
|
+
|
|
8
|
+
const type = captureOpts.type && String(captureOpts.type).toLowerCase()
|
|
9
|
+
|
|
10
|
+
const suggestedType =
|
|
11
|
+
{ matroska: 'mkv', mkv: 'mkv', mp4: 'mp4', webm: 'webm' }[type] ||
|
|
12
|
+
(captureOpts.mimeType && captureOpts.mimeType.includes('mp4') ? 'mp4' : 'webm')
|
|
13
|
+
|
|
14
|
+
const video = await browserless.capture(url, {
|
|
15
|
+
...captureOpts,
|
|
16
|
+
path: outputPath
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const preview = outputPath
|
|
20
|
+
? `saved at ${process.cwd()}/${outputPath}`
|
|
21
|
+
: `captured ${prettyBytes(video.length)} (use --path=./capture.${suggestedType} to persist)`
|
|
22
|
+
|
|
23
|
+
return [video, preview]
|
|
24
|
+
}
|
package/src/index.js
CHANGED
|
@@ -63,7 +63,13 @@ const run = async () => {
|
|
|
63
63
|
const [command, rawUrl] = cli.input
|
|
64
64
|
const url = new URL(rawUrl).toString()
|
|
65
65
|
const fn = require(`./commands/${command}`)
|
|
66
|
-
const
|
|
66
|
+
const launchOpts = { headless }
|
|
67
|
+
|
|
68
|
+
if (command === 'capture') {
|
|
69
|
+
launchOpts.headless = headless === false ? false : 'new'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const browser = createBrowser(launchOpts)
|
|
67
73
|
onExit(browser.close)
|
|
68
74
|
const browserless = await browser.createContext()
|
|
69
75
|
return fn({ url, browserless, opts: nestie(opts), isPageReady })
|