Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

python - Running into error for google translation of data

I am attempting to translate a list of tweets with the following sample code:

from google_trans_new import google_translator  
translator = google_translator()  
translate_text = translator.translate('?????????', lang_src='th',lang_tgt='en')  
print(translate_text)

I keep running into the following long error when I run the code:

HTTPError                                 Traceback (most recent call last)
~anaconda3libsite-packagesgoogle_trans_newgoogle_trans_new.py in translate(self, text, lang_tgt, lang_src, pronounce)
    188                         raise e
--> 189             r.raise_for_status()
    190         except requests.exceptions.ConnectTimeout as e:

~anaconda3libsite-packages
equestsmodels.py in raise_for_status(self)
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942 

HTTPError: 429 Client Error: Too Many Requests for url: https://www.google.com/sorry/index?continue=https://translate.google.cn/_/TranslateWebserverUi/data/batchexecute&q=EgRrvwCgGLHwuIAGIhkA8aeDS9RXYOujcLlE7r1EY3pCFB3PU57xMgFy

During handling of the above exception, another exception occurred:

google_new_transError                     Traceback (most recent call last)
<ipython-input-1-e0a80cf9e6cc> in <module>
      1 from google_trans_new import google_translator
      2 translator = google_translator()
----> 3 translate_text = translator.translate('?????????', lang_src='th',lang_tgt='en')
      4 print(translate_text)
      5 #output: Hello china

~anaconda3libsite-packagesgoogle_trans_newgoogle_trans_new.py in translate(self, text, lang_tgt, lang_src, pronounce)
    192         except requests.exceptions.HTTPError as e:
    193             # Request successful, bad response
--> 194             raise google_new_transError(tts=self, response=r)
    195         except requests.exceptions.RequestException as e:
    196             # Request failed

google_new_transError: 429 (Too Many Requests) from TTS API. Probable cause: Unknown

Is this because I have used the translator too frequently? When will it reset so I can continue my work?

question from:https://stackoverflow.com/questions/65878555/running-into-error-for-google-translation-of-data

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...