Skip to content

luminati-io/duckduckgo-api

Repository files navigation

DuckDuckGo Search Scraper

Promo

This repository offers two solutions for extracting data from DuckDuckGo Search Engine Results Pages (SERPs):

  • Free DuckDuckGo Scraper: A tool for scraping DuckDuckGo Search Results at small scale
  • Enterprise-grade DuckDuckGo SERP API: A scalable, production-ready solution for high-volume, real-time data extraction (part of Bright Data's SERP Scraper API)

Table of Contents

Free DuckDuckGo SERP Scraper

The Free DuckDuckGo SERP Scraper offers a straightforward method for collecting search result data on a smaller scale. It’s perfect if you need limited data without the overhead of managing proxies or handling high volumes.

free-duckduckgo-serp-scraper

Setup Requirements

  • Python 3.9+Download Python
  • Required Packages:
    • selenium (for browser automation)
    • webdriver-manager (for managing browser drivers)
    • beautifulsoup4 (for HTML parsing)

Install the packages using:

pip install selenium webdriver-manager beautifulsoup4

New to Web Scraping?
Kickstart your journey with our Beginner’s Guide to Web Scraping with Python. Then, level up with our Using Selenium for Web Scraping tutorial, and if you’re already comfortable with Selenium, take your skills further with our advanced SeleniumBase guide.

Quick Start Guide

  1. Open the duckduckgo-serp-scraper.py file.

  2. Customize the search terms as needed:

    SEARCH_TERMS = [
        "ergonomic office chair",
        "coffee maker",
    ]
  3. Run the script to begin scraping.

Sample Output

Below is a preview of the scraper output:

free-duckduckgo-serp-scraper-output

Limitations

Keep in mind that while the free scraper is great for basic tasks, it has some important limitations:

  • High risk of IP blocking with frequent use
  • Limited request volume capacity
  • Frequent CAPTCHA interruptions
  • Not suitable for production environments

For a scalable and stable solution, consider Bright Data's dedicated API detailed below 👇

DuckDuckGo SERP API

The DuckDuckGo SERP API is part of Bright Data’s comprehensive SERP Scraper API suite. It leverages our industry-leading DuckDuckGo proxy infrastructure to deliver real-time DuckDuckGo search results with a single API call.

Key Benefits

  • Global Accuracy: Get tailored results for specific locations worldwide.
  • Pay-Per-Success: You pay only for successful requests.
  • Real-Time Data: Access up-to-date search results in seconds.
  • Unlimited Scalability: Handle high-volume scraping effortlessly.
  • Cost-Efficient: No need for expensive infrastructure.
  • Reliable Performance: Advanced anti-blocking technology ensures consistent results.
  • 24/7 Expert Support: Get assistance whenever you need it.

📌 Try Before You Buy: Experience our solution with the SERP API Live Demo.

bright-data-serp-api-playground

Getting Started

  1. Create a Bright Data account (new users receive a $5 credit).
  2. Generate your API key.
  3. Follow our step-by-step configuration guide to integrate the SERP API.

Implementation Methods

You can integrate the DuckDuckGo SERP API into your workflow using one of two approaches:

Direct API Access

Make a direct request to Bright Data’s API endpoint.

cURL Example

curl https://api.brightdata.com/request \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer API_TOKEN" \
  -d '{
        "zone": "ZONE_NAME",
        "url": "https://duckduckgo.com/?q=budget+laptops+under+500+gbp&kl=uk-en&kad=en-gb&df=w",
        "format": "raw"
      }'

Python Example

import requests

url = "https://api.brightdata.com/request"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer API_TOKEN"
}

payload = {
    "zone": "ZONE_NAME",
    "url": "https://duckduckgo.com/?q=budget+laptops+under+500+gbp&kl=uk-en&kad=en-gb&df=w",
    "format": "raw",
}

response = requests.post(url, headers=headers, json=payload)

with open("duckduckgo-scraper-api-result.html", "w", encoding="utf-8") as file:
    file.write(response.text)

print("Response saved!")

Native Proxy-Based Access

Use proxy routing for direct access to search results.

cURL Example

