deepl-scraper-pp2
scrape deepl using pyppeteer2 with para info, cross platform (Windows/MacOS/Linux)
Intro
deepl-scraper-pp2
is more or less deepl-scraper-pp. deepl-scraper-pp2
however preserves newlines in the translated text. Hence, it will make life easier when trying to process large chunks of text. deepl-scraper-pp2
is originally intended for deepl-tr-webui
but can be used elsewhere as well.
Installation
pip install deepl-scraper-pp2
# pip install deepl-scraper-pp2 # upgrade to the latest version
or
poetry add deepl-scraper-pp2
# poetry add deepl-scraper-pp2@latest # upgrade to the latest version
or clone the repo (git clone https://github.com/ffreemt/deepl-scraper-pyppeteer2.git
) and install from it.
Usage
python
in import asyncio
from deepl_scraper_pp2.deepl_tr import deepl_tr
print(asyncio.run(deepl_tr("test 1 \n\n test 2"))
# '测试1 \n\n 测试2'
Or start a local server
uvicorn deepl_scraper_pp2.deepl_server:app
# or
python -m deepl_scraper_pp2.run_uvicorn
and consume the REST API
import requests
res = requests.post(
"http://127.0.0.1:8000/text",
json={
"text": "test 1\n\ntest2",
"to_lang": "zh"},
headers={"accept": "application/json", "Content-Type": "application/json"}
)
print(res.json())
# {'q': {'text': 'test 1\n\ntest2', 'from_lang': None, 'to_lang': 'zh', 'description': None},
'result': '测试1\n\n测试2'}
Consult http://127.0.0.1:8000/docs for details.
Disclaimer
The pypi is beta and will likely remain beta -- use it at your own peril.