Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8370369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:53:59+00:00 2026-06-09T13:53:59+00:00

Edit I now realize the API is simply inadequate and is not even working.

  • 0

Edit I now realize the API is simply inadequate and is not even working.
I would like to redirect my question, I want to be able to auto-magically search duckduckgo using their “I’m feeling ducky”. So that I can search for “stackoverflow” for instance and get the main page (“https://stackoverflow.com/“) as my result.

I am using the duckduckgo API. Here

And I found that when using:

r = duckduckgo.query("example")

The results do not reflect a manual search, namely:

for result in r.results:
    print result

Results in:

>>> 
>>> 

Nothing.

And looking for an index in results results in an out of bounds error, since it is empty.

How am I supposed to get results for my search?

It seems the API (according to its documented examples) is supposed to answer questions and give a sort of “I’m feeling ducky” in the form of r.answer.text

But the website is made in such a way that I can not search it and parse results using normal methods.

I would like to know how I am supposed to parse search results with this API or any other method from this site.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:54:01+00:00Added an answer on June 9, 2026 at 1:54 pm

    If you visit DuckDuck Go API Page, you will find some notes about using the API. The first notes says clearly that:

    As this is a Zero-click Info API, most deep queries (non topic names)
    will be blank.

    An here’s the list of those fields:

    Abstract: ""
    AbstractText: ""
    AbstractSource: ""
    AbstractURL: ""
    Image: ""
    Heading: ""
    Answer: ""
    Redirect: ""
    AnswerType: ""
    Definition: ""
    DefinitionSource: ""
    DefinitionURL: ""
    RelatedTopics: [ ]
    Results: [ ]
    Type: ""
    

    So it might be a pity, but their API just truncates a bunch of results and does not give them to you; possibly to work faster, and seems like nothing can be done except using DuckDuckGo.com.

    So, obviously, in that case API is not the way to go.

    As for me, I see only one way out left: retrieving raw html from duckduckgo.com and parsing it using, e.g. html5lib (it worth to mention that their html is well-structured).

    It also worth to mention that parsing html pages is not the most reliable way to scrap data, because html structure can change, while API usually stays stable until changes are publicly announced.

    Here’s and example of how can be such parsing achieved with BeautifulSoup:

    from BeautifulSoup import BeautifulSoup
    import urllib
    import re
    
    site = urllib.urlopen('http://duckduckgo.com/?q=example')
    data = site.read()
    
    parsed = BeautifulSoup(data)
    topics = parsed.findAll('div', {'id': 'zero_click_topics'})[0]
    results = topics.findAll('div', {'class': re.compile('results_*')})
    
    print results[0].text
    

    This script prints:

    u'Eixample, an inner suburb of Barcelona with distinctive architecture'
    

    The problem of direct querying on the main page is that it uses JavaScript to produce required results (not related topics), so you can use HTML version to get results only. HTML version has different link:

    • http://duckduckgo.com/?q=example # JavaScript version
    • http://duckduckgo.com/html/?q=example # HTML-only version

    Let’s see what we can get:

    site = urllib.urlopen('http://duckduckgo.com/html/?q=example')
    data = site.read()
    parsed = BeautifulSoup(data)
    
    first_link = parsed.findAll('div', {'class': re.compile('links_main*')})[0].a['href']
    

    The result stored in first_link variable is a link to the first result (not a related search) that search engine outputs:

    http://www.iana.org/domains/example

    To get all the links you can iterate over found tags (other data except links can be received similar way)

    for i in parsed.findAll('div', {'class': re.compile('links_main*')}):
        print i.a['href']
    
    http://www.iana.org/domains/example
    Posts by example
    https://www.facebook.com/leadingbyexample
    http://www.trythisforexample.com/
    http://www.myspace.com/leadingbyexample?_escaped_fragment_=
    
    https://en.wikipedia.org/wiki/Example_(musician)
    http://www.merriam-webster.com/dictionary/example
    ...
    

    Note that HTML-only version contains only results, and for related search you must use JavaScript version. (vithout html part in url).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I'm not going to do this, I now realize how dangerous this can
EDIT: There's now a doc page on this so this question is irrelevant, also
EDIT: This question is now redundant since Twitter no longer supports basic auth. I've
Edit This question has gone through a few iterations by now, so feel free
EDIT : At first I thought it wasn't working cross domain at all, now
Edit: Warning - I now realize that the following technique is generally regarded as
Realize this may sound like a broad question - so let me clarify. I
EDIT: Now a Major Motion Blog Post at http://messymatters.com/sealedbids The idea of rot13 is
edit: Now for some reason each productid is only showing up once instead of
THIRD EDIT: I now believe that this problem is due to a SOAP version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.