Skip to main content

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"

Metadata

Release files for groove 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for groove 1.0.4
File Size Uploaded
groove-1.0.4.tar.gz 42.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for groove 1.0.4
File Interpreter ABI Platform
groove-1.0.4-cp310-cp310-manylinux_2_31_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.31+ x86-64 Details
groove-1.0.4-cp310-cp310-macosx_11_0_x86_64.whl CPython 3.10 CPython 3.10 macOS 11.0+ x86-64 Details

Total release size: 71.0 kB

Release files / groove-1.0.4.tar.gz

Download URL groove-1.0.4.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7f722df5098d27473ada8473dc8166b6a45545f71e211d251aaba3357e994c3b
BLAKE2b-256 checksum
How to use checksums
5ba6ced84bed5a639a893167ea9041535350dc0c108251ae0c171adca8a0f061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure

Release files / groove-1.0.4-cp310-cp310-manylinux_2_31_x86_64.whl

Download URL groove-1.0.4-cp310-cp310-manylinux_2_31_x86_64.whl
Size 14.5 kB
Tags CPython 3.10 Linux glibc 2.31+ x86-64
SHA-256 checksum
How to use checksums
17cdd7fe8f0ab93a89f28e1e81316f8e28b2d83889b4d6d39d087e1e2f46f51c
BLAKE2b-256 checksum
How to use checksums
31c5d4bf3ffa410935e6641780b1ac52c5e7a621569b54ca06fb1a71b2a7ac7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure

Release files / groove-1.0.4-cp310-cp310-macosx_11_0_x86_64.whl

Download URL groove-1.0.4-cp310-cp310-macosx_11_0_x86_64.whl
Size 14.5 kB
Tags CPython 3.10 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
e89696e8ccb6e683758b5f6dee99936ad94fb2c1c48b5aac33e13f2ded37f7ca
BLAKE2b-256 checksum
How to use checksums
c00125dbdb9f3b29f0eeb36384b2b212e8bb6075dd7d8c5a9a8301f5031f2ed5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure

Release history Release notifications | RSS feed

This release

1.0.4 This release

3 release files

1.0.3

3 release files

0.1.1

3 release files

0.1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page