Skip to main content

baidu translate for free

Project description

baidu-tr-free

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

Installation

pip install -U baidu-tr-free or

  • 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.5.tar.gz (8.4 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: baidu-tr-free-0.0.5.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 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.5.tar.gz
Algorithm Hash digest
SHA256 373c41955a1d519e2d9d65bf6d72cae874ddfefb479b871c89e7b45394ffd8c0
MD5 7b4587e817027f942a1fff216bead832
BLAKE2b-256 c1dfd677dfb849eb895d015e3cacd8d237ed3e7462adc2638f150b16958496a6

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