Skip to main content

Spoofbot

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)

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

Browsers

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

The browsers have an automatic request delay built in which can be controlled with the request_timeout and honor_timeout. After requests have been made, did_wait and waiting_period provide further information.

File Cache

Using FileCacheAdapter, 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.

Release files for spoofbot 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spoofbot 0.1.3
File Size Uploaded
spoofbot-0.1.3.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spoofbot 0.1.3
File Interpreter ABI Platform
spoofbot-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / spoofbot-0.1.3.tar.gz

Download URL spoofbot-0.1.3.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d63762fc55912c6534108ee9c6def422e3858b22033013907d30320c8859c990
BLAKE2b-256 checksum
How to use checksums
81b347883eca384cc860e044f70ceae2c60b73b8e31ceaac39930c34454b1a3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release files / spoofbot-0.1.3-py3-none-any.whl

Download URL spoofbot-0.1.3-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57ca8fe86f105e32c0030ed690e7cb04203cb911b43353f9391c5ba144e31660
BLAKE2b-256 checksum
How to use checksums
c3a8244b85601bb858a8149309f04061735cdcf7f390c83ee069a1d44fa48339
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

Release history Release notifications | RSS feed

1.4.0

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

3 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

1 release file

1.1.0

1 release file

1.0.2

2 release files

1.0.1

2 release files

1.0.0

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

2 release files

0.2.1

2 release files

0.2

2 release files

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page