Skip to main content

微软bing翻译器python sdk

PyPI version Download count

介绍

微软bing翻译器,支持cn.bing.com和www.bing.com,建议轻量使用,欢迎star、follow、fork。

适用对象

无法或者不便使用微软Azaue Text Translation服务的用户轻量级用户可以使用bing提供的翻译能力。

源码

github

gitee

安装

pip install cn_bing_translator

使用方法

from cn_bing_translator import Translator

if __name__ == "__main__":
    translator = Translator()
    source = "翻译器"
    result = translator.process(source)
    print(result)

默认情况下将自动检测源语言语种,并翻译为英语,如果需要指定其他语种,可以在初始化的时候传入对应的语言代码:

# 传入以下参数初始化一个从英语到日语的翻译器
translator = Translator(fromLang='en', toLang='ja')

具体支持的语言类型和代码请参考微软网站。

翻译器初始化的时候,也可以定制user agent:

agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1 Edg/99.0.4844.51'
translator = Translator(agent=agent)

如果有使用代理的需求,可以指定proxy:

proxy = {'https':'http://localhost:8080'}
translator = Translator(proxy=proxy)

默认调用cn.bing.com,如需使用www.bing.com,可以在初始化的时候指定:

translator = Translator(cnBing=False)

需要注意的是,根据bing.com的跳转规则,如果服务器判断是中国区用户访问,即使指定cnBing为False,仍然会自动跳转到cn.bing.com。

注意事项

建议轻量级使用,控制调用量和频率,微软bing翻译器默认带有防滥用措施,频繁发起大量请求可能会触发拦截。

Metadata

Release files for cn-bing-translator 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cn-bing-translator 0.0.3
File Size Uploaded Provenance Actions
cn_bing_translator-0.0.3.tar.gz 5.1 kB Without provenance Details for cn_bing_translator-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cn-bing-translator 0.0.3
File Interpreter ABI Platform Actions
cn_bing_translator-0.0.3-py3-none-any.whl Python 3 none any Details for cn_bing_translator-0.0.3-py3-none-any.whl

Total release size: 11.1 kB

Release files / cn_bing_translator-0.0.3.tar.gz

Download URL cn_bing_translator-0.0.3.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
406b70ff2217c2731816e6c9434168e5dbbdf40a5b0d98dd0d69dc88fe907bd7
BLAKE2b-256 checksum
How to use checksums
35bd4366321414955e3a6bf593c96909018924ec4a30661766b85f9eff5ad941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / cn_bing_translator-0.0.3-py3-none-any.whl

Download URL cn_bing_translator-0.0.3-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4063a456762dbbf0696fb5c7b540b9947dba76dd60f24662b37a9f11289481c
BLAKE2b-256 checksum
How to use checksums
973e7993b2ad858aa3e4543dc2e302274413a903ce4b3cd77faf2e40005deb2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Security for cn-bing-translator 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page