Skip to main content

scrape deepl via pyppeteer2 with para info

Project description

deepl-scraper-pp2

[tests]pythonCode style: blackLicense: MITPyPI version

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

in python

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.

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

deepl-scraper-pp2-0.1.0a2.tar.gz (10.8 kB view hashes)

Uploaded Source

Built Distribution

deepl_scraper_pp2-0.1.0a2-py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 3

Supported by

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