使用RESTful接口调用Google AJAX搜索API的“你是说”?
有没有办法通过Google的AJAX搜索API的RESTful接口获取拼写或搜索建议(比如“你是想说”)呢?我想用Python来访问这个,不过其实我只需要知道URL查询的写法就可以了。
谢谢!
2 个回答
1
如果你只是想找一些拼写建议,可以看看Wordnik这个网站: http://docs.wordnik.com/api/methods
2
谷歌的AJAX API没有拼写检查的功能,具体可以查看这个链接。你可以使用SOAP服务,但我觉得这个服务现在可能已经不再提供了。
最后,你可以看看雅虎的API,他们有一个拼写检查的功能。
编辑:看看这个,也许能帮到你:
import httplib
import xml.dom.minidom
data = """
<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1">
<text> %s </text>
</spellrequest>
"""
word_to_spell = "gooooooogle"
con = httplib.HTTPSConnection("www.google.com")
con.request("POST", "/tbproxy/spell?lang=en", data % word_to_spell)
response = con.getresponse()
dom = xml.dom.minidom.parseString(response.read())
dom_data = dom.getElementsByTagName('spellresult')[0]
for child_node in dom_data.childNodes:
result = child_node.firstChild.data.split()
print result