What I want to do is 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).
I have asked a similar question ( Python search scraping) and the answer to it works well with google my problem is that I can't find Duckduckgo's search api address anywhere. Could you help me or suggest antoher way of doing this?
DuckDuckGo uses its web crawler, DuckDuckBot, and up to 400 other sources to compile its search results, including other search engines like Bing, Yahoo, and Yandex, and crowdsourcing sites like Wikipedia.
DuckDuckGo is fairly safe and offers much more privacy than mainstream browsers. First of all, DuckDuckGo's main appeal is your search privacy. This means that DuckDuckGo doesn't collect user data and track your search history. Unlike Google, it doesn't associate what you look for online with your IP address.
The DuckDuckGo Instant Answer API provides free programmatic access to many of the search engine’s instant answers, pulled from over 100 independent sources. Answers include things like topic summaries, categories, disambiguation, redirects, and definitions.
To gain the best local results from DuckDuckGo users, you should use hyperlocal terms in your site, describing where you are, what's nearby, major intersections, roads, neighborhoods, and other regions that a user might input when they are searching for a local result.
tl;dr -- Screen scrape https://duckduckgo.com/html/?q={search_terms}
As other answerers have mentioned, the URL for DuckDuckGo's limited search API is
http://api.duckduckgo.com/?q=x&format=json
x
being the search terms you're looking for.
However, please note that this is not a full search API. As DuckDuckGo's API page mentions,
This API does not include all of our links, however. That is, it is not a full search results API or a way to get DuckDuckGo results into your applications beyond our instant answers. Because of the way we generate our search results, we unfortunately do not have the rights to fully syndicate our results. For the same reason, we cannot allow framing our results without our branding. Please see our partnerships page for more info on guidelines and getting in touch with us.
This is an Instant Answer API, and not a full results API. However, there are some Web links within it, e.g. official sites.
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
.
just change with whatever you want to search for. This will output the results in JSON
https://api.duckduckgo.com/?q=<your search string>&format=json&pretty=1&no_html=1&skip_disambig=1
I think this is what you are asking for
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With