Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

duck-duck-scrape

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duck-duck-scrape - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

6

CHANGELOG.md

@@ -8,2 +8,5 @@ # Changelog

## [Unreleased]
## [2.1.3] - 2021-09-13
### Fixed:
- Search news and videos sanity checking
## [2.1.2] - 2021-08-08

@@ -33,3 +36,3 @@ ### Fixed:

[Unreleased]: https://github.com/Snazzah/duck-duck-scrape/compare/v2.1.2...HEAD
[Unreleased]: https://github.com/Snazzah/duck-duck-scrape/compare/v2.1.3...HEAD
[1.0.3]: https://github.com/Snazzah/duck-duck-scrape/releases/tag/v1.0.3

@@ -41,1 +44,2 @@ [2.0.0]: https://github.com/Snazzah/duck-duck-scrape/compare/v1.0.3...v2.0.0

[2.1.2]: https://github.com/Snazzah/duck-duck-scrape/compare/v2.1.0...v2.1.2
[2.1.3]: https://github.com/Snazzah/duck-duck-scrape/compare/v2.1.2...v2.1.3

6

lib/search/images.js

@@ -125,3 +125,3 @@ "use strict";

if (!vqd)
vqd = await util_1.getVQD(query, 'web', needleOptions);
vqd = await (0, util_1.getVQD)(query, 'web', needleOptions);
const filters = [

@@ -143,3 +143,3 @@ options.size ? `size:${options.size}` : '',

};
const response = await needle_1.default('get', `https://duckduckgo.com/i.js?${util_1.queryString(queryObject)}`, needleOptions);
const response = await (0, needle_1.default)('get', `https://duckduckgo.com/i.js?${(0, util_1.queryString)(queryObject)}`, needleOptions);
if (response.statusCode === 403)

@@ -153,3 +153,3 @@ throw new Error('A server error occurred!');

...image,
title: html_entities_1.decode(image.title)
title: (0, html_entities_1.decode)(image.title)
}))

@@ -156,0 +156,0 @@ };

@@ -33,3 +33,3 @@ "use strict";

if (!vqd)
vqd = await util_1.getVQD(query, 'web', needleOptions);
vqd = await (0, util_1.getVQD)(query, 'web', needleOptions);
const queryObject = {

@@ -45,6 +45,6 @@ l: options.locale,

};
const response = await needle_1.default('get', `https://duckduckgo.com/news.js?${util_1.queryString(queryObject)}`, needleOptions);
const response = await (0, needle_1.default)('get', `https://duckduckgo.com/news.js?${(0, util_1.queryString)(queryObject)}`, needleOptions);
if (response.statusCode === 403)
throw new Error('A server error occurred!');
const newsResult = util_1.ensureJSON(response.body);
const newsResult = (0, util_1.ensureJSON)(response.body);
return {

@@ -55,7 +55,7 @@ noResults: !newsResult.results.length,

date: article.date,
excerpt: html_entities_1.decode(article.excerpt),
excerpt: (0, html_entities_1.decode)(article.excerpt),
image: article.image,
relativeTime: article.relative_time,
syndicate: article.syndicate,
title: html_entities_1.decode(article.title),
title: (0, html_entities_1.decode)(article.title),
url: article.url,

@@ -80,3 +80,3 @@ isOld: !!article.is_old

throw new TypeError('Search locale must be a string!');
if (options.time && Object.values(util_1.SearchTimeType).includes(options.time))
if (options.time && !Object.values(util_1.SearchTimeType).includes(options.time))
throw new TypeError(`${options.time} is an invalid time filter!`);

@@ -83,0 +83,0 @@ if (options.vqd && !/\d-\d+-\d+/.test(options.vqd))

@@ -40,3 +40,3 @@ "use strict";

if (!vqd)
vqd = await util_1.getVQD(query, 'web', needleOptions);
vqd = await (0, util_1.getVQD)(query, 'web', needleOptions);
const queryObject = {

@@ -59,3 +59,3 @@ q: query,

};
const response = await needle_1.default('get', `https://duckduckgo.com/d.js?${util_1.queryString(queryObject)}`, needleOptions);
const response = await (0, needle_1.default)('get', `https://duckduckgo.com/d.js?${(0, util_1.queryString)(queryObject)}`, needleOptions);
if (response.body.includes('DDG.deep.is506'))

@@ -90,3 +90,3 @@ throw new Error('A server error occurred!');

title: search.t,
description: html_entities_1.decode(search.a),
description: (0, html_entities_1.decode)(search.a),
rawDescription: search.a,

@@ -104,3 +104,3 @@ hostname: search.i,

results.images = imagesResult.results.map((i) => {
i.title = html_entities_1.decode(i.title);
i.title = (0, html_entities_1.decode)(i.title);
return i;

@@ -115,7 +115,7 @@ });

date: article.date,
excerpt: html_entities_1.decode(article.excerpt),
excerpt: (0, html_entities_1.decode)(article.excerpt),
image: article.image,
relativeTime: article.relative_time,
syndicate: article.syndicate,
title: html_entities_1.decode(article.title),
title: (0, html_entities_1.decode)(article.title),
url: article.url,

@@ -133,4 +133,4 @@ isOld: !!article.is_old

url: video.content,
title: html_entities_1.decode(video.title),
description: html_entities_1.decode(video.description),
title: (0, html_entities_1.decode)(video.title),
description: (0, html_entities_1.decode)(video.description),
image: video.images.large || video.images.medium || video.images.small || video.images.motion,

@@ -201,5 +201,5 @@ duration: video.duration,

};
const response = await needle_1.default('get', `https://duckduckgo.com/ac/?${util_1.queryString(queryObject)}`, needleOptions);
return util_1.ensureJSON(response.body);
const response = await (0, needle_1.default)('get', `https://duckduckgo.com/ac/?${(0, util_1.queryString)(queryObject)}`, needleOptions);
return (0, util_1.ensureJSON)(response.body);
}
exports.autocomplete = autocomplete;

