HTTPError: HTTP Error 503: Service Unavailable goslate language detection request : Python

风格不统一 提交于 2019-11-27 14:41:53
Matheus Araujo

In the documentation update from 05 of January of 2016, the author says that they will not update Goslate to overpass Google API access control :

Google has updated its translation service recently with a ticket mechanism to prevent simple crawler program like goslate from accessing. Though a more sophisticated crawler may still work technically, however it would have crossed the fine line between using the service and breaking the service. goslate will not be updated to break google’s ticket mechanism. Free lunch is over. Thanks for using.

The official, Google-approved way to use Google Translate in your programs is with the paid Google Cloud Translation API. With anything else, you're going to be fighting Google's rate limiting and bot detection.

maybe looking for this: https://pypi.python.org/pypi/textblob it is better than goslate,

since textblob is blocked as of now, maybe py-translate could do the trick,

https://pypi.python.org/pypi/py-translate/#downloads

http://pythonhosted.org/py-translate/devs/api.html

from translate import translator
translator('en', 'es', 'Hello World!')

"py-translate is a CLI Tool for Google Translate written in Python!"

the first argument to the translator function is the source language, the second is the target language, and the third is the phrase to be translated,

it returns a dictionary, which the documentation refers to as a request interface

gerosalesc

Elaborating on @programmer44 answer, here is an example of the use of TextBlob for this particular case:

from textblob.blob import TextBlob
blob = TextBlob('wait الدولة')
print(blob.detect_language())

Since TextBlob does not seem to work for me anymore neither. I have use langdetect which works just fine.

As shown on their documentation:

from langdetect import detect

print detect("War doesn't show who's right, just who's left.")
print detect("Ein, zwei, drei, vier")

will return

en
de
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!