first attempt at using HTTP POST for translate

This commit is contained in:
Brian S. Stephan 2010-09-08 19:07:01 -05:00
parent 47022f9428
commit 6541e6a193
1 changed files with 2 additions and 3 deletions

View File

@ -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('"}, "')