Oven logo

Oven

primp1.1.2

Published

HTTP client that can impersonate web browsers

pip install primp

Package Downloads

Weekly DownloadsMonthly Downloads

Authors

Project URLs

Requires Python

>=3.10

Python >= 3.10 Downloads CI

🪞 PRIMP 🐍

HTTP client that can impersonate web browsers.

📦 Installation

pip install -U primp

🔧 Building from Source

git clone https://github.com/deedy5/primp.git && cd primp

# Build python library using cargo
cargo build -r -p primp-python

# Build python library using maturin
cd crates/primp-python
python -m venv .venv && source .venv/bin/activate  # Linux/macOS
pip install maturin && maturin develop -r

🚀 Quick Start

Sync API

import primp

# Create client with browser impersonation
client = primp.Client(impersonate="chrome_145")

# Make requests
resp = client.get("https://tls.peet.ws/api/all")
print(resp.status_code)  # 200
print(resp.text)         # Response body
print(resp.json())       # Parsed JSON

Async API

import asyncio
import primp

async def main():
    async with primp.AsyncClient(impersonate="chrome_145") as client:
        resp = await client.get("https://tls.peet.ws/api/all")
        print(resp.text)

asyncio.run(main())

📊 Benchmark

🎭 Browser Impersonation

BrowserProfiles
🌐 Chromechrome_144, chrome_145
🧭 Safarisafari_18.5, safari_26
🔷 Edgeedge_144, edge_145
🦊 Firefoxfirefox_140, firefox_146
Operaopera_126, opera_127
🎲 Randomrandom
OSValue
🤖 Androidandroid
🍎 iOSios
🐧 Linuxlinux
🍏 macOSmacos
🪟 Windowswindows
🎲 Randomrandom

⚡ Features

  • 🔥 Fast - Built with Rust
  • 🎭 Browser Impersonation - Mimic Chrome, Safari, Firefox, Edge, Opera
  • 🌍 OS Impersonation - Windows, Linux, macOS, Android, iOS
  • 🔄 Sync & Async - Both APIs available
  • 🍪 Cookie Management - Persistent cookie store
  • 🌐 Proxy Support - HTTP, HTTPS, SOCKS5
  • 📝 HTML Conversion - Convert to markdown, plain text, rich text
  • 📤 File Uploads - Multipart/form-data support
  • 🔐 SSL Verification - Custom CA certificates

📖 Response Object

Standard Response

All properties work identically for both sync and async responses:

PropertyTypeDescription
.urlstrFinal response URL (after redirects)
.status_codeintHTTP status code
.contentbytesRaw response body as bytes
.encodingstrCharacter encoding (read/write)
.textstrDecoded text content
.headersdictResponse headers dictionary
.cookiesdictResponse cookies
.text_markdownstrHTML converted to Markdown
.text_plainstrHTML converted to plain text
.text_richstrHTML converted to rich text
MethodDescription
.json()Parse response body as JSON. Raises json.JSONDecodeError on invalid JSON.
.raise_for_status()Raise StatusError for 4xx/5xx status codes

Streaming Response

Use stream=True to get a StreamResponse for efficient handling of large data:

# Sync streaming
with primp.get("https://example.com/large-file.zip", stream=True) as response:
    for chunk in response.iter_bytes():
        process(chunk)

# Async streaming
async with await client.get("https://example.com/large-file.zip", stream=True) as response:
    async for chunk in response.aiter_bytes():
        process(chunk)
Sync MethodAsync MethodDescription
.read().aread()Read remaining content into memory
.iter_bytes(chunk_size).aiter_bytes(chunk_size)Iterate over byte chunks
.iter_text(chunk_size).aiter_text(chunk_size)Iterate over decoded text chunks
.iter_lines().aiter_lines()Iterate over lines
.next().anext()Get next chunk explicitly
.close().aclose()Close response and release resources

📚 Examples

See the /examples folder for detailed usage:


Disclaimer

This tool is for educational purposes only. Use it at your own risk.