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

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

问题描述

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

我问了一个类似的问题(Python 搜索抓取)并且它的答案适用于google 我的问题是我在任何地方都找不到 Duckduckgo 的搜索 api 地址.你能帮我或建议另一种方法吗?

解决方案

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

正如其他回答者所提到的,DuckDuckGo 的有限搜索 API 的 URL 是

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

x 是您要查找的搜索词.

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

<块引用>

但是,此 API 不包括我们的所有链接.也就是说,它不是一个完整的搜索结果 API,也不是一种将 DuckDuckGo 结果导入您的应用程序的方法,超出我们的即时答案.由于我们生成搜索结果的方式,很遗憾,我们无权完全联合我们的结果.出于同样的原因,我们不能允许在没有品牌的情况下构建我们的结果.请参阅我们的合作伙伴页面,了解有关指南的更多信息并与我们联系.

<块引用>

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

所以为了你所说的目的

<块引用>

只需提交字符串查询(相当于手动输入搜索栏)并保存第一个结果的 URL(如果有).

api.duckduckgo.com 不会给你你想要的东西.

您最好的选择可能是对 DuckDuckGo 的非 JS 网络版本进行屏幕抓取:

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

寻找带有诸如 div.resultdiv.web-result 之类的选择器的元素.

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?

解决方案

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.

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

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