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
|
except UnicodeDecodeError: pass
|
||||||
|
|
||||||
langpair = '%s|%s' % (fromlang, tolang)
|
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),) )
|
params = urlencode( (('v', 1.0), ('q', text), ('langpair', langpair),) )
|
||||||
url = gt_url + params
|
content = urlopen(gt_url, params).read()
|
||||||
content = urlopen(url).read()
|
|
||||||
start_idx = content.find('"translatedText":"')+18
|
start_idx = content.find('"translatedText":"')+18
|
||||||
translation = content[start_idx:]
|
translation = content[start_idx:]
|
||||||
end_idx = translation.find('"}, "')
|
end_idx = translation.find('"}, "')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user