简体   繁体   中英

Googletrans API error - daily limit or blocked IP?

I am using the googletrans package.

I have translated quite a lot of text by using it throughout the day today.

I had splitted my text into tokens of less than 15k characters as the documentations implies and I was re-instanting the Translator() at each case.

(Actually just to mention that, if I was not missing something, I had to split my text in smaller than 15k-char tokens eg 2k because I think that the package was returning me an error even with something like 10k-char tokens - I do not know why this was happening).

Now I do the following:

from googletrans import Translator

translator = Translator()      
response = translator.translate('Is this working?', dest='fr')

print(response.text)

and I directly get the following error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Why is this happening?

Is it because there is (an unwritten - I have not seen on the docs) daily limit of usage of the package or my IP is permanently blocked?

I saw a relevant discussion here: GoogleTrans API Error - Expecting value: line 1 column 1 (char 0) .

This because of daily limit usage. Try to use with same code next day. Alternative see latest documentation for setting proxies latest Googletrans documentation

Translator(service_urls=None, user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64)', proxies=None, timeout=None)

You can get about 1000 requests / hour without hitting the req/IP block limit. Also, individual requests are limited to less than 5000 characters per request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM