开发者

Using the RESTful interface to Google's AJAX Search API for "Did you mean"?

Is it possible to get spelling/search suggestions (i.e. "Did you mean") via the RESTful interface to Google's AJAX search API? I'm trying to access this from Python, though the URL query syntax is all I rea开发者_开发问答lly need.

Thanks!


the Google AJAX API don't have a spelling check feature see this, you can use the SOAP service but i think it's no longer available .

at last you can look at yahoo API they have a feature for spelling check.

EDIT : check this maybe it can help you:

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


if you're just looking for spelling suggestions you might want to check out something like Wordnik: http://docs.wordnik.com/api/methods

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