So for your stated purpose of
just submitting string queries (the equivalent of typing into the search bar by hand) and saving the URL of the first results (if there are any).
api.duckduckgo.com will not get you what you want.
Your best bet is probably to just screen scrape the non-JS, web version of DuckDuckGo:
https://duckduckgo.com/html/?q=x
looking for elements with a selector of something like div.result or div.web-result.
listed by latest revision:
ddg3 0.6.6
latest: 2017
https://pypi.org/project/ddg3/
code is < 200 lines
IT RAN, but lame
duckduckgo/aa2.py used it some; it ran a little more
DuckDuckGo-Python3-Library 1.0
last commit: 2016
https://pypi.org/project/DuckDuckGo-Python3-Library/
This Python3 version uses the instant answer API of DuckDuckGo.
ModuleNotFoundError: No module named 'urllib2'
duckduckgo.py last: 2016 https://github.com/thibauts/duckduckgo code is 30 lines should be used with great caution
duckduckpy 0.2 latest: 2016 https://pypi.org/project/duckduckpy/ several files; maybe 300 lines of code IT RAN
duckduckgo2 latest commit 2015 https://github.com/crazedpsyc/python-duckduckgo code is 180 lines
python-duckduckgo (another) last: 2015 https://github.com/crazedpsyc/python-duckduckgo/ fork of mikejs
python-duckduckgo last: 2010 https://github.com/mikejs/python-duckduckgo was forked
duckduckgo 0.1 only: 2010 https://pypi.org/project/duckduckgo/
>>> vars(r)
{'type': 'answer', 'api_version': '1.0', 'heading': 'DuckDuckGo', 'results': [], 'related': [<ddg3.Result object at 0x7f082fe0f940>, <ddg3.Result object at 0x7f082fe0f470>, <ddg3.Result object at 0x7f082fe0f550>, <ddg3.Result object at 0x7f082fe0f5f8>, <ddg3.Result object at 0x7f082fe0f6a0>, <ddg3.Result object at 0x7f082fe0f748>, <ddg3.Result object at 0x7f082fe0f7f0>], 'abstract': <ddg3.Abstract object at 0x7f082fe0f898>, 'answer': None, 'image': None}
>>> pprint(vars(r))
{'abstract': <ddg3.Abstract object at 0x7f082fe0f898>,
'answer': None,
'api_version': '1.0',
'heading': 'DuckDuckGo',
'image': None,
'related': [<ddg3.Result object at 0x7f082fe0f940>,
<ddg3.Result object at 0x7f082fe0f470>,
<ddg3.Result object at 0x7f082fe0f550>,
<ddg3.Result object at 0x7f082fe0f5f8>,
<ddg3.Result object at 0x7f082fe0f6a0>,
<ddg3.Result object at 0x7f082fe0f748>,
<ddg3.Result object at 0x7f082fe0f7f0>],
'results': [],
'type': 'answer'}
and also:
>>> for d in r.related:
... pprint(vars(d))
...
{'html': '<a href="https://duckduckgo.com/Startpage.com">Startpage.com</a> - '
'Startpage is a web search engine which highlights privacy as its '
'distinguishing feature. It was previously known as the metasearch '
'engine Ixquick, Startpage being then a variant service. Both sites '
'were merged in 2016.',
'icon': None,
'text': 'Startpage.com - Startpage is a web search engine which highlights '
'privacy as its distinguishing feature. It was previously known as '
'the metasearch engine Ixquick, Startpage being then a variant '
'service. Both sites were merged in 2016.',
'url': 'https://duckduckgo.com/Startpage.com'}
{'html': '<a href="https://duckduckgo.com/Names_Database">Names Database</a> - '
'The Names Database is a defunct social network, owned and operated '
'by Classmates.com, a wholly owned subsidiary of United Online. The '
'site does not appear to be significantly updated since 2008, and has '
'many broken links and display issues.',
'icon': None,
'text': 'Names Database - The Names Database is a defunct social network, '
'owned and operated by Classmates.com, a wholly owned subsidiary of '
'United Online. The site does not appear to be significantly updated '
'since 2008, and has many broken links and display issues.',
'url': 'https://duckduckgo.com/Names_Database'}
{'html': '<a '
'href="https://duckduckgo.com/c/Companies_based_in_Chester_County%2C_Pennsylvania">Companies '
'based in Chester County, Pennsylvania</a>',
'icon': None,
'text': 'Companies based in Chester County, Pennsylvania',
'url': 'https://duckduckgo.com/c/Companies_based_in_Chester_County%2C_Pennsylvania'}
{'html': '<a href="https://duckduckgo.com/c/Perl_software">Perl software</a>',
'icon': None,
'text': 'Perl software',
'url': 'https://duckduckgo.com/c/Perl_software'}
{'html': '<a '
'href="https://duckduckgo.com/c/Internet_privacy_software">Internet '
'privacy software</a>',
'icon': None,
'text': 'Internet privacy software',
'url': 'https://duckduckgo.com/c/Internet_privacy_software'}
{'html': '<a '
'href="https://duckduckgo.com/c/Proprietary_cross-platform_software">Proprietary '
'cross-platform software</a>',
'icon': None,
'text': 'Proprietary cross-platform software',
'url': 'https://duckduckgo.com/c/Proprietary_cross-platform_software'}
{'html': '<a href="https://duckduckgo.com/c/Internet_search_engines">Internet '
'search engines</a>',
'icon': None,
'text': 'Internet search engines',
'url': 'https://duckduckgo.com/c/Internet_search_engines'}