Skip to main content

A python requests wrapper for spoofing common browser behaviour

Project description


Web bot for spoofing browser behaviour when using python requests. Supports Firefox and Chrome browser on most generic Windows, MacOS and Linux spoofing.

Example usage

browser = Chrome()
cache = CacheAdapter()
browser.session.mount('https://', cache)
browser.session.mount('http://', cache)

spec = browser.get('').json()
# A simple HTTP Request & Response Service.<br/> <br/> <b>Run locally: </b> <code>$ docker run -p 80:80 kennethreitz/httpbin</code>
headers = browser.navigate(
    headers={'Accept': 'mime/type'}
# mime/type


spoofbot allows for useragents to be generate using information like the platform and browser version. Currently, only Firefox and Chrome are supported, but through inheritance one can add more browsers. Firefox indicates that brotli encoding (br) is acceptable, but that might lead to issue swhen parsing the responses. It is possible to change that default header:

browser = Firefox()
browser._accept_encoding = ['deflate', 'gzip']  # brotli (br) is cumbersome

File Cache

Using CacheAdapter, one can store responses (without metadata such as headers) in the filesystem. It supports deleting the last request or a specific file from the cache. The cache indicates whether the last made request got a cache hit. If there is a request that should be cached that cannot be adequately stored with only hostname and path, one can specify and alternative url to use instead of the request's prior to the request. This last case is also supported when deleting the last request.

Har Cache

Using HarAdapter, one is able to load .har files to use as cache. This cache does not make actual http requests to the net, but fails if no matching request could be found. It can be specified whether matching a request should be strict (must match all headers) or not.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for spoofbot, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size spoofbot-0.1.1-py3-none-any.whl (13.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size spoofbot-0.1.1.tar.gz (11.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page