Skip to main content

Generate Python Requests code from HAR file

Project description

har2requests

  • Step 1: Interact with a website from your usual browser
  • Step 2: automatically generate the Python code to replay your requests

Motivation

To write bots in Python, the two main options are:

Of course, requests bots are more stable but they require more daunting work to reverse engineer the javascript code and reproduce every request made by the client.

Discover har2requests!

Features

  • Automatic requests code generation from a HAR file
  • Detection of the headers common to all requests and code factorization
  • Clever inference on the origin of authorization headers
  • Code formatting using black

Installation

pip install har2requests

Usage

From Chrome or Firefox, go to the Network tab of the Developer Tools, put the filters you want and export to HAR.

To read from a file:

har2requests input.har > output.py

To read from the clipboard:

pbpaste | har2requests - > output.py

By default, OPTIONS requests are ignored. To include them, use --include-options.

When encountering errors, you can use the --unsafe feature that will display warnings instead of errors if the HAR file does not fit the specification.

har2requests uses string matching algorithms to find the origin of authorization headers. If your file is too big, it might be slow. You can disable it with --no-infer.

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

har2requests-0.2.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

har2requests-0.2.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file har2requests-0.2.1.tar.gz.

File metadata

  • Download URL: har2requests-0.2.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.8

File hashes

Hashes for har2requests-0.2.1.tar.gz
Algorithm Hash digest
SHA256 80770dd4b72c5ffa9b77f6fb44ff26244ce43d86f8454aca03628e97ad9d6722
MD5 b5e8db8cca759d29d4f8ac5fd01b8377
BLAKE2b-256 57a33e3e64d08e8851c261c055ebf1edd8a4f4a9f247c6fab21273a01666e566

See more details on using hashes here.

File details

Details for the file har2requests-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: har2requests-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.8

File hashes

Hashes for har2requests-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53eaac03e2a4032d0943f446759e7f35a95278a244fe317eef882cc80c60ed58
MD5 21344276c210e487a5328cb58cc7320b
BLAKE2b-256 52c307d76d59ee526c1492fe0311ac9f6a0d15501b2541cdb9c82927e3f0e8b1

See more details on using hashes here.

Supported by

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