简体   繁体   English

Googletrans API 错误 - 每日限制或被阻止的 IP?

[英]Googletrans API error - daily limit or blocked IP?

I am using the googletrans package.我正在使用googletrans包。

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.正如文档所暗示的那样,我已将文本拆分为少于 15k 个字符的标记,并且我在每种情况下都重新实例化了Translator()

(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). (实际上只是提一下,如果我没有遗漏一些东西,我必须将我的文本拆分为小于 15k-char 的标记,例如 2k,因为我认为即使使用 10k-char 标记之类的东西,该包也会向我返回错误 - 我不知道为什么会这样)。

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?是因为有(一个不成文的 - 我在文档上没有看到)包的每日使用限制还是我的 IP 被永久阻止?

I saw a relevant discussion here: GoogleTrans API Error - Expecting value: line 1 column 1 (char 0) .我在这里看到了一个相关的讨论: 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另请参阅设置代理的最新文档 最新的 Googletrans 文档

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.您可以获得大约 1000 个请求/小时而不会达到 req/IP 块限制。 Also, individual requests are limited to less than 5000 characters per request.此外,单个请求限制为每个请求少于 5000 个字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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