n8n-nodes-crawl4ai-plus 2.0.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.
Files changed (74) hide show
  1. package/LICENSE +23 -0
  2. package/LICENSE.md +19 -0
  3. package/README.md +157 -0
  4. package/dist/credentials/Crawl4aiApi.credentials.d.ts +7 -0
  5. package/dist/credentials/Crawl4aiApi.credentials.js +242 -0
  6. package/dist/credentials/Crawl4aiApi.credentials.js.map +1 -0
  7. package/dist/nodes/Crawl4aiBasicCrawler/Crawl4aiBasicCrawler.node.d.ts +5 -0
  8. package/dist/nodes/Crawl4aiBasicCrawler/Crawl4aiBasicCrawler.node.js +37 -0
  9. package/dist/nodes/Crawl4aiBasicCrawler/Crawl4aiBasicCrawler.node.js.map +1 -0
  10. package/dist/nodes/Crawl4aiBasicCrawler/actions/crawlMultipleUrls.operation.d.ts +4 -0
  11. package/dist/nodes/Crawl4aiBasicCrawler/actions/crawlMultipleUrls.operation.js +299 -0
  12. package/dist/nodes/Crawl4aiBasicCrawler/actions/crawlMultipleUrls.operation.js.map +1 -0
  13. package/dist/nodes/Crawl4aiBasicCrawler/actions/crawlSingleUrl.operation.d.ts +4 -0
  14. package/dist/nodes/Crawl4aiBasicCrawler/actions/crawlSingleUrl.operation.js +324 -0
  15. package/dist/nodes/Crawl4aiBasicCrawler/actions/crawlSingleUrl.operation.js.map +1 -0
  16. package/dist/nodes/Crawl4aiBasicCrawler/actions/operations.d.ts +8 -0
  17. package/dist/nodes/Crawl4aiBasicCrawler/actions/operations.js +67 -0
  18. package/dist/nodes/Crawl4aiBasicCrawler/actions/operations.js.map +1 -0
  19. package/dist/nodes/Crawl4aiBasicCrawler/actions/processRawHtml.operation.d.ts +4 -0
  20. package/dist/nodes/Crawl4aiBasicCrawler/actions/processRawHtml.operation.js +148 -0
  21. package/dist/nodes/Crawl4aiBasicCrawler/actions/processRawHtml.operation.js.map +1 -0
  22. package/dist/nodes/Crawl4aiBasicCrawler/actions/router.d.ts +2 -0
  23. package/dist/nodes/Crawl4aiBasicCrawler/actions/router.js +37 -0
  24. package/dist/nodes/Crawl4aiBasicCrawler/actions/router.js.map +1 -0
  25. package/dist/nodes/Crawl4aiBasicCrawler/crawl4ai.svg +17 -0
  26. package/dist/nodes/Crawl4aiBasicCrawler/helpers/apiClient.d.ts +15 -0
  27. package/dist/nodes/Crawl4aiBasicCrawler/helpers/apiClient.js +226 -0
  28. package/dist/nodes/Crawl4aiBasicCrawler/helpers/apiClient.js.map +1 -0
  29. package/dist/nodes/Crawl4aiBasicCrawler/helpers/formatters.d.ts +5 -0
  30. package/dist/nodes/Crawl4aiBasicCrawler/helpers/formatters.js +81 -0
  31. package/dist/nodes/Crawl4aiBasicCrawler/helpers/formatters.js.map +1 -0
  32. package/dist/nodes/Crawl4aiBasicCrawler/helpers/interfaces.d.ts +189 -0
  33. package/dist/nodes/Crawl4aiBasicCrawler/helpers/interfaces.js +3 -0
  34. package/dist/nodes/Crawl4aiBasicCrawler/helpers/interfaces.js.map +1 -0
  35. package/dist/nodes/Crawl4aiBasicCrawler/helpers/utils.d.ts +8 -0
  36. package/dist/nodes/Crawl4aiBasicCrawler/helpers/utils.js +97 -0
  37. package/dist/nodes/Crawl4aiBasicCrawler/helpers/utils.js.map +1 -0
  38. package/dist/nodes/Crawl4aiContentExtractor/Crawl4aiContentExtractor.node.d.ts +5 -0
  39. package/dist/nodes/Crawl4aiContentExtractor/Crawl4aiContentExtractor.node.js +38 -0
  40. package/dist/nodes/Crawl4aiContentExtractor/Crawl4aiContentExtractor.node.js.map +1 -0
  41. package/dist/nodes/Crawl4aiContentExtractor/actions/cssExtractor.operation.d.ts +4 -0
  42. package/dist/nodes/Crawl4aiContentExtractor/actions/cssExtractor.operation.js +336 -0
  43. package/dist/nodes/Crawl4aiContentExtractor/actions/cssExtractor.operation.js.map +1 -0
  44. package/dist/nodes/Crawl4aiContentExtractor/actions/jsonExtractor.operation.d.ts +4 -0
  45. package/dist/nodes/Crawl4aiContentExtractor/actions/jsonExtractor.operation.js +369 -0
  46. package/dist/nodes/Crawl4aiContentExtractor/actions/jsonExtractor.operation.js.map +1 -0
  47. package/dist/nodes/Crawl4aiContentExtractor/actions/llmExtractor.operation.d.ts +4 -0
  48. package/dist/nodes/Crawl4aiContentExtractor/actions/llmExtractor.operation.js +786 -0
  49. package/dist/nodes/Crawl4aiContentExtractor/actions/llmExtractor.operation.js.map +1 -0
  50. package/dist/nodes/Crawl4aiContentExtractor/actions/operations.d.ts +8 -0
  51. package/dist/nodes/Crawl4aiContentExtractor/actions/operations.js +76 -0
  52. package/dist/nodes/Crawl4aiContentExtractor/actions/operations.js.map +1 -0
  53. package/dist/nodes/Crawl4aiContentExtractor/actions/regexExtractor.operation.d.ts +4 -0
  54. package/dist/nodes/Crawl4aiContentExtractor/actions/regexExtractor.operation.js +437 -0
  55. package/dist/nodes/Crawl4aiContentExtractor/actions/regexExtractor.operation.js.map +1 -0
  56. package/dist/nodes/Crawl4aiContentExtractor/actions/router.d.ts +2 -0
  57. package/dist/nodes/Crawl4aiContentExtractor/actions/router.js +37 -0
  58. package/dist/nodes/Crawl4aiContentExtractor/actions/router.js.map +1 -0
  59. package/dist/nodes/Crawl4aiContentExtractor/crawl4ai.svg +17 -0
  60. package/dist/nodes/Crawl4aiContentExtractor/helpers/apiClient.d.ts +1 -0
  61. package/dist/nodes/Crawl4aiContentExtractor/helpers/apiClient.js +7 -0
  62. package/dist/nodes/Crawl4aiContentExtractor/helpers/apiClient.js.map +1 -0
  63. package/dist/nodes/Crawl4aiContentExtractor/helpers/formatters.d.ts +1 -0
  64. package/dist/nodes/Crawl4aiContentExtractor/helpers/formatters.js +8 -0
  65. package/dist/nodes/Crawl4aiContentExtractor/helpers/formatters.js.map +1 -0
  66. package/dist/nodes/Crawl4aiContentExtractor/helpers/interfaces.d.ts +1 -0
  67. package/dist/nodes/Crawl4aiContentExtractor/helpers/interfaces.js +3 -0
  68. package/dist/nodes/Crawl4aiContentExtractor/helpers/interfaces.js.map +1 -0
  69. package/dist/nodes/Crawl4aiContentExtractor/helpers/utils.d.ts +6 -0
  70. package/dist/nodes/Crawl4aiContentExtractor/helpers/utils.js +89 -0
  71. package/dist/nodes/Crawl4aiContentExtractor/helpers/utils.js.map +1 -0
  72. package/dist/tsconfig.tsbuildinfo +1 -0
  73. package/index.js +14 -0
  74. package/package.json +70 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.description = exports.operations = void 0;
