Google解答框中是否有API? [英] Is there an API for the Google Answer Boxes?

查看:116
本文介绍了Google解答框中是否有API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google答案框(有时称为精选片段,知识卡或实时结果)非常有帮助。我想提取信息并在我自己的程序中使用它。看看HTML代码,它并不像从那里拉它那么简单。我已经做了相当多的研究,但我似乎无法为他们找到任何支持。有谁知道是否有API(或Web Search API的一部分),您可以在其中检索从答案框中返回的信息?



我在这里看到了答案:



举个例子,这是What is the time in japan的HTML代码:

 <! - m  - >< div data-hveid =30> 
< div class =vk_c vk_gy vk_sh card-section _MZc>
< div class =vk_bk vk_ans> 6:37 AM< / div>
< div class =vk_gy vk_sh>周二,< span class =_ Hq> 2015年8月4日< / span>
< span class =_ Hq> (GMT + 9)< / span>
< / div> < span class =vk_gy vk_sh>在日本的时间< / span>

这与东京位于何处非常不同:

 <! -  m  - > 
< div class =_ uX kno-fb-ctxaria-level =3role =headingdata-hveid =41data-ved =0CCkQtwcoATACahUKEwiLjemg8I3HAhUTKYgKHU7jCho>
< div class =_ eFdata-tts =answersdata-tts-text =Japan>日本< / div>
< div class =_ Tfc>
< / div>< / div>
<! - n - >
< / li>< li class =moddata-md =61style =clear:none>
<! - m - >
< div class =_ oDddata-hveid =42>
< span class =_ Tgc _y9e>东京由关东地区的西南部,< b>伊豆岛< / b>和< b>小笠原群岛< / b> 。东京是< b>日本< / b>的首都,也是超过1300万人居住的地方,使它成为世界上人口最多的城市之一。< / span>< / div>

我基本上需要从第一个和第二个日本中提取6:37 AM ,但执行动态字符串搜索将是困难的,因为它们的格式非常不同。

解决方案

有一个即时答案api可用来自DuckDuckGo,我过去曾经使用过,效果很好。这些反应并不像谷歌那么强大,但这是一个好的开始。



https://duckduckgo.com/api



api在JSON响应中看起来如此。

  {
摘要:
AbstractText:
AbstractSource:
AbstractURL:
图片:
标题:
答案:
重定向:
AnswerType:
定义:
DefinitionSource:
DefinitionURL:
RelatedTopics :[]
结果:[]
类型:
}

我希望这有助于!


The Google Answer Boxes (sometimes called Featured Snippets, Knowledge Cards, or Live Results) are extremely helpful. I'd like to extract the information and use it in my own program. Looking at the HTML code, it's not quite so straight forward as pulling it from there. I've done quite a bit of research, but I can't seem to find any support for them. Does anyone know if there is an API (or part of the Web Search API) where you can retrieve the information returned from the Answer Box?

I saw the answer here: google api for glorious info box? , but the solution presented was deprecated last month.

Just for an example, this is the HTML code for "What is the time in japan":

<!--m--><div data-hveid="30">      
<div class="vk_c vk_gy vk_sh card-section _MZc">  
<div class="vk_bk vk_ans">6:37 AM</div> 
<div class="vk_gy vk_sh"> Tuesday, <span class="_Hq">August 4, 2015</span>  
<span class="_Hq"> (GMT+9) </span>  
</div> <span class="vk_gy vk_sh">  Time in Japan  </span> 

Which is VERY different from "where is tokyo located":

<!--m-->
<div class="_uX kno-fb-ctx" aria-level="3" role="heading" data-hveid="41" data-ved="0CCkQtwcoATACahUKEwiLjemg8I3HAhUTKYgKHU7jCho">
<div class="_eF" data-tts="answers" data-tts-text="Japan">Japan</div>
<div class="_Tfc">
</div></div>
<!--n-->
</li><li class="mod" data-md="61" style="clear:none">
<!--m-->
<div class="_oDd" data-hveid="42">
<span class="_Tgc _y9e">Tokyo consists of the southwestern part of the Kanto region, the <b>Izu Islands</b>, and the <b>Ogasawara Islands</b>. Tokyo is the capital of <b>Japan</b>, and the place where over 13 million people live, making it one of the most populous cities in the world.</span></div>

I essentially need to extract "6:37 AM" from the first and "Japan" from the second, but performing a dynamic string search would be difficult as they are in very different formats.

解决方案

There is an instant answer api available from DuckDuckGo that I've used in the past that works pretty well. The responses aren't as robust as google's but it's a good start.

https://duckduckgo.com/api

The api looks like so in a JSON response.

{
Abstract: ""
AbstractText: ""
AbstractSource: ""
AbstractURL: ""
Image: ""
Heading: ""
Answer: ""
Redirect: ""
AnswerType: ""
Definition: ""
DefinitionSource: ""
DefinitionURL: ""
RelatedTopics: [ ]
Results: [ ]
Type: ""
}

I hope this helps!

这篇关于Google解答框中是否有API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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