@@ -65,3 +65,3 @@ "use strict";

if (!vqd)
vqd = await util_1.getVQD(query, 'web', needleOptions);
vqd = await (0, util_1.getVQD)(query, 'web', needleOptions);
const filters = [

@@ -82,6 +82,6 @@ options.time && options.time !== 'a' ? `publishedAfter:${options.time}` : '',

};
const response = await needle_1.default('get', `https://duckduckgo.com/v.js?${util_1.queryString(queryObject)}`, needleOptions);
const response = await (0, needle_1.default)('get', `https://duckduckgo.com/v.js?${(0, util_1.queryString)(queryObject)}`, needleOptions);
if (response.statusCode === 403)
throw new Error('A server error occurred!');
const videosResult = util_1.ensureJSON(response.body);
const videosResult = (0, util_1.ensureJSON)(response.body);
return {

@@ -92,4 +92,4 @@ noResults: !videosResult.results.length,

url: video.content,
title: html_entities_1.decode(video.title),
description: html_entities_1.decode(video.description),
title: (0, html_entities_1.decode)(video.title),
description: (0, html_entities_1.decode)(video.description),
image: video.images.large || video.images.medium || video.images.small || video.images.motion,

@@ -118,5 +118,5 @@ duration: video.duration,

throw new TypeError('Search locale must be a string!');
if (options.time && Object.values(util_1.SearchTimeType).includes(options.time))
if (options.time && !Object.values(util_1.SearchTimeType).includes(options.time))
throw new TypeError(`${options.time} is an invalid time filter!`);
if (options.definition && Object.values(VideoDefinition).includes(options.definition))
if (options.definition && !Object.values(VideoDefinition).includes(options.definition))
throw new TypeError(`${options.definition} is an invalid video definition!`);

@@ -123,0 +123,0 @@ if (options.duration && !Object.values(VideoDuration).includes(options.duration))

@@ -24,4 +24,4 @@ "use strict";

throw new Error('Currency `to` cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/currency/${amount}/${from}/${to}`, needleOptions);
const result = util_1.parseSpiceBody(response.body);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/currency/${amount}/${from}/${to}`, needleOptions);
const result = (0, util_1.parseSpiceBody)(response.body);
if (result.headers.status !== '0')

@@ -28,0 +28,0 @@ throw new Error(result.headers.description);

@@ -20,3 +20,3 @@ "use strict";

throw new Error('Word cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/dictionary/audio/${word}`, needleOptions);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/dictionary/audio/${word}`, needleOptions);
if (response.body.toString() === 'ddg_spice_dictionary_audio();\n')

@@ -23,0 +23,0 @@ return [];

@@ -20,8 +20,8 @@ "use strict";

throw new Error('Word cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/dictionary/definition/${word}`, needleOptions);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/dictionary/definition/${word}`, needleOptions);
if (response.body.toString() === 'ddg_spice_dictionary_definition();\n')
return [];
const result = util_1.parseSpiceBody(response.body);
const result = (0, util_1.parseSpiceBody)(response.body);
return result;
}
exports.dictionaryDefinition = dictionaryDefinition;

@@ -20,3 +20,3 @@ "use strict";

throw new Error('Word cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/dictionary/hyphenation/${word}`, needleOptions);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/dictionary/hyphenation/${word}`, needleOptions);
if (response.body.toString() === 'ddg_spice_dictionary_hyphenation();\n')

@@ -23,0 +23,0 @@ return [];

@@ -20,3 +20,3 @@ "use strict";

throw new Error('Word cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/dictionary/pronunciation/${word}`, needleOptions);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/dictionary/pronunciation/${word}`, needleOptions);
if (response.body.toString() === 'ddg_spice_dictionary_pronunciation();\n')

@@ -23,0 +23,0 @@ return [];

@@ -61,6 +61,6 @@ "use strict";

throw new Error('Domain cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/dns/${recordType}/${domain}`, needleOptions);
const result = util_1.parseSpiceBody(response.body);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/dns/${recordType}/${domain}`, needleOptions);
const result = (0, util_1.parseSpiceBody)(response.body);
return result;
}
exports.dns = dns;

@@ -23,7 +23,7 @@ "use strict";

throw new Error('Locale cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/forecast/${encodeURIComponent(query)}/${locale}`, needleOptions);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/forecast/${encodeURIComponent(query)}/${locale}`, needleOptions);
if (response.body.toString() === 'ddg_spice_forecast();\n')
return null;
return util_1.parseSpiceBody(response.body, /ddg_spice_[\w]+\(\n?((?:.|\n)+)\n?\);?/);
return (0, util_1.parseSpiceBody)(response.body, /ddg_spice_[\w]+\(\n?((?:.|\n)+)\n?\);?/);
}
exports.forecast = forecast;

@@ -20,4 +20,4 @@ "use strict";

throw new Error('Symbol cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/stocks/${symbol}`, needleOptions);
const result = util_1.parseSpiceBody(response.body);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/stocks/${symbol}`, needleOptions);
const result = (0, util_1.parseSpiceBody)(response.body);
if (result.Outcome !== 'Success')

@@ -24,0 +24,0 @@ throw new Error(`${result.Outcome}: ${result.Message}`);

@@ -20,5 +20,5 @@ "use strict";

throw new Error('Query cannot be empty!');
const response = await needle_1.default('get', `${util_1.SPICE_BASE}/time/${query}`, needleOptions);
return util_1.parseSpiceBody(response.body);
const response = await (0, needle_1.default)('get', `${util_1.SPICE_BASE}/time/${query}`, needleOptions);
return (0, util_1.parseSpiceBody)(response.body);
}
exports.time = time;

@@ -49,3 +49,3 @@ "use strict";

try {
const response = await needle_1.default('get', `https://duckduckgo.com/?${queryString({ q: query, ia })}`, options);
const response = await (0, needle_1.default)('get', `https://duckduckgo.com/?${queryString({ q: query, ia })}`, options);
return exports.VQD_REGEX.exec(response.body)[1];

