@link-assistant/web-capture 1.1.2 → 1.7.1

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +57 -13
  2. package/Dockerfile +26 -21
  3. package/README.md +290 -160
  4. package/bin/web-capture.js +622 -17
  5. package/package.json +15 -4
  6. package/src/animation.js +283 -0
  7. package/src/archive.js +225 -0
  8. package/src/batch.js +180 -0
  9. package/src/browser.js +150 -111
  10. package/src/docx.js +182 -0
  11. package/src/extract-images.js +120 -0
  12. package/src/figures.js +208 -0
  13. package/src/gdocs.js +335 -0
  14. package/src/image.js +65 -8
  15. package/src/index.js +15 -0
  16. package/src/latex.js +127 -0
  17. package/src/lib.js +281 -1
  18. package/src/localize-images.js +202 -0
  19. package/src/markdown.js +7 -2
  20. package/src/metadata.js +333 -0
  21. package/src/pdf.js +76 -0
  22. package/src/popups.js +171 -0
  23. package/src/postprocess.js +263 -0
  24. package/src/retry.js +48 -0
  25. package/src/themed-image.js +167 -0
  26. package/src/verify.js +312 -0
  27. package/tests/e2e/docker.test.js +51 -12
  28. package/tests/e2e/process.test.js +34 -10
  29. package/tests/fixtures/habr-articles.js +45 -0
  30. package/tests/integration/api-endpoints.test.js +231 -0
  31. package/tests/integration/habr-article.test.js +337 -0
  32. package/tests/mock/index.test.js +5 -3
  33. package/tests/unit/animation.test.js +33 -0
  34. package/tests/unit/batch.test.js +114 -0
  35. package/tests/unit/browser.test.js +38 -2
  36. package/tests/unit/extract-images.test.js +233 -0
  37. package/tests/unit/figures.test.js +74 -0
  38. package/tests/unit/gdocs.test.js +278 -0
  39. package/tests/unit/heading-image.test.js +49 -0
  40. package/tests/unit/latex.test.js +123 -0
  41. package/tests/unit/localize-images.test.js +78 -0
  42. package/tests/unit/metadata.test.js +140 -0
  43. package/tests/unit/postprocess.test.js +110 -0
  44. package/tests/unit/retry.test.js +111 -0
  45. package/tests/unit/verify.test.js +182 -0
  46. package/.github/workflows/release.yml +0 -294
  47. package/ARCHITECTURE.md +0 -982
  48. package/LICENSE +0 -24
  49. package/apply.sh +0 -166
  50. package/docs/market-analysis-2025-05-13.md +0 -64
  51. package/scripts/changeset-version.mjs +0 -38
  52. package/scripts/create-github-release.mjs +0 -93
  53. package/scripts/create-manual-changeset.mjs +0 -88
  54. package/scripts/format-github-release.mjs +0 -83
  55. package/scripts/format-release-notes.mjs +0 -218
  56. package/scripts/instant-version-bump.mjs +0 -121
  57. package/scripts/publish-to-npm.mjs +0 -128
  58. package/scripts/setup-npm.mjs +0 -37
  59. package/scripts/validate-changeset.mjs +0 -106
  60. package/scripts/version-and-commit.mjs +0 -237
package/README.md CHANGED
@@ -1,241 +1,306 @@
1
- # web-capture
1
+ # web-capture (JavaScript/Node.js)
2
2
 
