Skip to main content

Python wrapper for Chromium's http library

Project description

python-cronet

python-cronet is a library to use Chromium's network stack from Python.

The library is currently in alpha stage.

What is Cronet

Cronet is the networking stack of Chromium put into a library for use on Android. It offers an easy-to-use, high performance, standards-compliant, and secure way to perform HTTP requests.

The Chromium team also provides a native version of the library(not officially supported) which allows you to use it in desktop/server operating systems like Linux, macOS and Windows.

The main benefits of using cronet as an HTTP client are:

  • You get to use the same high quality code that runs on Chromium.
  • Support for the latest protocols like QUIC and compression formats.
  • Concurrency support by performing asynchronous requests.
  • Has the same TLS fingerprint as Chrome, meaning that Cloudflare and other bot detection systems can't block your requests based on it.
  • It's much more lightweight on system resources compared to headless Chrome(although it doesn't support executing javascript).

Installation

For the time being the only supported platform is linux-x86-64. The plan is to also support windows and macOS.

pip install python-cronet

Example usage

The library provides an asynchronous API:

import asyncio
import cronet

async def main():
    with cronet.Cronet() as cr:
        # GET request
        response = await cr.get("https://httpbin.org/get")
        print(f"GET request: {response.url}, {response.status_code}")
        print(f"Response JSON: {response.json()}")

        # GET request with query parameters
        params = {"param1": "value1", "param2": "value2"}
        response = await cr.get("https://httpbin.org/get", params=params)
        print(f"GET request with params: {response.url}, {response.status_code}")
        print(f"Response JSON: {response.json()}")

        # POST request with form data
        data = {"key1": "value1", "key2": "value2"}
        response = await cr.post("https://httpbin.org/post", data=data)
        print(f"POST request: {response.url}, {response.status_code}")
        print(f"Response JSON: {response.json()}")

        # PUT request with JSON data
        json_data = {"key1": "value1", "key2": "value2"}
        response = await cr.put("https://httpbin.org/put", json=json_data)
        print(f"PUT request: {response.url}, {response.status_code}")
        print(f"Response JSON: {response.json()}")

        # PATCH request with custom headers
        headers = {"X-Custom-Header": "MyValue"}
        response = await cr.patch("https://httpbin.org/patch", headers=headers)
        print(f"PATCH request: {response.url}, {response.status_code}")
        print(f"Response JSON: {response.json()}")

        # DELETE request
        response = await cr.delete("https://httpbin.org/delete")
        print(f"DELETE request: {response.url}, {response.status_code}")
        print(f"Response JSON: {response.json()}")


asyncio.run(main())

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

python_cronet-0.1.6-cp313-cp313-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

python_cronet-0.1.6-cp312-cp312-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

python_cronet-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

python_cronet-0.1.6-cp310-cp310-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

python_cronet-0.1.6-cp39-cp39-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

python_cronet-0.1.6-cp38-cp38-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

File details

Details for the file python_cronet-0.1.6-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_cronet-0.1.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e60b5ef9be2a11fa5fe525d1b11e42930031354ed2c4ee69ec9687741a33a0a
MD5 a1f7d8d12dcba8d6d0c244e409b2a36b
BLAKE2b-256 9a4d010d210c0520d9c86fe66cf8de50295d81d2c8705400e8a965e03049fa87

See more details on using hashes here.

File details

Details for the file python_cronet-0.1.6-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_cronet-0.1.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5d26c0ab67b99c8bcf9d8fc0de4bf9f8b861e997fa5b1e707ba3f8579ba1783
MD5 1ab5b85939568d0abde8f59ab8242153
BLAKE2b-256 8f98570ebdfb0d8fb0c15ff34b4b7d66e7ec30bf7c720e88d0a3cefa0dea4748

See more details on using hashes here.

File details

Details for the file python_cronet-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_cronet-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5dbfb0e0b58914d1ec06a50a9bf66f0aed9a90878da1483f3d86dfe274a3c8ee
MD5 d7e5cadb591f237a646c38164062d515
BLAKE2b-256 ec5ff628a46ad312b18476b3b69194fc1893300c3904e2d8255c9be828233084

See more details on using hashes here.

File details

Details for the file python_cronet-0.1.6-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_cronet-0.1.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4af2c8af88320c89222c2010c8a801c363a6e7dfd2f9dffcb2f4746b1392280
MD5 1f4049bff25876e2171d217a6e70eb3f
BLAKE2b-256 6e70cfeae53c3c51a9916f8f26b156033596857f215eb3c44eb5e7a3ddf8ded1

See more details on using hashes here.

File details

Details for the file python_cronet-0.1.6-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_cronet-0.1.6-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd2023e3583a902100872c204c96d18be2a1c801c3982d9b3a5121ccc4a395bd
MD5 5eb9c0f4cae21d37a568429377220ec3
BLAKE2b-256 8788b4367af698ddbd34ccab8a2663c09d9e9e40751a4a60fe0fe50c7cb806ef

See more details on using hashes here.

File details

Details for the file python_cronet-0.1.6-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_cronet-0.1.6-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6910e40cc2ea33889d1798b065ba2136ee2708cb74d84e7e0697d20eddc1cc35
MD5 9659459cb67611cc05e0fabb187e325b
BLAKE2b-256 3bb6aa33b27910b976b04ad1a93e7ed9c957d253b9bd91871dc22b8e42c569ed

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