ts-duckduckgo-search
v0.3.1
Published
DuckDuckGo search scraper with TypeScript API
Downloads
39
Maintainers
Readme
DuckDuckGo Search Scraper
TypeScript wrapper for scraping DuckDuckGo results from the lite HTML endpoint.
Getting Started
npm install
npm run buildUsage
import { searchDuckDuckGo } from 'ts-duckduckgo-search';
const results = await searchDuckDuckGo('privacy focused search');
console.log(results);
/*
[
{
title: 'DuckDuckGo — Privacy, simplified.',
url: 'https://duckduckgo.com/',
description: 'DuckDuckGo is an internet search engine...'
},
...
]
*/Options
await searchDuckDuckGo('typescript', {
maxResults: 20,
locale: 'us-en',
safeSearch: 'strict',
});maxResults– Maximum number of results to return (default10).locale– Locale string passed as theklparameter (us-en,pt-pt, etc.).safeSearch– Safe-search level (off,moderate,strict).offset– Result offset in multiples of 50, passed as thesparameter.userAgent– Custom user-agent header.signal–AbortSignalused to cancel the underlying fetch.
Testing
npm test