Skip to main content

baidutranslate forfree

Project description

baidu-tr-free

Baidu translate for free -- local cache plus throttling. Let's hope it lasts.

Installation

  • Install (pip or whatever) necessary requirements, e.g. pip install js2py requests_cache jsonpath_rw or pip install -r requirements.txt
  • Drop the file bdtr.py in any folder in your PYTHONPATH (check with import sys; print(sys.path)
    • Several valid TOKEN/BAIDUID are included.
  • or clone the repo (e.g., git clone https://github.com/ffreemt/baidu-tr-free.git or download https://github.com/ffreemt/baidu-tr-free/archive/master.zip and unzip) and change to the baidu-tr-free folder and do a python setup.py develop

Usage

from bdtr import bdtr
print(bdtr('hello world'))  # -> '你好,世界'
print(bdtr('hello world', to_lang='de'))  # ->'Hallo Welt'
print(bdtr('hello world', to_lang='jp'))  # ->'ハローワールド'

Validation and Pressure Tests

  • pip install pytest
  • pytest
    • Average delay for throttling set to 0.6 s, ajdust as needed

Acknowledgments

  • Thanks to everyone whose code was used
  • JS_SIGN (javascript code for signing) can be found on the net. It's also not too difficult to obtain some similar code from Chrome's devtools.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baidu-tr-free-0.0.1.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file baidu-tr-free-0.0.1.tar.gz.

File metadata

  • Download URL: baidu-tr-free-0.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.6.7

File hashes

Hashes for baidu-tr-free-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d12b8201e61fc21cac2bf4d95a44357d9122a8af202061ce045b4c6383ffa06e
MD5 21626c753bbaa6efdce03396598be834
BLAKE2b-256 8abf57ae8806e4225eb73fc5d3e5a16b2ca94de2b0883f3cdb33bfaf6665a445

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page