27
+ const crawlSingleUrl = __importStar(require("./crawlSingleUrl.operation"));
28
+ const crawlMultipleUrls = __importStar(require("./crawlMultipleUrls.operation"));
29
+ const processRawHtml = __importStar(require("./processRawHtml.operation"));
30
+ exports.operations = {
31
+ crawlSingleUrl: crawlSingleUrl.execute,
32
+ crawlMultipleUrls: crawlMultipleUrls.execute,
33
+ processRawHtml: processRawHtml.execute,
34
+ };
35
+ exports.description = [
36
+ {
37
+ displayName: 'Operation',
38
+ name: 'operation',
39
+ type: 'options',
40
+ noDataExpression: true,
41
+ options: [
42
+ {
43
+ name: 'Crawl Single URL',
44
+ value: 'crawlSingleUrl',
45
+ description: 'Crawl a single URL and extract content',
46
+ action: 'Crawl a single URL',
47
+ },
48
+ {
49
+ name: 'Crawl Multiple URLs',
50
+ value: 'crawlMultipleUrls',
51
+ description: 'Crawl multiple URLs and extract content',
52
+ action: 'Crawl multiple ur ls',
53
+ },
54
+ {
55
+ name: 'Process Raw HTML',
56
+ value: 'processRawHtml',
57
+ description: 'Process provided HTML content without crawling',
58
+ action: 'Process raw html',
59
+ },
60
+ ],
61
+ default: 'crawlSingleUrl',
62
+ },
63
+ ...crawlSingleUrl.description,
64
+ ...crawlMultipleUrls.description,
65
+ ...processRawHtml.description,
66
+ ];
67
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../nodes/Crawl4aiBasicCrawler/actions/operations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,2EAA6D;AAC7D,iFAAmE;AACnE,2EAA6D;AAWhD,QAAA,UAAU,GAAgD;IACrE,cAAc,EAAE,cAAc,CAAC,OAAO;IACtC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO;IAC5C,cAAc,EAAE,cAAc,CAAC,OAAO;CACvC,CAAC;AAGW,QAAA,WAAW,GAAsB;IAC5C;QACE,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,gBAAgB;gBACvB,WAAW,EAAE,wCAAwC;gBACrD,MAAM,EAAE,oBAAoB;aAC7B;YACD;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EAAE,yCAAyC;gBACtD,MAAM,EAAE,sBAAsB;aAC/B;YACD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,gBAAgB;gBACvB,WAAW,EAAE,gDAAgD;gBAC7D,MAAM,EAAE,kBAAkB;aAC3B;SACF;QACD,OAAO,EAAE,gBAAgB;KAC1B;IAGD,GAAG,cAAc,CAAC,WAAW;IAC7B,GAAG,iBAAiB,CAAC,WAAW;IAChC,GAAG,cAAc,CAAC,WAAW;CAC9B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ import type { Crawl4aiNodeOptions } from '../helpers/interfaces';
3
+ export declare const description: INodeProperties[];
4
+ export declare function execute(this: IExecuteFunctions, items: INodeExecutionData[], nodeOptions: Crawl4aiNodeOptions): Promise<INodeExecutionData[]>;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.execute = execute;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ const utils_1 = require("../helpers/utils");
7
+ const formatters_1 = require("../helpers/formatters");
8
+ exports.description = [
9
+ {
10
+ displayName: 'HTML Content',
11
+ name: 'html',
12
+ type: 'string',
13
+ typeOptions: {
14
+ rows: 8,
15
+ },
16
+ required: true,
17
+ default: '',
18
+ placeholder: '<html><body><h1>Example</h1><p>Content</p></body></html>',
19
+ description: 'The raw HTML content to process',
20
+ displayOptions: {
21
+ show: {
22
+ operation: ['processRawHtml'],
23
+ },
24
+ },
25
+ },
26
+ {
27
+ displayName: 'Base URL',
28
+ name: 'baseUrl',
29
+ type: 'string',
30
+ default: 'https://example.com',
31
+ description: 'The base URL to use for resolving relative links',
32
+ displayOptions: {
33
+ show: {
34
+ operation: ['processRawHtml'],
35
+ },
36
+ },
37
+ },
38
+ {
39
+ displayName: 'Crawler Options',
40
+ name: 'crawlerOptions',
41
+ type: 'collection',
42
+ placeholder: 'Add Option',
43
+ default: {},
44
+ displayOptions: {
45
+ show: {
46
+ operation: ['processRawHtml'],
47
+ },
48
+ },
49
+ options: [
50
+ {
51
+ displayName: 'CSS Selector',
52
+ name: 'cssSelector',
53
+ type: 'string',
54
+ default: '',
55
+ placeholder: 'article.content',
56
+ description: 'CSS selector to focus on specific content (leave empty for full page)',
57
+ },
58
+ {
59
+ displayName: 'Exclude External Links',
60
+ name: 'excludeExternalLinks',
61
+ type: 'boolean',
62
+ default: false,
63
+ description: 'Whether to exclude external links from the result',
64
+ },
65
+ {
66
+ displayName: 'Excluded Tags',
67
+ name: 'excludedTags',
68
+ type: 'string',
69
+ default: '',
70
+ placeholder: 'nav,footer,aside',
71
+ description: 'Comma-separated list of HTML tags to exclude from processing',
72
+ },
73
+ {
74
+ displayName: 'Word Count Threshold',
75
+ name: 'wordCountThreshold',
76
+ type: 'number',
77
+ default: 0,
78
+ description: 'Minimum number of words for content to be included',
79
+ },
80
+ ],
81
+ },
82
+ {
83
+ displayName: 'Options',
84
+ name: 'options',
85
+ type: 'collection',
86
+ placeholder: 'Add Option',
87
+ default: {},
88
+ displayOptions: {
89
+ show: {
90
+ operation: ['processRawHtml'],
91
+ },
92
+ },
93
+ options: [
94
+ {
95
+ displayName: 'Include Media Data',
96
+ name: 'includeMedia',
97
+ type: 'boolean',
98
+ default: false,
99
+ description: 'Whether to include media data in output (images, videos)',
100
+ },
101
+ {
102
+ displayName: 'Verbose Response',
103
+ name: 'verboseResponse',
104
+ type: 'boolean',
105
+ default: false,
106
+ description: 'Whether to include detailed data in output (HTML, status codes, etc.)',
107
+ },
108
+ ],
109
+ },
110
+ ];
111
+ async function execute(items, nodeOptions) {
112
+ var _a;
113
+ const allResults = [];
114
+ for (let i = 0; i < items.length; i++) {
115
+ try {
116
+ const html = this.getNodeParameter('html', i, '');
117
+ const baseUrl = this.getNodeParameter('baseUrl', i, 'https://example.com');
118
+ const crawlerOptions = this.getNodeParameter('crawlerOptions', i, {});
119
+ const options = this.getNodeParameter('options', i, {});
120
+ if (!html) {
121
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'HTML content cannot be empty.', { itemIndex: i });
122
+ }
123
+ const crawlerConfig = (0, utils_1.createCrawlerRunConfig)(crawlerOptions);
124
+ const crawler = await (0, utils_1.getCrawl4aiClient)(this);
125
+ const result = await crawler.processRawHtml(html, baseUrl, crawlerConfig);
126
+ const formattedResult = (0, formatters_1.formatCrawlResult)(result, options.includeMedia, options.verboseResponse);
127
+ allResults.push({
128
+ json: formattedResult,
129
+ pairedItem: { item: i },
130
+ });
131
+ }
132
+ catch (error) {
133
+ if (this.continueOnFail()) {
134
+ const node = this.getNode();
135
+ const errorItemIndex = (_a = error.itemIndex) !== null && _a !== void 0 ? _a : i;
136
+ allResults.push({
137
+ json: items[i].json,
138
+ error: new n8n_workflow_1.NodeOperationError(node, error.message, { itemIndex: errorItemIndex }),
139
+ pairedItem: { item: i },
140
+ });
141
+ continue;
142
+ }
143
+ throw error;
144
+ }
145
+ }
146
+ return allResults;
147
+ }
148
+ //# sourceMappingURL=processRawHtml.operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processRawHtml.operation.js","sourceRoot":"","sources":["../../../../nodes/Crawl4aiBasicCrawler/actions/processRawHtml.operation.ts"],"names":[],"mappings":";;;AA0HA,0BA2DC;AA/KD,+CAAkD;AAIlD,4CAG0B;AAC1B,sDAA0D;AAG7C,QAAA,WAAW,GAAsB;IAC5C;QACE,WAAW,EAAE,cAAc;QAC3B,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE;YACX,IAAI,EAAE,CAAC;SACR;QACD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,0DAA0D;QACvE,WAAW,EAAE,iCAAiC;QAC9C,cAAc,EAAE;YACd,IAAI,EAAE;gBACJ,SAAS,EAAE,CAAC,gBAAgB,CAAC;aAC9B;SACF;KACF;IACD;QACE,WAAW,EAAE,UAAU;QACvB,IA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AC;YAG9C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;YAG1E,MAAM,eAAe,GAAG,IAAA,8BAAiB,EACvC,MAAM,EACN,OAAO,CAAC,YAAuB,EAC/B,OAAO,CAAC,eAA0B,CACnC,CAAC;YAGF,UAAU,CAAC,IAAI,CAAC;gBACd,IAAI,EAAE,eAAe;gBACrB,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACxB,CAAC,CAAC;QAEL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEf,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;gBAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5B,MAAM,cAAc,GAAG,MAAC,KAAa,CAAC,SAAS,mCAAI,CAAC,CAAC;gBACrD,UAAU,CAAC,IAAI,CAAC;oBACd,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;oBACnB,KAAK,EAAE,IAAI,iCAAkB,CAAC,IAAI,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oBAC5F,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;iBACxB,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
2
+ export declare function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.router = router;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const operations_1 = require("./operations");
6
+ async function router() {
7
+ const items = this.getInputData();
8
+ let returnData = [];
9
+ const node = this.getNode();
10
+ const operation = this.getNodeParameter('operation', 0);
11
+ const nodeOptions = this.getNodeParameter('options', 0, {});
12
+ const continueOnFail = this.continueOnFail();
13
+ try {
14
+ const executeFunction = operations_1.operations[operation];
15
+ if (!executeFunction) {
16
+ throw new n8n_workflow_1.NodeOperationError(node, `The operation "${operation}" is not supported!`, { itemIndex: 0 });
17
+ }
18
+ returnData = await executeFunction.call(this, items, nodeOptions);
19
+ }
20
+ catch (error) {
21
+ if (continueOnFail) {
22
+ returnData = items.map((item, index) => {
23
+ var _a;
24
+ return ({
25
+ json: item.json,
26
+ error: new n8n_workflow_1.NodeOperationError(node, error.message, { itemIndex: (_a = error.itemIndex) !== null && _a !== void 0 ? _a : index }),
27
+ pairedItem: { item: index },
28
+ });
29
+ });
30
+ }
31
+ else {
32
+ throw error;
33
+ }
34
+ }
35
+ return this.prepareOutputData(returnData);
36
+ }
37
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../nodes/Crawl4aiBasicCrawler/actions/router.ts"],"names":[],"mappings":";;AAYA,wBA0CC;AAlDD,+CAAkD;AAMlD,6CAA0C;AAEnC,KAAK,UAAU,MAAM;IAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAClC,IAAI,UAAU,GAAyB,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAG5B,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAW,CAAC;IAElE,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAwB,CAAC;IAEnF,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IAE7C,IAAI,CAAC;QAIH,MAAM,eAAe,GAAG,uBAAU,CAAC,SAAS,CAAC,CAAC;QAE9C,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,iCAAkB,CAAC,IAAI,EAAE,kBAAkB,SAAS,qBAAqB,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;QACzG,CAAC;QAGD,UAAU,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAGpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,cAAc,EAAE,CAAC;YAEnB,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;;gBAAC,OAAA,CAAC;oBACvC,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,IAAI,iCAAkB,CAAC,IAAI,EAAG,KAAe,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAC,KAAa,CAAC,SAAS,mCAAI,KAAK,EAAE,CAAC;oBAC/G,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;iBAC5B,CAAC,CAAA;aAAA,CAAC,CAAC;QACN,CAAC;aAAM,CAAC;YAEN,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAGD,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
3
+ <title>Crawl4AI Icon</title>
4
+ <g id="Crawl4AI" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <path d="M16,2 C8.268,2 2,8.268 2,16 C2,23.732 8.268,30 16,30 C23.732,30 30,23.732 30,16 C30,8.268 23.732,2 16,2 Z" id="Spider-Body" fill="#3498DB"></path>
6
+ <path d="M16,6 C10.477,6 6,10.477 6,16 C6,21.523 10.477,26 16,26 C21.523,26 26,21.523 26,16 C26,10.477 21.523,6 16,6 Z M16,22 C12.686,22 10,19.314 10,16 C10,12.686 12.686,10 16,10 C19.314,10 22,12.686 22,16 C22,19.314 19.314,22 16,22 Z" id="Web" fill="#FFFFFF"></path>
7
+ <circle id="Eye-1" fill="#FFFFFF" cx="13" cy="14" r="1.5"></circle>
8
+ <circle id="Eye-2" fill="#FFFFFF" cx="19" cy="14" r="1.5"></circle>
9
+ <!-- Spider legs -->
10
+ <path d="M4,8 C2,6 2,4 3,3 C4,2 6,2 8,4" id="Leg-1" stroke="#2980B9" stroke-width="1.5" stroke-linecap="round"></path>
11
+ <path d="M28,8 C30,6 30,4 29,3 C28,2 26,2 24,4" id="Leg-2" stroke="#2980B9" stroke-width="1.5" stroke-linecap="round"></path>
12
+ <path d="M4,24 C2,26 2,28 3,29 C4,30 6,30 8,28" id="Leg-3" stroke="#2980B9" stroke-width="1.5" stroke-linecap="round"></path>
13
+ <path d="M28,24 C30,26 30,28 29,29 C28,30 26,30 24,28" id="Leg-4" stroke="#2980B9" stroke-width="1.5" stroke-linecap="round"></path>
14
+ <path d="M4,16 C2,16 0,15 0,14 C0,13 2,12 4,12" id="Leg-5" stroke="#2980B9" stroke-width="1.5" stroke-linecap="round"></path>
15
+ <path d="M28,16 C30,16 32,15 32,14 C32,13 30,12 28,12" id="Leg-6" stroke="#2980B9" stroke-width="1.5" stroke-linecap="round"></path>
16
+ </g>
17
+ </svg>
@@ -0,0 +1,15 @@
1
+ import { Crawl4aiApiCredentials, CrawlerRunConfig, CrawlResult } from './interfaces';
2
+ export declare class Crawl4aiClient {
3
+ private apiClient;
4
+ private readonly credentials;
5
+ constructor(credentials: Crawl4aiApiCredentials);
6
+ private createApiClient;
7
+ crawlUrl(url: string, config: CrawlerRunConfig): Promise<CrawlResult>;
8
+ crawlMultipleUrls(urls: string[], config: CrawlerRunConfig): Promise<CrawlResult[]>;
9
+ processRawHtml(html: string, baseUrl: string, config: CrawlerRunConfig): Promise<CrawlResult>;
10
+ arun(url: string, options: any): Promise<CrawlResult>;
11
+ private formatBrowserConfig;
12
+ private formatCrawlerConfig;
13
+ close(): Promise<void>;
14
+ }
15
+ export declare function createCrawlerInstance(credentials: Crawl4aiApiCredentials): Promise<Crawl4aiClient>;
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Crawl4aiClient = void 0;
7
+ exports.createCrawlerInstance = createCrawlerInstance;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ class Crawl4aiClient {
10
+ constructor(credentials) {
11
+ this.credentials = credentials;
12
+ this.apiClient = this.createApiClient();
13
+ }
14
+ createApiClient() {
15
+ const baseURL = this.credentials.connectionMode === 'docker'
16
+ ? this.credentials.dockerUrl
17
+ : 'http://localhost:11235';
18
+ const client = axios_1.default.create({
19
+ baseURL,
20
+ timeout: 60000,
21
+ });
22
+ if (this.credentials.connectionMode === 'docker' && this.credentials.authenticationType) {
23
+ if (this.credentials.authenticationType === 'token' && this.credentials.apiToken) {
24
+ client.defaults.headers.common['Authorization'] = `Bearer ${this.credentials.apiToken}`;
25
+ }
26
+ else if (this.credentials.authenticationType === 'basic' && this.credentials.username && this.credentials.password) {
27
+ client.defaults.auth = {
28
+ username: this.credentials.username,
29
+ password: this.credentials.password
30
+ };
31
+ }
32
+ }
33
+ return client;
34
+ }
35
+ async crawlUrl(url, config) {
36
+ try {
37
+ const response = await this.apiClient.post('/crawl', {
38
+ urls: [url],
39
+ browser_config: this.formatBrowserConfig(config),
40
+ crawler_config: this.formatCrawlerConfig(config),
41
+ });
42
+ if (response.data && Array.isArray(response.data.results) && response.data.results.length > 0) {
43
+ return response.data.results[0];
44
+ }
45
+ return {
46
+ url,
47
+ success: false,
48
+ error_message: 'No result returned from Crawl4AI API',
49
+ };
50
+ }
51
+ catch (error) {
52
+ return {
53
+ url,
54
+ success: false,
55
+ error_message: error instanceof Error ? error.message : 'Unknown error occurred',
56
+ };
57
+ }
58
+ }
59
+ async crawlMultipleUrls(urls, config) {
60
+ try {
61
+ const response = await this.apiClient.post('/crawl', {
62
+ urls,
63
+ browser_config: this.formatBrowserConfig(config),
64
+ crawler_config: this.formatCrawlerConfig(config),
65
+ });
66
+ if (response.data && Array.isArray(response.data.results)) {
67
+ return response.data.results;
68
+ }
69
+ return urls.map(url => ({
70
+ url,
71
+ success: false,
72
+ error_message: 'No results returned from Crawl4AI API',
73
+ }));
74
+ }
75
+ catch (error) {
76
+ return urls.map(url => ({
77
+ url,
78
+ success: false,
79
+ error_message: error instanceof Error ? error.message : 'Unknown error occurred',
80
+ }));
81
+ }
82
+ }
83
+ async processRawHtml(html, baseUrl, config) {
84
+ try {
85
+ const rawUrl = `raw://${encodeURIComponent(html)}`;
86
+ const response = await this.apiClient.post('/crawl', {
87
+ urls: [rawUrl],
88
+ browser_config: this.formatBrowserConfig(config),
89
+ crawler_config: {
90
+ ...this.formatCrawlerConfig(config),
91
+ base_url: baseUrl,
92
+ },
93
+ });
94
+ if (response.data && Array.isArray(response.data.results) && response.data.results.length > 0) {
95
+ return response.data.results[0];
96
+ }
97
+ return {
98
+ url: baseUrl,
99
+ success: false,
100
+ error_message: 'No result returned from Crawl4AI API',
101
+ };
102
+ }
103
+ catch (error) {
104
+ return {
105
+ url: baseUrl,
106
+ success: false,
107
+ error_message: error instanceof Error ? error.message : 'Unknown error occurred',
108
+ };
109
+ }
110
+ }
111
+ async arun(url, options) {
112
+ var _a, _b;
113
+ try {
114
+ const crawlerConfig = {
115
+ cache_mode: options.cacheMode || 'ENABLED',
116
+ js_code: options.jsCode,
117
+ css_selector: options.cssSelector,
118
+ };
119
+ if (options.extractionStrategy) {
120
+ crawlerConfig.extraction_strategy = options.extractionStrategy;
121
+ }
122
+ if (options.extraArgs) {
123
+ Object.assign(crawlerConfig, options.extraArgs);
124
+ }
125
+ const requestBody = {
126
+ urls: [url],
127
+ browser_config: this.formatBrowserConfig(options.browserConfig || {}),
128
+ crawler_config: {
129
+ type: 'CrawlerRunConfig',
130
+ params: crawlerConfig,
131
+ },
132
+ };
133
+ const response = await this.apiClient.post('/crawl', requestBody);
134
+ if (response.data && Array.isArray(response.data.results) && response.data.results.length > 0) {
135
+ return response.data.results[0];
136
+ }
137
+ return {
138
+ url,
139
+ success: false,
140
+ error_message: 'No result returned from Crawl4AI API',
141
+ };
142
+ }
143
+ catch (error) {
144
+ return {
145
+ url,
146
+ success: false,
147
+ error_message: ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.detail) || error.message || 'Unknown error occurred',
148
+ };
149
+ }
150
+ }
151
+ formatBrowserConfig(config) {
152
+ var _a, _b;
153
+ return {
154
+ type: 'BrowserConfig',
155
+ params: {
156
+ browser_type: config.browserType || 'chromium',
157
+ headless: config.headless !== false,
158
+ browser_mode: 'dedicated',
159
+ use_managed_browser: false,
160
+ cdp_url: null,
161
+ debugging_port: 9222,
162
+ use_persistent_context: false,
163
+ user_data_dir: null,
164
+ chrome_channel: 'chromium',
165
+ channel: 'chromium',
166
+ proxy: null,
167
+ viewport_width: ((_a = config.viewport) === null || _a === void 0 ? void 0 : _a.width) || 1080,
168
+ viewport_height: ((_b = config.viewport) === null || _b === void 0 ? void 0 : _b.height) || 600,
169
+ accept_downloads: false,
170
+ downloads_path: null,
171
+ storage_state: null,
172
+ ignore_https_errors: true,
173
+ java_script_enabled: config.javaScriptEnabled !== false,
174
+ sleep_on_close: false,
175
+ verbose: true,
176
+ cookies: [],
177
+ headers: {},
178
+ user_agent: config.userAgent || "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/116.0.0.0 Safari/537.36",
179
+ user_agent_mode: "",
180
+ user_agent_generator_config: {},
181
+ text_mode: false,
182
+ light_mode: false,
183
+ extra_args: [],
184
+ host: "localhost",
185
+ enable_stealth: config.enable_stealth || false,
186
+ },
187
+ };
188
+ }
189
+ formatCrawlerConfig(config) {
190
+ const params = {
191
+ cache_mode: config.cacheMode || 'ENABLED',
192
+ stream: config.streamEnabled || false,
193
+ page_timeout: config.pageTimeout || config.timeout || 30000,
194
+ wait_until: 'domcontentloaded',
195
+ wait_for: config.waitFor || null,
196
+ js_code: config.jsCode,
197
+ js_only: config.jsOnly || false,
198
+ css_selector: config.cssSelector,
199
+ excluded_tags: config.excludedTags || [],
200
+ exclude_external_links: config.excludeExternalLinks || false,
201
+ check_robots_txt: config.checkRobotsTxt || false,
202
+ word_count_threshold: config.wordCountThreshold || 0,
203
+ session_id: config.sessionId,
204
+ only_text: false,
205
+ scan_full_page: false,
206
+ remove_overlay_elements: false,
207
+ simulate_user: false,
208
+ override_navigator: false,
209
+ magic: false,
210
+ };
211
+ if (config.extractionStrategy) {
212
+ params.extraction_strategy = config.extractionStrategy;
213
+ }
214
+ return {
215
+ type: 'CrawlerRunConfig',
216
+ params,
217
+ };
218
+ }
219
+ async close() {
220
+ }
221
+ }
222
+ exports.Crawl4aiClient = Crawl4aiClient;
223
+ async function createCrawlerInstance(credentials) {
224
+ return new Crawl4aiClient(credentials);
225
+ }
226
+ //# sourceMappingURL=apiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../../../nodes/Crawl4aiBasicCrawler/helpers/apiClient.ts"],"names":[],"mappings":";;;;;;AA6RA,sDAIC;AAjSD,kDAA6C;AAM7C,MAAa,cAAc;IAIzB,YAAY,WAAmC;QAC7C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IAKO,eAAe;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,KAAK,QAAQ;YAC1D,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS;YAC5B,CAAC,CAAC,wBAAwB,CAAC;QAE7B,MAAM,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YAC1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AM,CAAC,SAAS,IAAI,SAAS;YACzC,MAAM,EAAE,MAAM,CAAC,aAAa,IAAI,KAAK;YACrC,YAAY,EAAE,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO,IAAI,KAAK;YAC3D,UAAU,EAAE,kBAAkB;YAC9B,QAAQ,EAAG,MAAc,CAAC,OAAO,IAAI,IAAI;YACzC,OAAO,EAAE,MAAM,CAAC,MAAM;YACtB,OAAO,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;YAC/B,YAAY,EAAE,MAAM,CAAC,WAAW;YAChC,aAAa,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE;YACxC,sBAAsB,EAAE,MAAM,CAAC,oBAAoB,IAAI,KAAK;YAC5D,gBAAgB,EAAE,MAAM,CAAC,cAAc,IAAI,KAAK;YAChD,oBAAoB,EAAE,MAAM,CAAC,kBAAkB,IAAI,CAAC;YACpD,UAAU,EAAE,MAAM,CAAC,SAAS;YAC5B,SAAS,EAAE,KAAK;YAChB,cAAc,EAAE,KAAK;YACrB,uBAAuB,EAAE,KAAK;YAC9B,aAAa,EAAE,KAAK;YACpB,kBAAkB,EAAE,KAAK;YACzB,KAAK,EAAE,KAAK;SACb,CAAC;QAGF,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC9B,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,kBAAkB,CAAC;QACzD,CAAC;QAED,OAAO;YACL,IAAI,EAAE,kBAAkB;YACxB,MAAM;SACP,CAAC;IACJ,CAAC;IAKD,KAAK,CAAC,KAAK;IAEX,CAAC;CACF;AAlRD,wCAkRC;AAKM,KAAK,UAAU,qBAAqB,CACzC,WAAmC;IAEnC,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { IDataObject } from 'n8n-workflow';
2
+ import { CrawlResult } from './interfaces';
3
+ export declare function formatCrawlResult(result: CrawlResult, includeMedia?: boolean, verboseResponse?: boolean): IDataObject;
4
+ export declare function parseExtractedJson(result: CrawlResult): IDataObject | null;
5
+ export declare function formatExtractionResult(result: CrawlResult, extractedData: IDataObject | null, includeFullText?: boolean): IDataObject;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatCrawlResult = formatCrawlResult;
4
+ exports.parseExtractedJson = parseExtractedJson;
5
+ exports.formatExtractionResult = formatExtractionResult;
6
+ function formatCrawlResult(result, includeMedia = false, verboseResponse = false) {
7
+ const formattedResult = {
8
+ url: result.url,
9
+ success: result.success,
10
+ statusCode: result.statusCode || result.status_code || null,
11
+ title: result.title || '',
12
+ content: result.markdown || '',
13
+ text: result.text || '',
14
+ };
15
+ if (!result.success && result.error_message) {
16
+ formattedResult.error = result.error_message;
17
+ }
18
+ if (result.extracted_content) {
19
+ try {
20
+ formattedResult.extractedContent = JSON.parse(result.extracted_content);
21
+ }
22
+ catch (e) {
23
+ formattedResult.extractedContent = result.extracted_content;
24
+ }
25
+ }
26
+ if (result.links) {
27
+ formattedResult.links = {
28
+ internal: result.links.internal,
29
+ external: result.links.external,
30
+ };
31
+ }
32
+ if (includeMedia && result.media) {
33
+ formattedResult.media = {
34
+ images: result.media.images,
35
+ videos: result.media.videos,
36
+ };
37
+ }
38
+ if (verboseResponse) {
39
+ formattedResult.html = result.html || '';
40
+ formattedResult.cleanedHtml = result.cleaned_html || '';
41
+ formattedResult.crawlTime = result.crawl_time;
42
+ formattedResult.metadata = result.metadata || {};
43
+ }
44
+ return formattedResult;
45
+ }
46
+ function parseExtractedJson(result) {
47
+ if (!result.extracted_content) {
48
+ return null;
49
+ }
50
+ try {
51
+ return JSON.parse(result.extracted_content);
52
+ }
53
+ catch (error) {
54
+ return null;
55
+ }
56
+ }
57
+ function formatExtractionResult(result, extractedData, includeFullText = false) {
58
+ const formattedResult = {
59
+ url: result.url,
60
+ success: result.success,
61
+ statusCode: result.statusCode || result.status_code || null,
62
+ };
63
+ if (!result.success && result.error_message) {
64
+ formattedResult.error = result.error_message;
65
+ return formattedResult;
66
+ }
67
+ if (extractedData) {
68
+ Object.entries(extractedData).forEach(([key, value]) => {
69
+ formattedResult[key] = value;
70
+ });
71
+ }
72
+ else {
73
+ formattedResult.extractionFailed = true;
74
+ }
75
+ if (includeFullText) {
76
+ formattedResult.originalText = result.text || '';
77
+ formattedResult.title = result.title || '';
78
+ }
79
+ return formattedResult;
80
+ }
81
+ //# sourceMappingURL=formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../../nodes/Crawl4aiBasicCrawler/helpers/formatters.ts"],"names":[],"mappings":";;AAUA,8CAwDC;AAOD,gDAUC;AASD,wDAkCC;AApHD,SAAgB,iBAAiB,CAC/B,MAAmB,EACnB,eAAwB,KAAK,EAC7B,kBAA2B,KAAK;IAGhC,MAAM,eAAe,GAAgB;QACnC,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,IAAI,IAAI;QAC3D,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;QACzB,OAAO,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;QAC9B,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;KACxB,CAAC;IAGF,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QAC5C,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC;IAC/C,CAAC;IAGD,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC7B,IAAI,CAAC;YAEH,eAAe,CAAC,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC1E,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YAEX,eAAe,CAAC,gBAAgB,GAAG,MAAM,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