Skip to main content

No project description provided

Project description

Groove

Python APIs for Groove, a proxy server built for web crawling and unit test mocking. Highlights of its primary features:

  • HTTP and HTTPs support over HTTP/1 and HTTP/2.
  • Local CA certificate generation and installation on Mac and Linux to support system curl and Chromium.
  • Different tiers of caching support - from disabling completely to aggressively maintaining all body archives.
  • Limit outbound requests of the same URL to 1 concurrent request to save on bandwidth if requests are already inflight.
  • Record and replay requests made to outgoing servers. Recreate testing flows in unit tests while separating them from crawling business logic.
  • 3rd party proxy support for commercial proxies.
  • Custom TLS Hello Client support to maintain a Chromium-like TLS handshake while intercepting requests and re-forwarding on packets.

For more information, see the Github project.

Usage

Add groove to your project and install the local certificates that allow for https certificate generation:

pip install groove
install-ca

Instantiating Groove with the default parameters is usually fine for most deployments. To ensure we clean up resources once you're completed with the proxy, wrap your code in the launch contextmanager.

from groove.proxy import Groove
from requests import get
from pathlib import Path

proxy = Groove()
with proxy.launch():
    response = get(
        "https://www.example.com",
        proxies={
            "http": proxy.base_url_proxy,
            "https": proxy.base_url_proxy,
        },
        verify=str(Path("~/.grooveproxy/ca.crt").expanduser()),
    )
    assert response.status_code == 200

Create a fully fake outbound for testing:

from groove.proxy import Groove
from groove.tape import TapeRecord, TapeRequest, TapeResponse, TapeSession
from requests import get
from pathlib import Path

records = [
    TapeRecord(
        request=TapeRequest(
            url="https://example.com:443/",
            method="GET",
            headers={},
            body=b"",
        ),
        response=TapeResponse(
            status=200,
            headers={},
            body=b64encode("Test response".encode())
        ),
    )
]

proxy = Groove()
with proxy.launch():
    proxy.tape_load(
        TapeSession(
            records=records
        )
    )

    response = get(
        "https://www.example.com",
        proxies={
            "http": proxy.base_url_proxy,
            "https": proxy.base_url_proxy,
        },
        verify=str(Path("~/.grooveproxy/ca.crt").expanduser())
    )
    assert response.content == b"Test response"

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

groove-1.0.3.tar.gz (41.3 kB view details)

Uploaded Source

Built Distributions

groove-1.0.3-cp310-cp310-manylinux_2_31_x86_64.whl (14.0 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.31+ x86-64

groove-1.0.3-cp310-cp310-macosx_10_16_x86_64.whl (14.0 kB view details)

Uploaded CPython 3.10 macOS 10.16+ x86-64

File details

Details for the file groove-1.0.3.tar.gz.

File metadata

  • Download URL: groove-1.0.3.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

File hashes

Hashes for groove-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d2cb182bf13a149c73ed5a102716e421593802bccd28abc7e1fc83a002c42353
MD5 aa8aca7fcdc1389d99e81ba719051cd9
BLAKE2b-256 9502e3dcc1ef537dc9480942c6452c8d2a55f05a2071ba96ae3d3f9a4330012f

See more details on using hashes here.

File details

Details for the file groove-1.0.3-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

  • Download URL: groove-1.0.3-cp310-cp310-manylinux_2_31_x86_64.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: CPython 3.10, manylinux: glibc 2.31+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

File hashes

Hashes for groove-1.0.3-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 ed2a8e8d7148cbe0c8465d4221c22d66e9faaf38814c32ae0be05bae7e5e74fb
MD5 453536fbbf40630d714cfc8a9cfdbe3e
BLAKE2b-256 035ebe914276456cadbcd63415a72083e310dae8d6fe5ca672523095bb14e014

See more details on using hashes here.

File details

Details for the file groove-1.0.3-cp310-cp310-macosx_10_16_x86_64.whl.

File metadata

File hashes

Hashes for groove-1.0.3-cp310-cp310-macosx_10_16_x86_64.whl
Algorithm Hash digest
SHA256 73f7a3ab0f8a2a2f3bce79e3b558a98ba309dc4d360474f58eab4df5acdeb927
MD5 5f02e5320436ef95b4958ffa25aa69d3
BLAKE2b-256 d371a6856d25ec47dc042b14575fc6f403b90b6140728be93df15d347ec932d9

See more details on using hashes here.

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