【发布时间】:2015-10-26 04:37:34
【问题描述】:
Google 答案框(有时称为精选片段、知识卡或实时结果)非常有用。我想提取信息并在我自己的程序中使用它。查看 HTML 代码,它并不像从那里拉出来那么简单。我已经做了很多研究,但我似乎找不到任何支持他们的东西。有谁知道是否有 API(或 Web Search API 的一部分)可以检索从答案框返回的信息?
我在这里看到了答案: google api for glorious info box? ,但提出的解决方案上个月已弃用。
仅举个例子,这是“日本现在几点”的 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"> 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>
这与“东京在哪里”有很大不同:
<!--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>
我基本上需要从第一个中提取“6:37 AM”,从第二个中提取“Japan”,但是执行动态字符串搜索会很困难,因为它们的格式非常不同。
【问题讨论】:
-
我和你一样好奇,但现在我正在探索 DuckDuckGo 的可能性,因为它们具有相似的功能:duckduckgo.com/api
标签: html google-api