Skip to main content

Python module to generate realistic screen resolutions from real-world StatCounter data.

Project description

fakewindowsize banner

fakewindowsize

CI PyPI version Python versions License: MIT DeepWiki

Python module to generate realistic screen resolutions.

Generate random but statistically accurate screen resolutions based on real-world usage data from StatCounter. Perfect for web scraping, testing, and generating realistic browser fingerprints.

Note on terminology: the data source is StatCounter's screen resolution stats (i.e. screen.width × screen.height, the physical display size), not the browser viewport / window inner size (window.innerWidth). For most fingerprinting use cases the screen resolution is exactly what you want.

Features

  • 📊 Real-world data: Uses screen resolution statistics from StatCounter (defaults to the previous, complete year)
  • 🎲 Weighted random selection: More common resolutions are more likely to be returned
  • 💾 Smart caching: Caches data locally (with a TTL) to minimize network requests
  • 📱 Multi-device support: Includes desktop, tablet, and mobile resolutions
  • 🌍 Configurable: Choose the year, region and device mix
  • 🔒 Proxy support: Configure HTTP proxies for data fetching

Installation

pip install fakewindowsize

Or with uv:

uv add fakewindowsize

Usage

Basic usage

import fakewindowsize

f = fakewindowsize.FakeWindowSize()

# Get a random, statistically realistic window size
width, height = f.get_random_window_size()
print(f"{width}x{height}")  # e.g., (1920, 1080)

Choosing year / region / device

# US desktop resolutions from the 2024 dataset
f = fakewindowsize.FakeWindowSize(year=2024, region="us", device="desktop")
width, height = f.get_random_window_size()
  • year: StatCounter yearly dataset (defaults to the previous calendar year, which is always complete).
  • region: StatCounter region code (ww, us, eu, ...).
  • device: +-joined device types (desktop+tablet+mobile, desktop, mobile, ...).
  • cache_ttl_days: how long the local cache stays fresh (default 30; None to never expire).
  • request_timeout: seconds before an HTTP request times out (default 30).

Each parameter combination is cached in its own file, so different regions/years never clobber each other.

With proxy support

f = fakewindowsize.FakeWindowSize()

proxies = {
    'http': 'http://proxy.example.com:8080',
    'https': 'http://proxy.example.com:8080',
}

data = f.scrape_window_size_dict(request_proxies=proxies)

How it works

  1. Fetches screen resolution statistics from StatCounter's global database
  2. Converts market share percentages into a cumulative distribution
  3. Uses weighted random selection to pick resolutions based on real-world usage
  4. Caches data locally (~/.fakewindowsize-<device>-<region>-<year>.json) to reduce network requests
  5. Returns resolution as a tuple of (width, height)

Data source

Screen resolution data is sourced from StatCounter Global Stats, which tracks browser usage across desktop, tablet, and mobile devices worldwide.

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

fakewindowsize-0.8.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fakewindowsize-0.8.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file fakewindowsize-0.8.2.tar.gz.

File metadata

  • Download URL: fakewindowsize-0.8.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fakewindowsize-0.8.2.tar.gz
Algorithm Hash digest
SHA256 6de82f43e160e16cb1f74f040a1b1a72b0417a156ef98d518ff38701825e2db5
MD5 a62974ae50d0b24db87ce117eb228a48
BLAKE2b-256 bd1935c5c0e0403157dabd07d15666360d90dcd7cf9d591b513c4dca2ebad375

See more details on using hashes here.

Provenance

The following attestation bundles were made for fakewindowsize-0.8.2.tar.gz:

Publisher: publish.yml on carlosplanchon/fakewindowsize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fakewindowsize-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: fakewindowsize-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fakewindowsize-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 57a2582e5d1234dccc264d911f3b7e0a7a546ae014d23e34b169c26f5d5678d9
MD5 25b7f391e002662557cf7b4e9423be66
BLAKE2b-256 5e0e082f42ab55fd42268af265fed15c6b129a978c5fc3eba489928a11a0f0c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fakewindowsize-0.8.2-py3-none-any.whl:

Publisher: publish.yml on carlosplanchon/fakewindowsize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page