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
Built Distributions
File details
Details for the file groove-1.0.4.tar.gz
.
File metadata
- Download URL: groove-1.0.4.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f722df5098d27473ada8473dc8166b6a45545f71e211d251aaba3357e994c3b |
|
MD5 | 59ceeb5054bc8725f2d21c2fa2e8b277 |
|
BLAKE2b-256 | 5ba6ced84bed5a639a893167ea9041535350dc0c108251ae0c171adca8a0f061 |
File details
Details for the file groove-1.0.4-cp310-cp310-manylinux_2_31_x86_64.whl
.
File metadata
- Download URL: groove-1.0.4-cp310-cp310-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 14.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17cdd7fe8f0ab93a89f28e1e81316f8e28b2d83889b4d6d39d087e1e2f46f51c |
|
MD5 | 4dd4c7150a829926b00908190365d7da |
|
BLAKE2b-256 | 31c5d4bf3ffa410935e6641780b1ac52c5e7a621569b54ca06fb1a71b2a7ac7d |
File details
Details for the file groove-1.0.4-cp310-cp310-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: groove-1.0.4-cp310-cp310-macosx_11_0_x86_64.whl
- Upload date:
- Size: 14.5 kB
- Tags: CPython 3.10, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e89696e8ccb6e683758b5f6dee99936ad94fb2c1c48b5aac33e13f2ded37f7ca |
|
MD5 | 395e74e7dc6b054d65175d0625ba4e98 |
|
BLAKE2b-256 | c00125dbdb9f3b29f0eeb36384b2b212e8bb6075dd7d8c5a9a8301f5031f2ed5 |