BrowserForge

1.2.4 · active · verified Sat Apr 11

BrowserForge is a Python library designed for intelligent browser header and fingerprint generation. It mimics the frequency of different browsers, operating systems, and devices found in the wild using a Bayesian generative network, providing realistic HTTP headers for web scraping and automation. It is a re-implementation of Apify's fingerprint-suite in Python, known for its extremely fast runtime and extensive customization options. The current version is 1.2.4, and it is actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate a set of realistic browser headers using `HeaderGenerator` and then apply them to a `requests` session. This is the primary and recommended use case for BrowserForge in its current iteration.

import requests
from browserforge.headers import HeaderGenerator

# Initialize the HeaderGenerator
generator = HeaderGenerator(
    browser='chrome',
    os='windows',
    device='desktop'
)

# Generate a set of realistic headers
headers = generator.generate()

print("Generated Headers:")
for key, value in headers.items():
    print(f"  {key}: {value}")

# Example of using generated headers with the requests library
try:
    response = requests.get('https://httpbin.org/headers', headers=headers, timeout=10)
    response.raise_for_status() # Raise an exception for HTTP errors
    print("\nResponse from httpbin.org:")
    print(response.json())
except requests.exceptions.RequestException as e:
    print(f"\nError making request: {e}")

view raw JSON →