curl -i \
  --proxy brd.superproxy.io:33335 \
  --proxy-user brd-customer-<CUSTOMER_ID>-zone-<ZONE_NAME>:<ZONE_PASSWORD> \
  -k \
  "https://duckduckgo.com/?q=budget+laptops+under+500+gbp&kl=uk-en&kad=en-gb&df=w"

Python Example

import requests
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

host = "brd.superproxy.io"
port = 33335
username = "brd-customer-<CUSTOMER_ID>-zone-<ZONE_NAME>"
password = "<ZONE_PASSWORD>"
proxy_url = f"http://{username}:{password}@{host}:{port}"

proxies = {
    "http": proxy_url,
    "https": proxy_url
}

url = "https://duckduckgo.com/?q=budget+laptops+under+500+gbp&kl=uk-en&kad=en-gb&df=w"
response = requests.get(url, proxies=proxies, verify=False)

with open("duckduckgo-scraper-api-result.html", "w", encoding="utf-8") as file:
    file.write(response.text)

print("Response saved!")

Note: For production use with the native proxy approach, installing Bright Data’s SSL certificate is recommended. Refer to our SSL Certificate Guide for details.

👉 For a full preview of the HTML output, see the complete result.

DuckDuckGo Search Query Parameters

Fine-tune your search results by using various query parameters.

Localization

Country and Language (kl)

Specifies the country and language for search results.

Example:

curl --proxy brd.superproxy.io:33335 \
     --proxy-user brd-customer-<id>-zone-<zone>:<password> \
     "https://duckduckgo.com/?q=best+coffee+brands&kl=it-it"

This returns search results tailored for Italy.

Interface Language (kad)

Controls the language of the DuckDuckGo interface.

Example:

https://duckduckgo.com/?q=photo+editing+tools&kad=de

This keeps the search content in English while displaying the interface in German.

Safe Search Configuration (kp)

Adjusts content filtering for adult material.

Values

  • 1 – Strict Safe Search
  • -1 – Moderate
  • -2 – Off

Example:

https://duckduckgo.com/?q=swimsuit&kp=1

Returns only family-safe results for "swimsuit”.

Time Range Filtering (df)

Limits search results to a specific time frame.

Values

  • d – Past day
  • w – Past week
  • m – Past month
  • y – Past year
  • Custom range: e.g., 2025-03-01..2025-03-10

Example:

https://duckduckgo.com/?q=iphone+15+review&df=w

Shows only recent reviews (within the last week).

Device Targeting (brd_mobile)

Simulate searches from various device types.

Options

  • 0 – Desktop (default)
  • 1 – Random mobile device
  • ios or iphone – iPhone
  • ipad or ios_tablet – iPad
  • android – Android phone
  • android_tablet – Android tablet

Example:

https://duckduckgo.com/?q=top+travel+apps&brd_mobile=ios

This simulates an iPhone user. You might see app store links, mobile-focused content, or AMP pages.

Browser Emulation (brd_browser)

Specify the browser’s user-agent for the request.

Options

  • Default (random browser)
  • chrome – Google Chrome
  • safari – Safari
  • firefox – Mozilla Firefox (not compatible with brd_mobile=1)

Example:

https://duckduckgo.com/?q=best+vpn+services&brd_browser=safari

This simulates a Safari browser, providing insights into how content is displayed and ranked on that platform.

Practical Example

You're monitoring competitors' pricing pages for "budget laptops under £500" in the UK, targeting mobile users.

Your goal is to:

  • Simulate a UK-based mobile user
  • Get localized English results (UK-specific retailers, currency)
  • Use a mobile Chrome user agent (to capture mobile-specific results like AMP pages)
  • Focus on recent product listicles or deals

Combine these requirements in a single cURL command:

curl --proxy brd.superproxy.io:33335 \
     --proxy-user brd-customer-<CUSTOMER_ID>-zone-<ZONE_NAME>:<ZONE_PASSWORD> \
     "https://duckduckgo.com/?\
q=budget+laptops+under+500+gbp&\
kl=uk-en&\
kad=en-gb&\
df=w&\
brd_mobile=android&\
brd_browser=chrome"

🎯 This fetches mobile-first, localized, and recent content.

Support & Resources

About

Scrape DuckDuckGo search results using a free Python scraper or scale with Bright Data’s enterprise-grade DuckDuckGo SERP API.

Topics

Resources

Stars

Watchers

Forks