Duckduckgo API获取搜索结果 [英] Duckduckgo API getting search results

查看:69
本文介绍了Duckduckgo API获取搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的只是提交字符串查询(相当于手动在搜索栏中键入内容)并保存第一个结果的URL(如果有).

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).

我问了类似的问题( Python搜索抓取),它的答案与google我的问题是我在任何地方都找不到Duckduckgo的搜索API地址.您能帮我还是建议其他方式?

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?

推荐答案

tl; dr-屏幕抓取 https://duckduckgo. com/html/?q = {search_terms}

tl;dr -- Screen scrape https://duckduckgo.com/html/?q={search_terms}

正如其他答复者所提到的那样,DuckDuckGo的API的网址是

As other answerers have mentioned, the URL for DuckDuckGo's API is

http://api.duckduckgo.com/?q=x&format=json

x是您要搜索的搜索词.

x being the search terms you're looking for.

但是,请注意,这不是完整的搜索API .正如 DuckDuckGo的API页面所述,

However, please note that this is not a full search API. As DuckDuckGo's API page mentions,

但是,此API并不包括我们所有的链接.也就是说,这不是完整的搜索结果API,也不是将DuckDuckGo结果带入您的应用程序之外的即时答案的方法.由于我们生成搜索结果的方式,因此,我们无权完全联合我们的搜索结果.出于相同的原因,我们不能在没有品牌的情况下构筑我们的结果.请参阅我们的合作伙伴关系页面,以获取有关准则和与我们联系的更多信息.

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.

这是Instant Answer API,而不是完整的结果API.但是,其中有一些Web链接,例如官方网站.

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

只需提交字符串查询(相当于手动在搜索栏中键入内容),然后保存第一个结果的URL(如果有).

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无法获得您想要的东西.

api.duckduckgo.com will not get you what you want.

您最好的选择可能是屏幕抓取非JS Web版本的DuckDuckGo:

Your best bet is probably to just screen scrape the non-JS, web version of DuckDuckGo:

https://duckduckgo.com/html/?q=x

使用诸如div.resultdiv.web-result之类的选择器来查找元素.

looking for elements with a selector of something like div.result or div.web-result.

这篇关于Duckduckgo API获取搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