有没有一种方法可以免费使用 python 将字符串从一种语言翻译成另一种语言,而且没有每日限制?

Is there a way to translate strings from one language to another using python for free without a daily limit?

我正在制作一个网络抓取工具,我需要将单词从英语翻译成荷兰语。 我目前正在使用这个模块:https://pypi.org/project/translate/。一段时间后,我 运行 没有免费的每日翻译。有没有办法免费执行此操作,可能是在本地或使用其他方法?

不确定 Google Translate 是否限制了您每天可以进行的翻译数量 - 我知道通过他们的官方 API,您需要一个 API 密钥,而且它可能是有限的- 但是当您通过 Google 搜索翻译内容时,您的浏览器与 API 对话呢?

def main():

    import requests

    url = "https://translate.google.com/translate_a/single"

    english_sentence = "I am hungry"
    from_language = "en"
    to_language = "de"

    params = {
        "client": "webapp",
        "sl": "auto",
        "tl": to_language,
        "hl": from_language,
        "dt": "t",
        "tk": "374347.226425",
        "q": english_sentence
    }

    response = requests.get(url, params=params)
    response.raise_for_status()

    data = response.json()

    german_sentence = data[0][0][0]

    print(german_sentence)

    return 0


if __name__ == "__main__":
    import sys
    sys.exit(main())

输出:

Ich bin hungrig
>>>