python - DuckDuckGo search returns 'List Index out of range' -


here duck duck go search script.

import duckduckgo r = duckduckgo.query('duckduckgo') print r.results[0].url 

it returns; list index out of range. if print r.results get;

[<duckduckgo.result object @ 0x0000000002e98f60>] 

but if search other 'duckduckgo'. returns empty value

[] 

i havefollowed did in example code. https://github.com/mikejs/python-duckduckgo

that documented behaviour. there different result attributes.

your first query returns list of results.

r = duckduckgo.query('duckduckgo') if r.type == 'answer':     print r.results    # [<duckduckgo.result object>] 

your other search returns disambiguation , results in r.related not in r.results

r = duckduckgo.query('python') if r.type == 'disambiguation':     print r.related    # [<duckduckgo.result object>] 

edit: python-duckduckgo uses duckduckgo api not give search result links

our instant answer api gives free access many of our instant answers like: topic summaries (api example), categories (api example), disambiguation (api example), !bang redirects (api example), , definitions (api example).

this api not include of our links, however. is, not full search results api or way duckduckgo results applications beyond our instant answers. because of way generate our search results, unfortunately not have rights syndicate our results. same reason, cannot allow framing our results without our branding. please see our partnerships page more info on guidelines , getting in touch us.

you can't want using duckduckgo api possible workaround has been posted on stackoverflow: https://stackoverflow.com/a/11923803/241866


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -