n8n-nodes-duckduckgo-search 30.0.2 → 30.0.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DuckDuckGo Search Node for n8n
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/n8n-nodes-duckduckgo-search.svg?v=30.0.2)](https://www.npmjs.com/package/n8n-nodes-duckduckgo-search)
3
+ [![npm version](https://img.shields.io/npm/v/n8n-nodes-duckduckgo-search.svg?v=30.0.4)](https://www.npmjs.com/package/n8n-nodes-duckduckgo-search)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
6
  A powerful and comprehensive n8n community node that seamlessly integrates DuckDuckGo search capabilities into your workflows. Search the web, find images, discover news, and explore videos - all with privacy-focused, reliable results.
@@ -61,11 +61,11 @@ function sleep(ms) {
61
61
  }
62
62
  function getRandomUserAgent() {
63
63
  const userAgents = [
64
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1',
65
- 'Mozilla/5.0 (Linux; Android 11; SM-G998U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.98 Mobile Safari/537.36',
66
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
67
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15',
68
- 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0',
64
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
65
+ 'Mozilla/5.0 (Linux; Android 14; SM-G998U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36',
66
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
67
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15',
68
+ 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0',
69
69
  ];
70
70
  return userAgents[Math.floor(Math.random() * userAgents.length)];
71
71
  }
@@ -28,7 +28,7 @@ async function directWebSearch(query, options = {}) {
28
28
  kp: options.safeSearch === 'strict' ? '1' : options.safeSearch === 'moderate' ? '-1' : '-2',
29
29
  }), {
30
30
  headers: {
31
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
31
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
32
32
  'Content-Type': 'application/x-www-form-urlencoded',
33
33
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
34
34
  'Accept-Language': 'en-US,en;q=0.9',
@@ -36,7 +36,7 @@ async function directWebSearch(query, options = {}) {
36
36
  'Cache-Control': 'no-cache',
37
37
  'Pragma': 'no-cache',
38
38
  },
39
- timeout: 10000,
39
+ timeout: 15000,
40
40
  });
41
41
  const results = [];
42
42
  const html = response.data;
@@ -64,8 +64,22 @@ async function directWebSearch(query, options = {}) {
64
64
  return { results };
65
65
  }
66
66
  catch (error) {
67
- console.error('Direct web search error:', error);
68
- throw new Error(`Direct web search failed: ${error.message}`);
67
+ console.error('Direct web search error:', error.message);
68
+ if (error.code === 'ECONNABORTED') {
69
+ throw new Error('Web search request timed out. Please try again.');
70
+ }
71
+ else if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
72
+ throw new Error('Unable to connect to DuckDuckGo. Please check your internet connection.');
73
+ }
74
+ else if (error.response && error.response.status === 429) {
75
+ throw new Error('Too many requests. Please wait a moment before trying again.');
76
+ }
77
+ else if (error.response && error.response.status >= 500) {
78
+ throw new Error('DuckDuckGo server error. Please try again later.');
79
+ }
80
+ else {
81
+ throw new Error(`Web search failed: ${error.message}`);
82
+ }
69
83
  }
70
84
  }
71
85
  exports.directWebSearch = directWebSearch;
@@ -79,12 +93,12 @@ async function directImageSearch(query, options = {}) {
79
93
  const searchUrl = `https://duckduckgo.com/?${searchParams.toString()}`;
80
94
  const response = await axios_1.default.get(searchUrl, {
81
95
  headers: {
82
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
96
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
83
97
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
84
98
  'Accept-Language': 'en-US,en;q=0.9',
85
99
  'Accept-Encoding': 'gzip, deflate, br',
86
100
  },
87
- timeout: 10000,
101
+ timeout: 15000,
88
102
  });
89
103
  const vqdMatch = response.data.match(/vqd=([\d-]+)/);
90
104
  const vqd = vqdMatch ? vqdMatch[1] : null;
@@ -109,14 +123,14 @@ async function directImageSearch(query, options = {}) {
109
123
  });
