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

TODO

  • Use requests.Session
  • Handle cookies (e.g. with a session)
  • handle text field from post requests

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.1.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

har2requests-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: har2requests-0.1.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for har2requests-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5ab6efc0e660ab543f02e1e80203028cee8e8133890461bb6ca950ca70bb9ce2
MD5 d7877a52c9367d1437d76e39b0f15ce5
BLAKE2b-256 14bb619de87eb8c5a06f43faa67956fb363ce26a18f3146c0bc3672b176d88e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: har2requests-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for har2requests-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f5b4df4a3bab731c29eebeab92d7c2649877973f344a533418add87b87174d68
MD5 815b309fc95584786af2710a90b83b32
BLAKE2b-256 fa44e616c725560ac1bfde522857ee04af54e3727d66c5062be10e7bf983901d

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