markolofsen / py_translator

The end goal is a simple application for translating text in the terminal. Text can be generated interactively or programmatically in the shell environment.

Home Page:https://pypi.org/project/py-translator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

raise JSONDecodeError

one2gov opened this issue · comments

Hi, my code is just simply as follows:

import py_translator
from py_translator import Translator
translator = Translator()
translator.translate('bonjour')

I would like to test the package and the text is so short within the limit. But it raise error:
raise JSONDecodeError("Expecting value", s, err.value) from None

and the error message is
JSONDecodeError: Expecting value

commented
from py_translator import Translator
Translator().translate('bonjour').text

Error reappears after certain amount of iterations (maybe 100)

raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

commented

@one2gov That's normal, use a mostly delay between requests.

commented

Or... Use a proxy

from py_translator import Translator
proxy = {
        'http': 'http://username:password@1.1.1.1:1234',
        'https': 'http://username:password@1.1.1.1:1234',
}
s = Translator(proxies=proxy).translate(text='Hello my friend', dest='es').text
print(s)

I am also getting the same error and I have tried translation as single without iteration but still receiving same error. I have also tried by putting delay in code but nothing works. I am using python 3.6.

@markolofsen Can you fix this?
aparently it has already been done:
ssut/py-googletrans#51
But this branch has the group error that you solved.