HTTP client that can impersonate web browsers, mimicking their headers and `TLS/JA3/JA4/HTTP2` fingerprints
Project description
Pyreqwest_impersonate
The fastest python HTTP client that can impersonate web browsers by mimicking their headers and TLS/JA3/JA4/HTTP2
fingerprints.
Binding to the Rust reqwest_impersonate
library.
🏁 Check the benchmarks for more details.
Provides precompiled wheels:
- Linux:
amd64
,aarch64
. - Windows:
amd64
. - MacOS:
amd64
,aarch64
.
Table of Contents
Installation
pip install -U pyreqwest_impersonate
Usage
I. Client
A blocking HTTP client that can impersonate web browsers.
class Client:
"""Initializes a blocking HTTP client that can impersonate web browsers.
Args:
auth (tuple, optional): A tuple containing the username and password for basic authentication. Default is None.
auth_bearer (str, optional): Bearer token for authentication. Default is None.
params (dict, optional): Default query parameters to include in all requests. Default is None.
headers (dict, optional): Default headers to send with requests. If `impersonate` is set, this will be ignored.
timeout (float, optional): HTTP request timeout in seconds. Default is 30.
proxy (str, optional): Proxy URL for HTTP requests. Example: "socks5://127.0.0.1:9150". Default is None.
impersonate (str, optional): Entity to impersonate. Example: "chrome_123". Default is None.
Chrome: "chrome_99","chrome_100","chrome_101","chrome_104","chrome_105","chrome_106","chrome_108",
"chrome_107","chrome_109","chrome_114","chrome_116","chrome_117","chrome_118","chrome_119",
"chrome_120","chrome_123"
Safari: "safari_12","safari_15_3","safari_15_5","safari_15_6_1","safari_16","safari_16_5","safari_17_2_1"
OkHttp: "okhttp_3_9","okhttp_3_11","okhttp_3_13","okhttp_3_14","okhttp_4_9","okhttp_4_10","okhttp_5"
Edge: "edge_99","edge_101","edge_120"
follow_redirects (bool, optional): Whether to follow redirects. Default is False.
max_redirects (int, optional): Maximum redirects to follow. Default 20. Applies if `follow_redirects` is True.
verify (bool, optional): Verify SSL certificates. Default is True.
http1 (bool, optional): Use only HTTP/1.1. Default is None.
http2 (bool, optional): Use only HTTP/2. Default is None.
"""
Client Methods
The Client
class provides a set of methods for making HTTP requests: get
, head
, options
, delete
, post
, put
, patch
, each of which internally utilizes the request()
method for execution. The parameters for these methods closely resemble those in httpx
.
get(url, *, params=None, headers=None, auth=None, auth_bearer=None, timeout=None)
Performs a GET request to the specified URL.
- url (str): The URL to which the request will be made.
- params (Optional[Dict[str, str]]): A map of query parameters to append to the URL. Default is None.
- headers (Optional[Dict[str, str]]): A map of HTTP headers to send with the request. Default is None.
- auth (Optional[Tuple[str, Optional[str]]]): A tuple containing the username and an optional password for basic authentication. Default is None.
- auth_bearer (Optional[str]): A string representing the bearer token for bearer token authentication. Default is None.
- timeout (Optional[float]): The timeout for the request in seconds. Default is 30.
post(url, *, params=None, headers=None, content=None, data=None, files=None, auth=None, auth_bearer=None, timeout=None)
Performs a POST request to the specified URL.
- url (str): The URL to which the request will be made.
- params (Optional[Dict[str, str]]): A map of query parameters to append to the URL. Default is None.
- headers (Optional[Dict[str, str]]): A map of HTTP headers to send with the request. Default is None.
- content (Optional[bytes]): The content to send in the request body as bytes. Default is None.
- data (Optional[Dict[str, str]]): The form data to send in the request body. Default is None.
- files (Optional[Dict[str, str]]): A map of file fields to file paths to be sent as multipart/form-data. Default is None.
- auth (Optional[Tuple[str, Optional[str]]]): A tuple containing the username and an optional password for basic authentication. Default is None.
- auth_bearer (Optional[str]): A string representing the bearer token for bearer token authentication. Default is None.
- timeout (Optional[float]): The timeout for the request in seconds. Default is 30.
Example
from pyreqwest_impersonate import Client
client = Client(impersonate="chrome_123")
# get request
resp = client.get("https://tls.peet.ws/api/all")
print(resp.json())
# post request
data = {"key1": "value1", "key2": "value2"}
auth = ("user", "password")
resp = client.post(url="https://httpbin.org/anything", data=data, auth=auth)
print(resp.text)
II. AsyncClient
TODO
III. Response Object
Key Features
High Performance
: The attributes of theResponse
object are executed in Rust, which is known for its high performance. This ensures that operations like accessing headers, decoding text, or parsing JSON are very fast.Lazy Execution
: All attributes of theResponse
object are executed lazily. This means that the actual computation or data retrieval happens only when you access the attribute, not when theResponse
object is created. This approach optimizes performance by avoiding unnecessary computations.Automatic Character Encoding Detection
: TheResponse
object intelligently detects the character encoding of the response body from the "Content-Type" header. If the encoding is not specified, it defaults to "UTF-8".
Response attributes and methods
cookies
: Fetches the cookies from the response as a dictionary.headers
: Retrieves the headers from the response as a dictionary.status_code
: Gets the status code of the response as an integer.url
: Returns the URL of the response as a string.content
: Provides the content of the response as bytes.text
: Decodes the response body into text, automatically detecting the character encoding.json()
: Parses the response body as JSON, converting it into a Python object for easy manipulation.
Example
from pyreqwest_impersonate import Client
client = Client()
response = client.get("https://example.com")
print(response.status_code) # Access the status code
print(response.url) # Access the URL
print(response.headers) # Access headers
print(response.cookies) # Access cookies
print(response.content) # Get the content as bytes
print(response.text) # Decode the content as text
print(response.json()) # Parse the content as JSON
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyreqwest_impersonate-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a4dafd49fda722bf04e0995c1a0df027c0cbb7b834561960825999169e20f38 |
|
MD5 | cee2836d8de04baf2eafaf5eb8b26c9d |
|
BLAKE2b-256 | 784e1e5cd3b8fa778d427804b53610ef3693cda64854d6cd2e4e122afead817b |
Hashes for pyreqwest_impersonate-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea09a05d7ecb8d16d6466200366a764a405fbf57abbb40424f3f7ceba9dec32e |
|
MD5 | 589d212c55ca8db4396b38f462b0c84d |
|
BLAKE2b-256 | f4f6f2cf92859f062b9a23a88288849ecb0b410dfc2516d4e1ca58402b0e56dc |
Hashes for pyreqwest_impersonate-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ccba7503d09b6f86a4b5f6923730d5fc34b8fb6c8229df9834294dbca459c48 |
|
MD5 | c2a18e50ab41c3897ed9e025755d8f3f |
|
BLAKE2b-256 | d6c1d9d9b4b5e6ad20b7f300dbb363ee2e2309a393bf1b8fba3e56aa8a91bab8 |
Hashes for pyreqwest_impersonate-0.2.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2631c8a9c23aa46c44ca6e291df49956c5a29c1363c0dfcb00b1a63c25039c5 |
|
MD5 | 3150f27dda3088433983c6313e8b0d71 |
|
BLAKE2b-256 | 5479a29022cf9ecd3471ca43afb32fe7ea8d02fa89301eaa0e6e64c623fe33ab |
Hashes for pyreqwest_impersonate-0.2.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5120e5f9371bd63b4446660e9430f1f3a8cf8d2a0b54e1a63219edc735ddadb |
|
MD5 | 9b871976232da2e58645aa3df223f7e5 |
|
BLAKE2b-256 | a5b971ae79404e98bc48640c5cfb3d2e7851a75319045bfe0095c1135b95bf60 |
Hashes for pyreqwest_impersonate-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6034ca84231b1a0d11efc392bb0d07244581d37e2b4c6f610ce2e609670015c9 |
|
MD5 | e605c67762490b164169d7393942a3be |
|
BLAKE2b-256 | 953e87a0028ff662151849542b8d05301b3f73e3c088b72785d8e8f441531db4 |
Hashes for pyreqwest_impersonate-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 832579ded92439e038673f87462d1190c901f93e304290bc96490df022ba2f51 |
|
MD5 | 429b33ff120fb17f312df51fb5401c7a |
|
BLAKE2b-256 | 4e39c721f3075a1ca23ead62c561aec8a64be365f40408f473713794ca28d371 |
Hashes for pyreqwest_impersonate-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 993d3516e644bac8cdbc07b191b1df4ece402bff501a4db7a0e653b12632adc2 |
|
MD5 | 088bcae874cfa051f7f427afc5ab6af3 |
|
BLAKE2b-256 | b092081597b9b7feac38e7f37c7c9ad39c82c319aff30709c25a0bf85d5c8e6c |
Hashes for pyreqwest_impersonate-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65dc50994fd51148a6e633a8c6d45c393def37505b6643d5b6a2841e633264da |
|
MD5 | ec147328fc2bd5f1ec8a01051c7855b8 |
|
BLAKE2b-256 | 7b3bfbf8e6911bd40104c415d7c9285d6d948a529662b1801309141f0577322f |
Hashes for pyreqwest_impersonate-0.2.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aee4d4c9b5d8f5c00a036cee8e935c629c32bda2200550c1346234b844662dec |
|
MD5 | 9ee7dce84e2530a22c08236070f47635 |
|
BLAKE2b-256 | 230af6ebba3b7f9609e206edc2bb1df85a66a448ac27a2e4be3c920c8c997609 |
Hashes for pyreqwest_impersonate-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 979eab1be17934bfd848f498cd34a42b033a72bb003e0c576219dbb693e3fb52 |
|
MD5 | 5eab45122c80cdc6ed20e6ed2eec08e2 |
|
BLAKE2b-256 | 73ce2880d6d015c9da0feec2bf3ef76f921cbc6610c495afdb7f3ecafe6f0f82 |
Hashes for pyreqwest_impersonate-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f763790daf98ff94627e6ea8349203d9367f7b08ecc3deee9fd3d61eb46e6a5 |
|
MD5 | 2d905b1bb24c65e9536ceab16376f52d |
|
BLAKE2b-256 | ed2c4368b85bc5eb3e331e3d015d2b18b31a6f922b252d55e27416f4e2482489 |
Hashes for pyreqwest_impersonate-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8a89a4edb7ea5de0858299cf4af8af980a19b228896f1201da986cf35d9b5e8 |
|
MD5 | 00fd6cc9a2ceec7909735f0ada4a2058 |
|
BLAKE2b-256 | 557c761dabfc7f3de12edfd4855ca1ea24d3964da99acbe928a4ceccbe4a841f |
Hashes for pyreqwest_impersonate-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1d696f18225bb4a146cf75a6f27281b8a0275117ab4e1fae6cd0a0e6937c5da |
|
MD5 | ee282d2d23de9a7b4626458059b9a755 |
|
BLAKE2b-256 | d3c54243b1557e6b9737ac14e40b30ab9ec3bc959343f678260f6ca1c415e5a3 |
Hashes for pyreqwest_impersonate-0.2.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5d423e2aad74cec291760dbd07bafb04079849da9006d2abec8118faf38548b |
|
MD5 | 0cce37ddd55b07406e641cedb0d13c4e |
|
BLAKE2b-256 | c019cb60f47b4ba05a5bbc58df2e233a2c79cd6ec6ae8145044d78e648fe72fe |
Hashes for pyreqwest_impersonate-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20af1203ae92289943fdc5a54880577ddc6706f1ec94cfd12fd27c170d5668bc |
|
MD5 | 41239354349051d2821ff632e5818009 |
|
BLAKE2b-256 | e81b20cd3863b6056be3f5c7af49955403aef0d40dbb061b8738ab4a0d64d30c |
Hashes for pyreqwest_impersonate-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2487fc4588bf8e955662a6a2879e80195c35a850ebea55c8fd1f01dca86b94a7 |
|
MD5 | 4d4198e1088a4ccd6847d08f72e8b9b4 |
|
BLAKE2b-256 | 1188f3a828bd965734f9d21b54d77e3b1ad268c50de782725632270bb1eba82d |
Hashes for pyreqwest_impersonate-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82684308a20e5b08340dc1e1a9cf04f2c73720732daceb0921e52ea080b5e51e |
|
MD5 | c86e6beae3bc3cc410b1e445eb0e9c01 |
|
BLAKE2b-256 | 4cc4b683b5377d5fb7fb6abcce44428abcff611635f5ea8b74d01d341d5cb57b |
Hashes for pyreqwest_impersonate-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b10c4248ebad745d17741f5cccc7853cf66331c737826b72e5294ac474c2fb42 |
|
MD5 | b36f908307950e3a2f426b8e3d69df36 |
|
BLAKE2b-256 | c3604f58fae078b0bee900648c135515a415ba7b2617b9bc51ee19c3318afec6 |
Hashes for pyreqwest_impersonate-0.2.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 667255774919ee96c472764aedab5277b8c9525bcf9845a1ca169f607cae6b74 |
|
MD5 | 36c495c2a20a7dc379757942cd206bb2 |
|
BLAKE2b-256 | ceca49246648ec5fac41b23369c6392b8f8f1a153e8df7cc6d017cbff85b2ff5 |
Hashes for pyreqwest_impersonate-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80b16b0ba4b49aef413914ba72f1103688107ae75bae41b38e2353f04ca5cc10 |
|
MD5 | 199ccb9a0bb5e29e994ad3078c5a284f |
|
BLAKE2b-256 | 1f3d2d173184eb377d8a6ae60c7a131af13bea0587bfb0563fd2f2988ea80d70 |
Hashes for pyreqwest_impersonate-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03822581bfd8004af31309062727fdc7c78c0515a950b2851f71353100c6328b |
|
MD5 | e5b66396dc978955ddcd4598c43ec34c |
|
BLAKE2b-256 | aa47f43ae02dbf5e209e438c4bd15105fe64db346169251d0ad9d3cfc9f44f10 |
Hashes for pyreqwest_impersonate-0.2.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68be763d3e7d24c549c86fffb8d273d93c9bafdc3c1b04e17c64d37d8caa40d9 |
|
MD5 | 51b4641a37a60d05e025cb493aa70fc0 |
|
BLAKE2b-256 | 5d53d3ff24c77d608714a5a8567c71f6b90d6f9cdbfb7deed93d6b324c1e6517 |
Hashes for pyreqwest_impersonate-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34e40cb455dd7d210eaf668207cfddcb7104f95e949fafa3c8a19e0c10791551 |
|
MD5 | 0db82b9b32bf908acbb390d9c6ca2a1d |
|
BLAKE2b-256 | bcc7fe0d0d477e889a4b0ab6eaa38863c77f1e4fa06c58ca865acf7b8e3b00b8 |
Hashes for pyreqwest_impersonate-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aa4b30bad6f0a7460fc42c21860e76dd2c6afb1373aef72ab11cc9906817223 |
|
MD5 | 5c898893bb2cbf895608ced02a7313d6 |
|
BLAKE2b-256 | a91b0041b4b39308d6cfde7c7cbea07a01244bec891218f0ca5c71ec1a372e56 |