3
- <img width="1824" alt="Screenshot 2025-05-12 at 3 49 32 AM" src="https://github.com/user-attachments/assets/cbf63dec-7dcd-40e7-9d5d-eddc49fe6169" />
3
+ [![npm version](https://img.shields.io/npm/v/@link-assistant/web-capture?label=npm&color=blue)](https://www.npmjs.com/package/@link-assistant/web-capture)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@link-assistant/web-capture?label=downloads&color=blue)](https://www.npmjs.com/package/@link-assistant/web-capture)
5
+ [![GitHub Release](https://img.shields.io/github/v/release/link-assistant/web-capture?label=GitHub%20Release)](https://github.com/link-assistant/web-capture/releases)
6
+ [![CI - JavaScript](https://img.shields.io/github/actions/workflow/status/link-assistant/web-capture/js.yml?branch=main&label=CI)](https://github.com/link-assistant/web-capture/actions/workflows/js.yml)
7
+ [![License: Unlicense](https://img.shields.io/badge/license-Unlicense-green)](https://unlicense.org)
4
8
 
5
9
  A CLI and microservice to fetch URLs and render them as:
6
10
 
11
+ - **Markdown**: Converted from HTML with image extraction (default)
7
12
  - **HTML**: Rendered page content
8
- - **Markdown**: Converted from HTML
9
- - **PNG screenshot**: Full page capture
10
-
11
- ## Quick Start
12
-
13
- ### CLI Usage
14
-
15
- ```bash
16
- # Install globally
17
- npm install -g web-capture
18
-
19
- # Capture a URL as HTML (output to stdout)
20
- web-capture https://example.com
21
-
22
- # Capture as Markdown and save to file
23
- web-capture https://example.com --format markdown --output page.md
24
-
25
- # Take a screenshot
26
- web-capture https://example.com --format png --output screenshot.png
27
-
28
- # Start as API server
29
- web-capture --serve
30
-
31
- # Start server on custom port
32
- web-capture --serve --port 8080
33
- ```
34
-
35
- ### API Endpoints (Server Mode)
36
-
37
- - **HTML**: GET /html?url=<URL>
38
- - **Markdown**: GET /markdown?url=<URL>
39
- - **PNG screenshot**: GET /image?url=<URL>
13
+ - **PNG/JPEG screenshot**: Viewport or full-page capture with theme support
14
+ - **ZIP archive**: Markdown + locally downloaded images
15
+ - **PDF**: Print-quality document with embedded images
16
+ - **DOCX**: Word document with embedded images
40
17
 
41
18
  ## Installation
42
19
 
43
- ```bash
44
- npm install
45
- # or
46
- yarn install
47
- ```
48
-
49
- ## CLI Reference
50
-
51
- ### Server Mode
52
-
53
- Start the API server:
20
+ ### From npm
54
21
 
55
22
  ```bash
56
- web-capture --serve [--port <port>]
23
+ npm install -g @link-assistant/web-capture
57
24
  ```
58
25
 
59
- | Option | Short | Description | Default |
60
- | --------- | ----- | ------------------------ | ------------------ |
61
- | `--serve` | `-s` | Start as HTTP API server | - |
62
- | `--port` | `-p` | Port to listen on | 3000 (or PORT env) |
63
-
64
- ### Capture Mode
65
-
66
- Capture a URL directly:
26
+ ### From Source
67
27
 
68
28
  ```bash
69
- web-capture <url> [options]
29
+ cd js
30
+ npm install
70
31
  ```
71
32
 
72
- | Option | Short | Description | Default |
73
- | ---------- | ----- | ----------------------------------------------------- | ---------------------------------------- |
74
- | `--format` | `-f` | Output format: `html`, `markdown`/`md`, `image`/`png` | `html` |
75
- | `--output` | `-o` | Output file path | stdout (text) or auto-generated (images) |
76
- | `--engine` | `-e` | Browser engine: `puppeteer`, `playwright` | `puppeteer` (or BROWSER_ENGINE env) |
33
+ ## Quick Start
77
34
 
78
- ### Examples
35
+ ### CLI Usage
79
36
 
80
37
  ```bash
81
- # Capture HTML to stdout
38
+ # Capture a URL as Markdown (default format)
39
+ # Output auto-derived to ./data/web-capture/<host>/<path>/document.md
82
40
  web-capture https://example.com
83
41
 
84
- # Capture Markdown to file
85
- web-capture https://example.com -f markdown -o page.md
42
+ # Capture as Markdown to a specific file
43
+ web-capture https://example.com -o page.md
86
44
 
87
- # Take screenshot with Playwright engine
88
- web-capture https://example.com -f png -e playwright -o screenshot.png
45
+ # Write to stdout explicitly
46
+ web-capture https://example.com -o -
89
47
 
90
- # Pipe HTML to another command
91
- web-capture https://example.com | grep "title"
92
- ```
48
+ # Capture as HTML
49
+ web-capture https://example.com --format html -o page.html
93
50
 
94
- ## Available Commands
51
+ # Take a PNG screenshot
52
+ web-capture https://example.com --format png -o screenshot.png
95
53
 
96
- ### Development
54
+ # Take a JPEG screenshot with custom quality
55
+ web-capture https://example.com --format jpeg --quality 60 -o screenshot.jpg
97
56
 
98
- - `yarn dev` - Start the development server with hot reloading using nodemon
99
- - `yarn start` - Start the service using Docker Compose
57
+ # Dark theme full-page screenshot
58
+ web-capture https://example.com --format png --theme dark --fullPage -o dark.png
100
59
 
101
- ### Testing
60
+ # Custom viewport size
61
+ web-capture https://example.com --format png --width 1920 --height 1080 -o wide.png
102
62
 
103
- - `yarn test` - Run all unit tests
104
- - `yarn test:watch` - Run tests in watch mode
105
- - `yarn test:e2e` - Run end-to-end tests
106
- - `yarn test:e2e:docker` - Run end-to-end tests against Docker container
107
- - `yarn test:all` - Run all tests including build and e2e tests
63
+ # Download as PDF
64
+ web-capture https://example.com --format pdf -o page.pdf
108
65
 
109
- ### Building
66
+ # Download as DOCX
67
+ web-capture https://example.com --format docx -o page.docx
110
68
 
111
- - `yarn build` - Build and start the Docker container
69
+ # Create a ZIP archive (default: zip format)
70
+ web-capture https://example.com --archive
112
71
 
113
- ### Examples
72
+ # Create a ZIP archive with specific format
73
+ web-capture https://example.com --archive zip -o site.zip
74
+ web-capture https://example.com --archive tar.gz -o site.tar.gz
114
75
 
115
- - `yarn examples:python` - Run Python example scripts
116
- - `yarn examples:javascript` - Run JavaScript example scripts
117
- - `yarn examples` - Run all examples (requires build)
76
+ # Keep images inline as base64 (opt-in)
77
+ web-capture https://example.com --embed-images -o page.md
118
78
 
119
- ## Usage
79
+ # Custom images directory
80
+ web-capture https://example.com --images-dir assets -o page.md
120
81
 
121
- ### Local Development
82
+ # Disable specific features
83
+ web-capture https://example.com --no-extract-latex --no-post-process -o page.md
122
84
 
123
- ```bash
124
- yarn dev
125
- curl http://localhost:3000/html?url=https://example.com
85
+ # Start as API server
86
+ web-capture --serve
87
+
88
+ # Start server on custom port
89
+ web-capture --serve --port 8080
126
90
  ```
127
91
 
128
- ### Docker
92
+ ### Google Docs
129
93
 
130
94
  ```bash
131
- # Build and run using Docker Compose
132
- yarn start
95
+ # Capture public Google Doc as Markdown
96
+ web-capture https://docs.google.com/document/d/DOC_ID/edit
133
97
 
134
- # Or manually
135
- docker build -t web-capture .
136
- docker run -p 3000:3000 web-capture
98
+ # Capture private Google Doc with API token
99
+ web-capture https://docs.google.com/document/d/DOC_ID/edit --apiToken YOUR_TOKEN
137
100
  ```
138
101
 
139
- ## API Endpoints
102
+ ## API Endpoints (Server Mode)
103
+
104
+ Start the server with `web-capture --serve` and use the endpoints below.
140
105
 
141
106
  ### HTML Endpoint
142
107
 
143
- ```bash
108
+ ```
144
109
  GET /html?url=<URL>&engine=<ENGINE>
145
110
  ```
146
111
 
147
112
  Returns the raw HTML content of the specified URL.
148
113
 
149
- **Parameters:**
114
+ | Parameter | Required | Description | Default |
115
+ | --------- | -------- | ------------------------------------ | --------- |
116
+ | `url` | Yes | URL to fetch | - |
117
+ | `engine` | No | Browser engine: puppeteer/playwright | puppeteer |
150
118
 
151
- - `url` (required): The URL to fetch
152
- - `engine` (optional): Browser engine to use (`puppeteer` or `playwright`). Default: `puppeteer`
119
+ ### Markdown Endpoint
153
120
 
154
- **Examples:**
121
+ ```
122
+ GET /markdown?url=<URL>
123
+ ```
155
124
 
156
- ```bash
157
- # Using default Puppeteer engine
158
- curl http://localhost:3000/html?url=https://example.com
125
+ Converts the HTML content of the specified URL to Markdown format. By default, original remote image URLs are preserved and base64 data URIs are stripped (clean single-file output). Use `keepOriginalLinks=false` to strip all images, or `embedImages=true` to keep base64 images inline.
159
126
 
160
- # Using Playwright engine
161
- curl http://localhost:3000/html?url=https://example.com&engine=playwright
162
- ```
127
+ | Parameter | Required | Description | Default |
128
+ | ------------------- | -------- | ------------------------------------------ | ------- |
129
+ | `url` | Yes | URL to fetch | - |
130
+ | `embedImages` | No | Keep base64 images inline (`true`/`false`) | `false` |
131
+ | `keepOriginalLinks` | No | Keep original remote URLs, strip base64 | `true` |
163
132
 
164
- ### Markdown Endpoint
133
+ ### Image Endpoint
165
134
 
166
- ```bash
167
- GET /markdown?url=<URL>
135
+ ```
136
+ GET /image?url=<URL>&format=png&theme=dark&width=1920&height=1080&fullPage=true
168
137
  ```
169
138
 
170
- Converts the HTML content of the specified URL to Markdown format.
139
+ Returns a screenshot of the specified URL.
171
140
 
172
- ### Image Endpoint
141
+ | Parameter | Required | Description | Default |
142
+ | --------------- | -------- | ---------------------------------------- | --------------- |
143
+ | `url` | Yes | URL to capture | - |
144
+ | `engine` | No | Browser engine: puppeteer/playwright | puppeteer |
145
+ | `format` | No | Image format: `png` (lossless) or `jpeg` | png |
146
+ | `quality` | No | JPEG quality 0-100 (ignored for PNG) | 80 |
147
+ | `width` | No | Viewport width in pixels | 1280 |
148
+ | `height` | No | Viewport height in pixels | 800 |
149
+ | `fullPage` | No | Capture full scrollable page | false |
150
+ | `theme` | No | Color scheme: `light`, `dark` | browser default |
151
+ | `dismissPopups` | No | Auto-close cookie/consent popups | true |
152
+
153
+ ### Archive Endpoint
173
154
 
174
- ```bash
175
- GET /image?url=<URL>&engine=<ENGINE>
155
+ ```
156
+ GET /archive?url=<URL>&localImages=true&documentFormat=markdown
176
157
  ```
177
158
 
178
- Returns a PNG screenshot of the specified URL.
159
+ Returns a ZIP archive containing either `document.md` or `document.html` and asset directories (`images/`, `css/`).
179
160
 
180
- **Parameters:**
161
+ | Parameter | Required | Description | Default |
162
+ | ------------------- | -------- | -------------------------------------------- | ---------- |
163
+ | `url` | Yes | URL to archive | - |
164
+ | `localImages` | No | Download images locally into the archive | `true` |
165
+ | `documentFormat` | No | Document format: `markdown` or `html` | `markdown` |
166
+ | `embedImages` | No | Keep base64 images inline in the document | `false` |
167
+ | `keepOriginalLinks` | No | Keep original remote URLs (skip downloading) | `false` |
181
168
 
182
- - `url` (required): The URL to capture
183
- - `engine` (optional): Browser engine to use (`puppeteer` or `playwright`). Default: `puppeteer`
169
+ **Archive structure** (with `localImages=true`):
184
170
 
185
- **Examples:**
171
+ ```
172
+ archive.zip
173
+ ├── document.md # or document.html when documentFormat=html
174
+ ├── images/
175
+ │ ├── image-1.png
176
+ │ ├── image-2.jpg
177
+ │ └── ...
178
+ └── css/ # only when documentFormat=html
179
+ ├── style-1.css
180
+ └── ...
181
+ ```
186
182
 
187
- ```bash
188
- # Using default Puppeteer engine
189
- curl http://localhost:3000/image?url=https://example.com > screenshot.png
183
+ ### PDF Endpoint
190
184
 
191
- # Using Playwright engine
192
- curl http://localhost:3000/image?url=https://example.com&engine=playwright > screenshot.png
185
+ ```
186
+ GET /pdf?url=<URL>&theme=light
193
187
  ```
194
188
 
195
- ## Configuration
189
+ Returns a PDF document rendered by the browser engine (all images embedded).
196
190
 
197
- web-capture uses [lino-arguments](https://github.com/link-foundation/lino-arguments) for unified configuration management. Configuration values are resolved with the following priority (highest to lowest):
191
+ | Parameter | Required | Description | Default |
192
+ | --------------- | -------- | ------------------------------- | --------------- |
193
+ | `url` | Yes | URL to convert | - |
194
+ | `engine` | No | Browser engine | puppeteer |
195
+ | `width` | No | Viewport width in pixels | 1280 |
196
+ | `height` | No | Viewport height in pixels | 800 |
197
+ | `theme` | No | Color scheme: `light`, `dark` | browser default |
198
+ | `dismissPopups` | No | Auto-close popups before export | true |
198
199
 
199
- 1. **CLI arguments**: `--port 8080`
200
- 2. **Environment variables**: `PORT=8080`
201
- 3. **Custom configuration file**: `--configuration path/to/custom.lenv`
202
- 4. **Default .lenv file**: `.lenv` in the project root
203
- 5. **Built-in defaults**
200
+ ### DOCX Endpoint
204
201
 
205
- ### Configuration File (.lenv)
202
+ ```
203
+ GET /docx?url=<URL>
204
+ ```
206
205
 
207
- Create a `.lenv` file in your project root using Links Notation format:
206
+ Returns a DOCX document with embedded images.
208
207
 
209
- ```lenv
210
- # Server configuration
211
- PORT: 3000
208
+ | Parameter | Required | Description | Default |
209
+ | --------- | -------- | -------------- | ------- |
210
+ | `url` | Yes | URL to convert | - |
212
211
 
213
- # Browser engine (puppeteer or playwright)
214
- BROWSER_ENGINE: puppeteer
212
+ ### Fetch/Stream Endpoints
213
+
214
+ ```
215
+ GET /fetch?url=<URL>
216
+ GET /stream?url=<URL>
215
217
  ```
216
218
 
217
- ### Using Custom Configuration Files
219
+ Proxy fetch and streaming proxy endpoints.
218
220
 
219
- Specify a custom configuration file path:
221
+ ## CLI Reference
222
+
223
+ ### Server Mode
220
224
 
221
225
  ```bash
222
- web-capture --serve --configuration /path/to/custom.lenv
226
+ web-capture --serve [--port <port>]
223
227
  ```
224
228
 
225
- ### Environment Variables
229
+ | Option | Short | Description | Default |
230
+ | --------- | ----- | ------------------------ | ------------------ |
231
+ | `--serve` | `-s` | Start as HTTP API server | - |
232
+ | `--port` | `-p` | Port to listen on | 3000 (or PORT env) |
226
233
 
227
- All configuration options support environment variables:
234
+ ### Capture Mode
228
235
 
229
236
  ```bash
230
- # Set port via environment variable
231
- export PORT=8080
232
- web-capture --serve
233
-
234
- # Set browser engine
235
- export BROWSER_ENGINE=playwright
236
- web-capture https://example.com --format png
237
+ web-capture <url> [options]
237
238
  ```
238
239
 
240
+ | Option | Short | Description | Default |
241
+ | --------------------------- | ----- | ---------------------------------------------- | ----------------------------------- |
242
+ | `--format` | `-f` | Output format (see below) | `markdown` |
243
+ | `--output` | `-o` | Output file path. Use `-o -` for stdout | auto-derived from URL |
244
+ | `--data-dir` | | Base directory for auto-derived output paths | `./data/web-capture` |
245
+ | `--engine` | `-e` | Browser engine: `puppeteer`, `playwright` | `puppeteer` (or BROWSER_ENGINE env) |
246
+ | `--theme` | `-t` | Color scheme: `light`, `dark`, `no-preference` | browser default |
247
+ | `--width` | | Viewport width in pixels | 1280 |
248
+ | `--height` | | Viewport height in pixels | 800 |
249
+ | `--quality` | | JPEG quality 0-100 | 80 |
250
+ | `--fullPage` | | Capture full scrollable page | false |
251
+ | `--embed-images` | | Keep images as inline base64 data URIs | false |
252
+ | `--no-extract-images` | | Alias for `--embed-images` | false |
253
+ | `--keep-original-links` | | Keep original remote URLs, strip base64 | false |
254
+ | `--images-dir` | | Subdirectory name for extracted images | `images` |
255
+ | `--archive` | | Create archive: `zip`, `7z`, `tar.gz`, `tar` | - |
256
+ | `--document-format` | | Document format in archive: `markdown`, `html` | `markdown` |
257
+ | `--localImages` | | Download images locally in archive mode | true |
258
+ | `--extract-latex` | | Extract LaTeX formulas | true |
259
+ | `--no-extract-latex` | | Disable LaTeX extraction | - |
260
+ | `--extract-metadata` | | Extract article metadata | true |
261
+ | `--no-extract-metadata` | | Disable metadata extraction | - |
262
+ | `--post-process` | | Apply post-processing | true |
263
+ | `--no-post-process` | | Disable post-processing | - |
264
+ | `--detect-code-language` | | Detect code block languages | true |
265
+ | `--no-detect-code-language` | | Disable code language detection | - |
266
+
267
+ **Supported formats:**
268
+
269
+ | Format | Description |
270
+ | ----------------- | ---------------------------------------- |
271
+ | `markdown` / `md` | Markdown conversion (default) |
272
+ | `html` | Rendered HTML |
273
+ | `image` / `png` | PNG screenshot (lossless) |
274
+ | `jpeg` | JPEG screenshot (configurable quality) |
275
+ | `pdf` | PDF with embedded images |
276
+ | `docx` | Word document with embedded images |
277
+ | `archive` / `zip` | ZIP archive with markdown + local images |
278
+
279
+ ## Configuration
280
+
281
+ Configuration values are resolved with the following priority (highest to lowest):
282
+
283
+ 1. **CLI arguments**: `--port 8080`
284
+ 2. **Environment variables**: `PORT=8080`
285
+ 3. **Default .lenv file**: `.lenv` in the project root
286
+ 4. **Built-in defaults**
287
+
288
+ ### Environment Variables
289
+
290
+ | Variable | Description | Default |
291
+ | ---------------------------------- | ----------------------------------- | -------------------- |
292
+ | `PORT` | Server port | `3000` |
293
+ | `BROWSER_ENGINE` | Browser engine | `puppeteer` |
294
+ | `API_TOKEN` | API token for authenticated capture | - |
295
+ | `WEB_CAPTURE_DATA_DIR` | Base directory for output | `./data/web-capture` |
296
+ | `WEB_CAPTURE_EMBED_IMAGES` | `0`/`1` — keep images inline | `0` |
297
+ | `WEB_CAPTURE_KEEP_ORIGINAL_LINKS` | `0`/`1` — keep original remote URLs | `0` |
298
+ | `WEB_CAPTURE_IMAGES_DIR` | Subdirectory for extracted images | `images` |
299
+ | `WEB_CAPTURE_EXTRACT_LATEX` | `0`/`1` — extract LaTeX | `1` |
300
+ | `WEB_CAPTURE_EXTRACT_METADATA` | `0`/`1` — extract metadata | `1` |
301
+ | `WEB_CAPTURE_POST_PROCESS` | `0`/`1` — post-processing | `1` |
302
+ | `WEB_CAPTURE_DETECT_CODE_LANGUAGE` | `0`/`1` — detect code langs | `1` |
303
+
239
304
  ## Browser Engine Support
240
305
 
241
306
  The service supports both **Puppeteer** and **Playwright** browser engines:
@@ -243,26 +308,91 @@ The service supports both **Puppeteer** and **Playwright** browser engines:
243
308
  - **Puppeteer**: Default engine, mature and well-tested
244
309
  - **Playwright**: Alternative engine with similar capabilities
245
310
 
246
- You can choose the engine using:
247
-
248
- - CLI argument: `--engine playwright`
249
- - Environment variable: `BROWSER_ENGINE=playwright`
250
- - Configuration file: `BROWSER_ENGINE: playwright` in `.lenv`
251
-
252
311
  **Supported engine values:**
253
312
 
254
313
  - `puppeteer` or `pptr` - Use Puppeteer
255
314
  - `playwright` or `pw` - Use Playwright
256
315
 
316
+ ## Popup/Modal Dismissal
317
+
318
+ By default, the image, PDF, and archive endpoints automatically dismiss common popups before capture:
319
+
320
+ - Google Funding Choices consent dialogs
321
+ - Cookie consent banners
322
+ - Generic modals and overlays
323
+ - Fixed-position overlays covering content
324
+
325
+ Set `dismissPopups=false` to disable this behavior.
326
+
327
+ ## Docker
328
+
329
+ ```bash
330
+ # Build and run using Docker Compose
331
+ docker compose up -d
332
+
333
+ # Or manually
334
+ docker build -t web-capture-js .
335
+ docker run -p 3000:3000 web-capture-js
336
+ ```
337
+
257
338
  ## Development
258
339
 
259
- The service is built with:
340
+ ### Available Commands
341
+
342
+ - `npm run dev` - Start the development server with hot reloading
343
+ - `npm run start` - Start the service using Docker Compose
344
+ - `npm test` - Run all unit tests
345
+ - `npm run lint` - Check code with ESLint
346
+ - `npm run format` - Format code with Prettier
347
+
348
+ ### Testing
349
+
350
+ ```bash
351
+ npm test # Run unit and integration tests
352
+ npm run test:e2e # Run end-to-end tests
353
+ npm run test:all # Run all tests including build
354
+ ```
355
+
356
+ ## Built With
260
357
 
261
358
  - Express.js for the web server
262
- - Puppeteer and Playwright for headless browser automation and screenshots
359
+ - Puppeteer and Playwright for headless browser automation
263
360
  - Turndown for HTML to Markdown conversion
361
+ - archiver for ZIP creation
362
+ - docx for DOCX generation
264
363
  - Jest for testing
265
364
 
365
+ ## Library Usage
366
+
367
+ You can also use web-capture as a Node.js library:
368
+
369
+ ```javascript
370
+ import {
371
+ fetchHtml,
372
+ convertHtmlToMarkdown,
373
+ } from '@link-assistant/web-capture/src/lib.js';
374
+ import { createBrowser } from '@link-assistant/web-capture/src/browser.js';
375
+ import { dismissPopups } from '@link-assistant/web-capture/src/popups.js';
376
+
377
+ // Fetch and convert to markdown
378
+ const html = await fetchHtml('https://habr.com/en/articles/895896/');
379
+ const markdown = convertHtmlToMarkdown(
380
+ html,
381
+ 'https://habr.com/en/articles/895896/'
382
+ );
383
+
384
+ // Take a themed screenshot
385
+ const browser = await createBrowser('playwright', { colorScheme: 'dark' });
386
+ const page = await browser.newPage();
387
+ await page.setViewport({ width: 1920, height: 1080 });
388
+ await page.goto('https://habr.com/en/articles/895896/', {
389
+ waitUntil: 'networkidle0',
390
+ });
391
+ await dismissPopups(page);
392
+ const buffer = await page.screenshot({ type: 'png', fullPage: true });
393
+ await browser.close();
394
+ ```
395
+
266
396
  ## License
267
397
 
268
- UNLICENSED
398
+ [Unlicense](../LICENSE) — This is free and unencumbered software released into the public domain. You are free to copy, modify, publish, use, compile, sell, or distribute this software for any purpose, commercial or non-commercial, and by any means. See [https://unlicense.org](https://unlicense.org) for details.