110
124
  const imageResponse = await axios_1.default.get(`https://duckduckgo.com/i.js?${imageParams.toString()}`, {
111
125
  headers: {
112
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
126
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
113
127
  'Accept': 'application/json, text/javascript, */*; q=0.01',
114
128
  'Accept-Language': 'en-US,en;q=0.9',
115
129
  'Accept-Encoding': 'gzip, deflate, br',
116
130
  'Referer': searchUrl,
117
131
  'X-Requested-With': 'XMLHttpRequest',
118
132
  },
119
- timeout: 10000,
133
+ timeout: 15000,
120
134
  });
121
135
  const imageData = imageResponse.data;
122
136
  const results = [];
@@ -138,25 +152,43 @@ async function directImageSearch(query, options = {}) {
138
152
  return { results };
139
153
  }
140
154
  catch (error) {
141
- console.error('Direct image search error:', error);
142
- const webResults = await directWebSearch(`${query} images photos`, options);
143
- return {
144
- results: webResults.results.map(result => ({
145
- title: result.title,
146
- url: result.url,
147
- thumbnail: '',
148
- source: result.url,
149
- })),
150
- };
155
+ console.error('Direct image search error:', error.message);
156
+ try {
157
+ console.log('Falling back to web search for image content...');
158
+ const webResults = await directWebSearch(`${query} images photos pictures`, options);
159
+ return {
160
+ results: webResults.results.map(result => ({
161
+ title: result.title,
162
+ url: result.url,
163
+ thumbnail: '',
164
+ source: result.url,
165
+ })),
166
+ };
167
+ }
168
+ catch (fallbackError) {
169
+ if (error.code === 'ECONNABORTED') {
170
+ throw new Error('Image search request timed out. Please try again.');
171
+ }
172
+ else if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
173
+ throw new Error('Unable to connect to DuckDuckGo for image search. Please check your internet connection.');
174
+ }
175
+ else if (error.response && error.response.status === 429) {
176
+ throw new Error('Too many image search requests. Please wait a moment before trying again.');
177
+ }
178
+ else {
179
+ throw new Error(`Image search failed: ${error.message}`);
180
+ }
181
+ }
151
182
  }
152
183
  }
153
184
  exports.directImageSearch = directImageSearch;
154
185
  function getSafeSearchString(value) {
155
186
  switch (value) {
156
- case 2:
187
+ case 0:
157
188
  return 'strict';
158
- case 1:
189
+ case -1:
159
190
  return 'moderate';
191
+ case -2:
160
192
  default:
161
193
  return 'off';
162
194
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-duckduckgo-search",
3
- "version": "30.0.2",
3
+ "version": "30.0.4",
4
4
  "description": "A powerful and comprehensive n8n community node that seamlessly integrates DuckDuckGo search capabilities into your workflows. Search the web, find images, discover news, and explore videos - all with privacy-focused, reliable results.",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -68,7 +68,6 @@
68
68
  "@types/request-promise-native": "~1.0.15",
69
69
  "@types/uuid": "^9.0.8",
70
70
  "@typescript-eslint/parser": "~5.45",
71
- "axios": "^1.9.0",
72
71
  "babel-jest": "^29.7.0",
73
72
  "copyfiles": "^2.4.1",
74
73
  "eslint-plugin-n8n-nodes-base": "^1.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-duckduckgo-search",
3
- "version": "30.0.2",
3
+ "version": "30.0.4",
4
4
  "description": "A powerful and comprehensive n8n community node that seamlessly integrates DuckDuckGo search capabilities into your workflows. Search the web, find images, discover news, and explore videos - all with privacy-focused, reliable results.",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -68,7 +68,6 @@
68
68
  "@types/request-promise-native": "~1.0.15",
69
69
  "@types/uuid": "^9.0.8",
70
70
  "@typescript-eslint/parser": "~5.45",
71
- "axios": "^1.9.0",
72
71
  "babel-jest": "^29.7.0",
73
72
  "copyfiles": "^2.4.1",
74
73
  "eslint-plugin-n8n-nodes-base": "^1.11.0",