n8n-nodes-puppeteer-no-timeout 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +303 -0
  3. package/index.js +0 -0
  4. package/package.json +63 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Nicholas Penree <nick@penree.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,303 @@
1
+ # n8n-nodes-puppeteer
2
+
3
+ ![n8n.io - Workflow Automation](https://raw.githubusercontent.com/n8n-io/n8n/master/assets/n8n-logo.png)
4
+
5
+ [n8n](https://www.n8n.io) node for browser automation using [Puppeteer](https://pptr.dev/). Execute custom scripts, capture screenshots and PDFs, scrape content, and automate web interactions using Chrome/Chromium's DevTools Protocol. Full access to Puppeteer's API plus n8n's Code node capabilities makes this node powerful for any browser automation task.
6
+
7
+ ## How to install
8
+
9
+ ### Community Nodes (Recommended)
10
+
11
+ For n8n version 0.187 and later, you can install this node through the Community Nodes panel:
12
+
13
+ 1. Go to **Settings > Community Nodes**
14
+ 2. Select **Install**
15
+ 3. Enter `n8n-nodes-puppeteer` in **Enter npm package name**
16
+ 4. Agree to the [risks](https://docs.n8n.io/integrations/community-nodes/risks/) of using community nodes
17
+ 5. Select **Install**
18
+
19
+ ### Docker Installation (Recommended for Production)
20
+
21
+ We provide a ready-to-use Docker setup in the `docker/` directory that includes all necessary dependencies and configurations:
22
+
23
+ 1. Clone this repository or copy the following files to your project:
24
+ - `docker/Dockerfile`
25
+ - `docker/docker-custom-entrypoint.sh`
26
+
27
+ 2. Build your Docker image:
28
+ ```bash
29
+ docker build -t n8n-puppeteer -f docker/Dockerfile docker/
30
+ ```
31
+
32
+ 3. Run the container:
33
+ ```bash
34
+ docker run -it \
35
+ -p 5678:5678 \
36
+ -v ~/.n8n:/home/node/.n8n \
37
+ n8n-puppeteer
38
+ ```
39
+
40
+ ### Manual Installation
41
+
42
+ For a standard installation without Docker:
43
+
44
+ ```bash
45
+ # Navigate to your n8n root directory
46
+ cd /path/to/n8n
47
+
48
+ # Install the package
49
+ npm install n8n-nodes-puppeteer
50
+ ```
51
+
52
+ Note: By default, when Puppeteer is installed, it downloads a compatible version of Chromium. While this works, it increases installation size and may not include necessary system dependencies. For production use, we recommend either using the Docker setup above or installing system Chrome/Chromium and setting the `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true` environment variable.
53
+
54
+ ## Browser Setup Options
55
+
56
+ ### 1. Local Browser (Docker Setup - Recommended)
57
+
58
+ The included Docker setup provides the most reliable way to run Chrome/Chromium with all necessary dependencies. It uses Alpine Linux's Chromium package and includes all required fonts and libraries.
59
+
60
+ ### 2. Remote Browser (Alternative for Cloud)
61
+
62
+ You can also connect to an external Chrome instance using the "Browser WebSocket Endpoint" option. This approach:
63
+ - Eliminates the need for Chrome dependencies in your n8n environment
64
+ - Simplifies deployment and maintenance
65
+ - Provides better resource isolation
66
+ - Works great for cloud and containerized deployments
67
+
68
+ Options include:
69
+ - **Managed Services**: Use [browserless](https://browserless.io) or [browsercloud](https://browsercloud.io)
70
+ - **Self-Hosted**: Run your own [browser container](https://docs.browserless.io/docker/config):
71
+ ```bash
72
+ docker run -p 3000:3000 -e "TOKEN=6R0W53R135510" ghcr.io/browserless/chromium
73
+ ```
74
+
75
+ To use a remote browser, enable "Browser WebSocket Endpoint" in any Puppeteer node and enter your WebSocket URL (e.g., `ws://browserless:3000?token=6R0W53R135510`).
76
+
77
+ ## Troubleshooting
78
+
79
+ If you see errors about missing shared libraries (like `libgobject-2.0.so.0` or `libnss3.so`), either:
80
+
81
+ 1. Install the missing Chrome dependencies
82
+ 2. Switch to using a remote browser with the WebSocket endpoint option
83
+
84
+ For additional help, see [Puppeteer's troubleshooting guide](https://pptr.dev/troubleshooting).
85
+
86
+ ## Node Reference
87
+
88
+ - **Operations**
89
+
90
+ - Get the full HTML contents of the page
91
+ - Capture the contents of a page as a PDF document
92
+ - Capture screenshot of all or part of the page
93
+ - Execute custom script to interact with the page
94
+
95
+ - **Options**
96
+
97
+ - All Operations
98
+
99
+ - **Batch Size**: Maximum number of pages to open simultaneously. More pages will consume more memory and CPU.
100
+ - **Browser WebSocket Endpoint**: The WebSocket URL of the browser to connect to. When configured, puppeteer will skip the browser launch and connect to the browser instance.
101
+ - **Emulate Device**: Allows you to specify a [device](https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts) to emulate when requesting the page.
102
+ - **Executable Path**: A path where Puppeteer expects to find the bundled browser. Has no effect when 'Browser WebSocket Endpoint' is set.
103
+ - **Extra Headers**: Allows you add additional headers when requesting the page.
104
+ - **Timeout**: Allows you to specify the maximum navigation time in milliseconds. You can pass 0 to disable the timeout entirely.
105
+ - **Wait Until**: Allows you to change how Puppeteer considers navigation completed.
106
+ - `load`: The load event is fired.
107
+ - `domcontentloaded`: The DOMContentLoaded event is fired.
108
+ - `networkidle0`: No more than 0 connections for at least 500 ms.
109
+ - `networkidle2`: No more than 2 connections for at least 500 ms.
110
+ - **Page Caching**: Allows you to toggle whether pages should be cached when requesting.
111
+ - **Headless mode**: Allows you to change whether to run browser runs in headless mode or not.
112
+ - **Use Chrome Headless Shell**: Whether to run browser in headless shell mode. Defaults to false. Headless mode must be enabled. chrome-headless-shell must be in $PATH.
113
+ - **Stealth mode**: When enabled, applies various techniques to make detection of headless Puppeteer harder. Powered by [puppeteer-extra-plugin-stealth](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth).
114
+ - **Launch Arguments**: Allows you to specify additional command line arguments passed to the browser instance.
115
+ - **Proxy Server**: Allows Puppeteer to use a custom proxy configuration. You can specify a custom proxy configuration in three ways:
116
+ By providing a semi-colon-separated mapping of list scheme to url/port pairs.
117
+ For example, you can specify:
118
+
119
+ http=foopy:80;ftp=foopy2
120
+
121
+ to use HTTP proxy "foopy:80" for http URLs and HTTP proxy "foopy2:80" for ftp URLs.
122
+
123
+ By providing a single uri with optional port to use for all URLs.
124
+ For example:
125
+
126
+ foopy:8080
127
+
128
+ will use the proxy at foopy:8080 for all traffic.
129
+
130
+ By using the special "direct://" value.
131
+
132
+ direct://" will cause all connections to not use a proxy.
133
+
134
+ - Get PDF
135
+ - **File Name**: Allows you to specify the filename of the output file.
136
+ - **Page Ranges** field: Allows you to specify paper ranges to print, e.g. 1-5, 8, 11-13.
137
+ - **Scale**: Allows you to scale the rendering of the web page. Amount must be between 0.1 and 2
138
+ - **Prefer CSS Page Size**: Give any CSS @page size declared in the page priority over what is declared in the width or height or format option.
139
+ - **Format**: Allows you to specify the paper format types when printing a PDF. eg: Letter, A4.
140
+ - **Height**: Allows you to set the height of paper. You can pass in a number or a string with a unit.
141
+ - **Width**: Allows you to set the width of paper. You can pass in a number or a string with a unit.
142
+ - **Landscape**: Allows you to control whether to show the header and footer
143
+ - **Margin**: Allows you to specify top, left, right, and bottom margin.
144
+ - **Display Header/Footer**: Allows you to specify whether to show the header and footer.
145
+ - **Header Template**: Allows you to specify the HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:
146
+ - `date`: Formatted print date
147
+ - `title`: Document title
148
+ - `url`: Document location
149
+ - `pageNumber` Current page number
150
+ - `totalPages` Total pages in the document
151
+ - **Footer Template**: Allows you to specify the HTML template for the print footer. Should be valid HTML with the following classes used to inject values into them:
152
+ - `date`: Formatted print date
153
+ - `title`: Document title
154
+ - `url`: Document location
155
+ - `pageNumber` Current page number
156
+ - `totalPages` Total pages in the document
157
+ - **Transparent Background**: Allows you to hide the default white background and allows generate PDFs with transparency.
158
+ - **Background Graphic**: Allows you to include background graphics.
159
+ - Get Screenshot
160
+ - **File Name**: Allows you to specify the filename of the output file.
161
+ - **Type** field: Allows you to specify the image format of the output file:
162
+ - JPEG
163
+ - PNG
164
+ - WebP
165
+ - **Quality**: Allows you to specify the quality of the image.
166
+ - Accepts a value between 0-100.
167
+ - Not applicable to PNG images.
168
+ - **Full Page**: Allows you to capture a screen of the full scrollable content.
169
+
170
+ ## Custom Scripts
171
+
172
+ The Custom Script operation gives you complete control over Puppeteer to automate complex browser interactions, scrape data, generate PDFs/screenshots, and more. Scripts run in a sandboxed environment with access to the full Puppeteer API and n8n's Code node features.
173
+
174
+ Before script execution, you can configure browser behavior using the operation's options like:
175
+
176
+ - Emulate specific devices
177
+ - Set custom headers
178
+ - Enable stealth mode to avoid detection
179
+ - Configure proxy settings
180
+ - Set page load timeouts
181
+ - And more
182
+
183
+ Access Puppeteer-specific objects using:
184
+
185
+ - `$page` - Current page instance
186
+ - `$browser` - Browser instance
187
+ - `$puppeteer` - Puppeteer library
188
+
189
+ Plus all special variables and methods from the Code node are available. For a complete reference, see the [n8n documentation](https://docs.n8n.io/code-examples/methods-variables-reference/). Just like n8n's Code node, anything you `console.log` will be shown in the browser's console during test mode or in stdout when configured.
190
+
191
+ ### Basic
192
+
193
+ ```javascript
194
+ // Navigate to an IP lookup service
195
+ await $page.goto("https://httpbin.org/ip");
196
+
197
+ // Extract the IP address from the page content
198
+ const ipData = await $page.evaluate(() => {
199
+ const response = document.body.innerText;
200
+ const parsed = JSON.parse(response);
201
+ return parsed.origin; // Extract the 'origin' field, which typically contains the IP address
202
+ });
203
+
204
+ console.log("Hello, world!");
205
+
206
+ console.log("IP Address", ipData);
207
+
208
+ // Return the result in the required format (array)
209
+ return [{ ip: ipData, ...$json }];
210
+ ```
211
+
212
+ ### Storing and re-using cookies
213
+
214
+ #### Node 1
215
+
216
+ ```javascript
217
+ await $page.goto("https://www.example.com/login");
218
+
219
+ // Perform login
220
+ await $page.type("#login-username", "user");
221
+ await $page.type("#login-password", "pass");
222
+ await $page.click("#login-button");
223
+
224
+ // Store cookies for later use
225
+ const cookies = await $page.cookies();
226
+
227
+ return [{ cookies }];
228
+ ```
229
+
230
+ #### Node 2
231
+
232
+ ```javascript
233
+ const { cookies } = $input.first().json;
234
+
235
+ // Restore cookies
236
+ await $page.setCookie(...cookies);
237
+
238
+ // Navigate to authenticated page
239
+ await $page.goto("https://example.com/protected-page");
240
+
241
+ // Perform authenticated operations
242
+ const data = await $page.evaluate(() => {
243
+ return document.querySelector(".protected-content").textContent;
244
+ });
245
+
246
+ return [{ data }];
247
+ ```
248
+
249
+ ### Working with Binary Data
250
+
251
+ ```javascript
252
+ await $page.goto("https://www.google.com");
253
+ const imageData = await $page.screenshot({ type: "png", encoding: "base64" });
254
+ return [
255
+ {
256
+ binary: {
257
+ screenshot: {
258
+ data: imageData,
259
+ mimeType: "image/png",
260
+ fileName: "screenshot.png",
261
+ },
262
+ },
263
+ },
264
+ ];
265
+ ```
266
+
267
+ ## Screenshots
268
+
269
+ ### Run Custom Script
270
+
271
+ ![](images/script.png)
272
+
273
+ ### Get Page Content
274
+
275
+ ![](images/content.png)
276
+
277
+ ### Get Screenshot
278
+
279
+ ![](images/screenshot.png)
280
+
281
+ ## License
282
+
283
+ MIT License
284
+
285
+ Copyright (c) 2022-2024 Nicholas Penree <nick@penree.com>
286
+
287
+ Permission is hereby granted, free of charge, to any person obtaining a copy
288
+ of this software and associated documentation files (the "Software"), to deal
289
+ in the Software without restriction, including without limitation the rights
290
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
291
+ copies of the Software, and to permit persons to whom the Software is
292
+ furnished to do so, subject to the following conditions:
293
+
294
+ The above copyright notice and this permission notice shall be included in all
295
+ copies or substantial portions of the Software.
296
+
297
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
298
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
299
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
300
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
301
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
302
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
303
+ SOFTWARE.
package/index.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "n8n-nodes-puppeteer-no-timeout",
3
+ "version": "1.3.1",
4
+ "description": "n8n node for browser automation using Puppeteer without timeout",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/drudge/n8n-nodes-puppeteer",
7
+ "author": {
8
+ "name": "Nicholas Penree",
9
+ "email": "nick@penree.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/drudge/n8n-nodes-puppeteer.git"
14
+ },
15
+ "main": "index.js",
16
+ "scripts": {
17
+ "dev": "npm run watch",
18
+ "build": "tsc && gulp",
19
+ "lint": "tslint -p tsconfig.json -c tslint.json",
20
+ "lintfix": "tslint --fix -p tsconfig.json -c tslint.json",
21
+ "nodelinter": "nodelinter",
22
+ "watch": "tsc --watch"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "keywords": [
28
+ "n8n",
29
+ "node",
30
+ "puppeteer",
31
+ "scraper",
32
+ "screenshot",
33
+ "script",
34
+ "pdf",
35
+ "n8n-node",
36
+ "n8n-community-node-package"
37
+ ],
38
+ "n8n": {
39
+ "n8nNodesApiVersion": 1,
40
+ "credentials": [],
41
+ "nodes": [
42
+ "dist/nodes/Puppeteer/Puppeteer.node.js"
43
+ ]
44
+ },
45
+ "devDependencies": {
46
+ "@typescript-eslint/parser": "^8.18.1",
47
+ "eslint": "^9.17.0",
48
+ "eslint-plugin-n8n-nodes-base": "^1.16.3",
49
+ "gulp": "^5.0.0",
50
+ "n8n-workflow": "*",
51
+ "prettier": "^3.4.2",
52
+ "typescript": "^5.7.2"
53
+ },
54
+ "peerDependencies": {
55
+ "n8n-workflow": "*"
56
+ },
57
+ "dependencies": {
58
+ "@n8n/vm2": "^3.9.25",
59
+ "puppeteer": "^24.1.1",
60
+ "puppeteer-extra": "^3.3.6",
61
+ "puppeteer-extra-plugin-stealth": "^2.11.2"
62
+ }
63
+ }