Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with yandex translation. #24

Closed
giyeol opened this issue Sep 20, 2020 · 1 comment
Closed

Problem with yandex translation. #24

giyeol opened this issue Sep 20, 2020 · 1 comment

Comments

@giyeol
Copy link

giyeol commented Sep 20, 2020

I get a JSONDecodeError error when trying to translate yandex.

>>> print(ts.yandex('hello', 'en', 'zh'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/translators/apis.py", line 921, in yandex_api
    data = r.json()
  File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Also, in case of language detection, I get a 403 error.

>>> print(ts.yandex('hello'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/translators/apis.py", line 910, in yandex_api
    from_language = self.detect_language(ss, query_text, self.sid, proxies) if from_language=='auto' else from_language
  File "/usr/local/lib/python3.6/dist-packages/translators/apis.py", line 879, in detect_language
    r.raise_for_status()
  File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://translate.yandex.net/api/v1/tr.json/detect?sid=....&srv=tr-text&text=hello&hint=zh%2Cen&options=1
@UlionTse
Copy link
Owner

UlionTse commented Nov 3, 2020

@giyeol Please upgrade it to v4.7.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants