我想向Google Input API
发送一些(约200K)的请求并显示结果。例如,我想发送deep
,并且必须返回:
["deep","dépenses","dépend","dépendance","dépendant"]
我尝试关注脚本,但没有帮助:
def request(word):
url = 'https://inputtools.google.com/request?text=' + word + '&itc=fr-t-i0-und&num=5&cp=0&cs=1&ie=utf-8&oe=utf-8&app=test'
conn = http.client.HTTPConnection(url)
res = conn.getresponse()
print(res.status, res.reason)
我想知道如何实现这一目标?(请参阅我想在这里实现的示例)
我不确定您从哪里获得了呼叫语法,但是如果您阅读了文档,则会发现您需要将代码编写为
import http.client
def request(word):
conn = http.client.HTTPSConnection('inputtools.google.com')
conn.request('GET', '/request?text=' + word + '&itc=fr-t-i0-und&num=5&cp=0&cs=1&ie=utf-8&oe=utf-8&app=test')
res = conn.getresponse()
print(res.status, res.reason)
print(res.read())
request(word='deep')