ocrtextblob

Textblob OCR throws 404 error when trying to translate to another language


I have a 5 line simple program to translate a language to English via OCR Textblob. But for some reason, it throws 404 error!!!

from textblob import TextBlob

text = u"おはようございます。"
tb = TextBlob(text)
translated = tb.translate(to="en")
print(translated)

enter image description here

The Textblob is installed and the version is 0.15.3

$ pip install -U textblob
$ python -m textblob.download_corpora

Thank you


Solution

  • Something has changed in the Google API used by Textblob. You can see the 'official' discussion and suggested solution here https://github.com/sloria/TextBlob/issues/395

    In summary, until the issue get fixed by Textblob author, in translate.py you should change

    url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
    

    to

    url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"