Googletrans API错误-每日限制或IP被阻止? [英] Googletrans API error - daily limit or blocked IP?
问题描述
我正在使用googletrans
软件包.
今天,我整天使用它翻译了很多文本.
I have translated quite a lot of text by using it throughout the day today.
正如文档所暗示的,我已经将文本分割为少于15,000个字符的标记,并且在每种情况下我都重新安装Translator()
.
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.
(实际上只是在说,如果我没有丢失任何东西,我必须将文本分割成少于15k个字符的令牌,例如2k,因为我认为即使是10k字符之类的软件包也会向我返回错误令牌-我不知道为什么会这样.
(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)
为什么会这样?
是因为每天(不成文-我在文档中没有看到)该软件包的每日使用限制或我的IP被永久阻止吗?
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?
我在这里看到了相关的讨论: GoogleTrans API错误-预期值:第1行第1列(字符0).
I saw a relevant discussion here: GoogleTrans API Error - Expecting value: line 1 column 1 (char 0).
推荐答案
这是因为每日使用限制.第二天尝试使用相同的代码.另一种方法是,查看设置代理的最新文档最新的Googletrans文档
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)
这篇关于Googletrans API错误-每日限制或IP被阻止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!