ddg-lite
v1.0.0
Published
A lightweight, hybrid ESM/CJS DuckDuckGo search results scraper.
Maintainers
Readme
ddg-lite is a powerful, dependency-light web scraper for retrieving search results from DuckDuckGo Lite. Built with built-in anti-ban mechanisms like highly randomized User-Agents and programmatic delays, it is the perfect zero-configuration search API alternative for Node.js developers.
Installation
npm install ddg-liteUsage
Simple Usage
const { search } = require("ddg-lite");
(async () => {
const res = await search("gilangf3000", {
maxPages: 2,
delay: 1000
});
console.log(res.results);
})();ESM Usage (ES Modules)
Because this package is hybrid, you can use import natively:
import { search, createClient } from "ddg-lite";
(async () => {
const res = await search("gilangf3000", {
maxPages: 1,
delay: 1000
});
console.log(res.results);
})();Modular Client Usage
const { createClient } = require("ddg-lite");
const ddg = createClient();
(async () => {
const res = await ddg.search("openai");
console.log(res.results);
})();Options
maxPages: Number of pages to fetch (default: 3).delay: Time to wait between requests in milliseconds (default: 1500).
Ethical Usage & Compliance
This library is designed for educational purposes and lightweight personal use. To ensure you do not violate DuckDuckGo's Terms of Service or abuse their infrastructure, please adhere to the following guidelines:
- Respect Rate Limits: DuckDuckGo provides the Lite version for users with low bandwidth, not for heavy automated scraping. The built-in
delay(default 1500ms) is crucial. Do not lower this delay aggressively. - Identify Your Traffic: While this library uses randomized User-Agents to function correctly, if you plan to use this for any prolonged programmatic access, consider using a custom User-Agent that identifies your bot and provides contact information.
- Do Not Overload Servers: Limit the
maxPagesparameter. Fetching excessive pages puts unnecessary load on the search engine. - No Commercial Use: Do not use this scraper to build a commercial product or search API wrapper. If you need search data for commercial purposes, use an official, paid API provider.
By using this software, you agree to use it responsibly and at your own risk. The authors are not responsible for any misuse or violation of website terms of service.
Project Structure
index.js: Main entry point.lib/duckduckgo.js: Scraper logic.lib/utils.js: Utility functions.lib/useragents.js: User-Agent generator.
