deepl translate for free with async and proxy support, based on pyppeteer
get_ppbrowser
is now an indepent package that deepl-tr-async
depents on.E.g.
sudo apt install libicu-dev
yum install libicu
brew install icu4c
Download and install the pyicu and pycld2 whl packages for your OS version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyicu and https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycld2
pip install deepl-tr-async
Validate installation
python -c "import deepl_tr_async; print(deepl_tr_async.__version__)"
# 0.0.2 or other version info
deepl-tr
deepl-tr --copyfrom=false this is a test
Help 帮助:
deepl-tr -?
or
deepl-tr --helpfull
import asyncio
from deepl_tr_async import deepl_tr_async
from deepl_tr_async.google_tr_async import google_tr_async
loop = asyncio.get_event_loop()
sent = 'Global coronavirus pandemic kills more than 30,000'
res = loop.run_until_complete(deepl_tr_async(sent, to_lang='zh'))
print(res)
# Alternatives:
# 全球冠状病毒大流行导致超过3万人死亡
# 全球冠状病毒大流行导致3万多人死亡
# 全球冠状病毒大流行导致超过30,000人死亡
# 全球冠状病毒大流行导致3万多人丧生
res = loop.run_until_complete(google_tr_async(sent, to_lang='zh'))
print(res)
# 全球冠状病毒大流行杀死超过30,000人
tasks = [deepl_tr_async(sent, to_lang='zh'), google_tr_async(sent, to_lang='zh')]
_ = asyncio.gather(*tasks)
res = loop.run_until_complete(_)
print(res)
['Alternatives:\n全球冠状病毒大流行导致超过3万人死亡\n全球冠状病毒大流行导致3万多人死亡\n全球冠状病毒大流行导致超过30,000人死亡\n全球冠状病毒大流行导致3万多人丧生', '全球冠状病毒大流行杀死超过30,000人']
This version of deep-tr-async
makes use of the package get-ppbrowser
. get-ppbrowser
is a headless browser based on pyppeteer2
.
To turn off headless mode, i.e., to show the browser in action, set PPBROWSER_HEADFUL to 1 (or true or True) in the .env
file, e.g.,
PPBROWSER_HEADFUL=1
or from the cmomand line, e.g.,
set PPBROWSER_HEADFUL=1
# export PPBROWSER_HEADFUL=1 in linux or iOS
or in a python script
import os
os.environ["PPBROWSER_HEADFUL"]="1" # note the quotes
PPBROWSER_DEBUG and PPBROWSER_PROXY can be set in a similar manner.