5

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 e.g. 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).

Outcast
  • 4,967
  • 5
  • 44
  • 99
  • Possible duplicate of [GoogleTrans API Error - Expecting value: line 1 column 1 (char 0)](https://stackoverflow.com/questions/49497391/googletrans-api-error-expecting-value-line-1-column-1-char-0) – Alex Gidan Jun 19 '19 at 16:46

2 Answers2

3

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)
Mindaugas Vaitkus
  • 151
  • 1
  • 2
  • 11
  • Ok, thank you. I will try this too if it does not work without the proxies. Also, I do not really know how to set proxies etc so I will have to understand some things firstly. As far as I understand the `user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64)'` is for you specifically so I will have to modify it for my pc etc? – Outcast Jun 20 '19 at 09:14
  • Yes, you have to modify it. Look for syntax of multiple user agents. You can test to integrate fake_agent library, it worked for me with other libraries. – Mindaugas Vaitkus Jun 20 '19 at 15:37
  • Hm not sure that I want to spend time on these details. However what you said about the daily limit usage must be true because I managed to translate some stuff more before I get the same error as above again. – Outcast Jun 20 '19 at 15:45
0

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.

Joey
  • 11
  • 1