first attempt at using HTTP POST for translate
This commit is contained in:
parent
47022f9428
commit
6541e6a193
|
@ -38,10 +38,9 @@ class GoogleTranslate(Module):
|
|||
except UnicodeDecodeError: pass
|
||||
|
||||
langpair = '%s|%s' % (fromlang, tolang)
|
||||
gt_url = 'http://ajax.googleapis.com/ajax/services/language/translate?'
|
||||
gt_url = 'http://ajax.googleapis.com/ajax/services/language/translate'
|
||||
params = urlencode( (('v', 1.0), ('q', text), ('langpair', langpair),) )
|
||||
url = gt_url + params
|
||||
content = urlopen(url).read()
|
||||
content = urlopen(gt_url, params).read()
|
||||
start_idx = content.find('"translatedText":"')+18
|
||||
translation = content[start_idx:]
|
||||
end_idx = translation.find('"}, "')
|
||||
|
|
Loading…
Reference in New Issue