@@ -52,0 +52,0 @@ }

{
"name": "duck-duck-scrape",
"version": "2.1.2",
"version": "2.1.3",
"description": "Search from DuckDuckGo and use it's spice APIs.",

@@ -43,3 +43,3 @@ "main": "./lib/index.js",

"html-entities": "^2.3.2",
"needle": "^2.6.0"
"needle": "^3.0.0"
},

@@ -53,3 +53,3 @@ "devDependencies": {

"eslint-config-prettier": "^8.0.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.0",

@@ -60,5 +60,5 @@ "lint-staged": "^11.0.0",

"typedoc": "^0.21.0",
"typescript": "4.3",
"typescript": "4.4",
"yarn": "^1.22.10"
}
}

@@ -134,3 +134,3 @@ import { decode } from 'html-entities';

if (options.time && Object.values(SearchTimeType).includes(options.time))
if (options.time && !Object.values(SearchTimeType).includes(options.time))
throw new TypeError(`${options.time} is an invalid time filter!`);

@@ -137,0 +137,0 @@

@@ -178,6 +178,6 @@ import { decode } from 'html-entities';

if (options.time && Object.values(SearchTimeType).includes(options.time))
if (options.time && !Object.values(SearchTimeType).includes(options.time))
throw new TypeError(`${options.time} is an invalid time filter!`);
if (options.definition && Object.values(VideoDefinition).includes(options.definition))
if (options.definition && !Object.values(VideoDefinition).includes(options.definition))
throw new TypeError(`${options.definition} is an invalid video definition!`);

@@ -184,0 +184,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc