never-primp 1.0.0__cp38-abi3-win_amd64.whl → 1.0.2__cp38-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of never-primp might be problematic. Click here for more details.
- never_primp/__init__.py +151 -2
- never_primp/never_primp.pyd +0 -0
- never_primp/never_primp.pyi +181 -133
- never_primp-1.0.2.dist-info/METADATA +803 -0
- never_primp-1.0.2.dist-info/RECORD +8 -0
- never_primp-1.0.2.dist-info/licenses/LICENSE +21 -0
- never_primp-1.0.0.dist-info/METADATA +0 -338
- never_primp-1.0.0.dist-info/RECORD +0 -7
- {never_primp-1.0.0.dist-info → never_primp-1.0.2.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
never_primp-1.0.2.dist-info/METADATA,sha256=OypnoTJVQ-gguQjVpLBGpnoepNWIY92MhlCAOSXHJwE,22313
|
|
2
|
+
never_primp-1.0.2.dist-info/WHEEL,sha256=CG8OzNtm0LMpJ2zhrjswlO8N-965OeMLklsQAG-nMvQ,94
|
|
3
|
+
never_primp-1.0.2.dist-info/licenses/LICENSE,sha256=O15TIxUAXq6sSpPu0K3CJu_dT5ZzCgIk7hQtZsf0lEk,1084
|
|
4
|
+
never_primp/__init__.py,sha256=KIXkg0XwGRBw889rtgMMr_lVCpXABihqDu5eVjxp8wA,18209
|
|
5
|
+
never_primp/never_primp.pyd,sha256=s1pse_cZvns2ogDZLtWEcPsKgXIXOMAM7jjnGjUDIgY,7859712
|
|
6
|
+
never_primp/never_primp.pyi,sha256=f3GNfXXLG5mS32djn56NVztEmnH5oUl_jefPiArZlkI,8001
|
|
7
|
+
never_primp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
never_primp-1.0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 deedy5
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: never_primp
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: 基于原primp 重新优化调整的请求库
|
|
5
|
-
Author: Neverland
|
|
6
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
7
|
-
|
|
8
|
-
 [](https://github.com/deedy5/pyreqwest-impersonate/releases) [](https://pypi.org/project/primp) [](https://pepy.tech/project/primp) [](https://github.com/deedy5/pyreqwest-impersonate/actions/workflows/CI.yml)
|
|
9
|
-
# 🪞NEVER_PRIMP
|
|
10
|
-
**🪞NEVER_PRIMP** = **P**ython **R**equests **IMP**ersonate
|
|
11
|
-
|
|
12
|
-
The fastest python HTTP client that can impersonate web browsers.</br>
|
|
13
|
-
Provides precompiled wheels:</br>
|
|
14
|
-
* 🐧 linux: `amd64`, `aarch64`, `armv7` (⚠️aarch64 and armv7 builds are `manylinux_2_34` compatible - `ubuntu>=22.04`, `debian>=12`);</br>
|
|
15
|
-
* 🐧 musllinux: `amd64`, `aarch64`;</br>
|
|
16
|
-
* 🪟 windows: `amd64`;</br>
|
|
17
|
-
* 🍏 macos: `amd64`, `aarch64`.</br>
|
|
18
|
-
|
|
19
|
-
## Table of Contents
|
|
20
|
-
|
|
21
|
-
- [Installation](#installation)
|
|
22
|
-
- [Key Features](#key-features)
|
|
23
|
-
- [Benchmark](#benchmark)
|
|
24
|
-
- [Usage](#usage)
|
|
25
|
-
- [I. Client](#i-client)
|
|
26
|
-
- [Client methods](#client-methods)
|
|
27
|
-
- [Response object](#response-object)
|
|
28
|
-
- [Devices](#devices)
|
|
29
|
-
- [Examples](#examples)
|
|
30
|
-
- [II. AsyncClient](#ii-asyncclient)
|
|
31
|
-
- [Disclaimer](#disclaimer)
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
```python
|
|
36
|
-
pip install -U never_primp
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Key Features
|
|
40
|
-
|
|
41
|
-
🚀 **Performance Optimized**
|
|
42
|
-
- Connection pooling with configurable idle timeout and max connections per host
|
|
43
|
-
- TCP optimization (TCP_NODELAY, TCP keepalive)
|
|
44
|
-
- ~59% faster for sequential requests with connection reuse
|
|
45
|
-
|
|
46
|
-
🔒 **Advanced Certificate Management**
|
|
47
|
-
- Uses system's native certificate store (auto-updated with OS)
|
|
48
|
-
- No more certificate expiration issues
|
|
49
|
-
- Custom CA bundle support
|
|
50
|
-
|
|
51
|
-
🍪 **Smart Cookie Management**
|
|
52
|
-
- Automatic cookie persistence using wreq's native Jar API
|
|
53
|
-
- Manual cookie control with `get_cookies()` / `set_cookies()`
|
|
54
|
-
- Cookies survive client configuration changes
|
|
55
|
-
|
|
56
|
-
⚙️ **Dynamic Configuration**
|
|
57
|
-
- Modify headers, proxy, and impersonation at runtime
|
|
58
|
-
- No need to recreate the client
|
|
59
|
-
- Thread-safe configuration updates
|
|
60
|
-
|
|
61
|
-
🔄 **Retry Mechanism**
|
|
62
|
-
- Configurable retry count and backoff timing
|
|
63
|
-
- Handle transient failures gracefully
|
|
64
|
-
|
|
65
|
-
🎭 **Browser Impersonation**
|
|
66
|
-
- Impersonate Chrome, Safari, Edge, Firefox, OkHttp
|
|
67
|
-
- Mimic TLS/JA3/JA4/HTTP2 fingerprints
|
|
68
|
-
- Custom OS impersonation (Windows, macOS, Linux, Android, iOS)
|
|
69
|
-
|
|
70
|
-
## Usage
|
|
71
|
-
### I. Client
|
|
72
|
-
|
|
73
|
-
HTTP client that can impersonate web browsers.
|
|
74
|
-
```python
|
|
75
|
-
class Client:
|
|
76
|
-
"""Initializes an HTTP client that can impersonate web browsers.
|
|
77
|
-
|
|
78
|
-
Args:
|
|
79
|
-
auth (tuple[str, str| None] | None): Username and password for basic authentication. Default is None.
|
|
80
|
-
auth_bearer (str | None): Bearer token for authentication. Default is None.
|
|
81
|
-
params (dict[str, str] | None): Default query parameters to include in all requests. Default is None.
|
|
82
|
-
headers (dict[str, str] | None): Default headers to send with requests. If `impersonate` is set, this will be ignored.
|
|
83
|
-
timeout (float | None): HTTP request timeout in seconds. Default is 30.
|
|
84
|
-
cookie_store (bool | None): Enable a persistent cookie store. Received cookies will be preserved and included
|
|
85
|
-
in additional requests. Default is True.
|
|
86
|
-
referer (bool | None): Enable or disable automatic setting of the `Referer` header. Default is True.
|
|
87
|
-
proxy (str | None): Proxy URL for HTTP requests. Example: "socks5://127.0.0.1:9150". Default is None.
|
|
88
|
-
impersonate (str | None): Entity to impersonate. Example: "chrome_124". Default is None.
|
|
89
|
-
Chrome: "chrome_100","chrome_101","chrome_104","chrome_105","chrome_106","chrome_107","chrome_108",
|
|
90
|
-
"chrome_109","chrome_114","chrome_116","chrome_117","chrome_118","chrome_119","chrome_120",
|
|
91
|
-
"chrome_123","chrome_124","chrome_126","chrome_127","chrome_128","chrome_129","chrome_130",
|
|
92
|
-
"chrome_131","chrome_133"
|
|
93
|
-
Safari: "safari_ios_16.5","safari_ios_17.2","safari_ios_17.4.1","safari_ios_18.1.1",
|
|
94
|
-
"safari_15.3","safari_15.5","safari_15.6.1","safari_16","safari_16.5","safari_17.0",
|
|
95
|
-
"safari_17.2.1","safari_17.4.1","safari_17.5","safari_18","safari_18.2","safari_ipad_18"
|
|
96
|
-
OkHttp: "okhttp_3.9","okhttp_3.11","okhttp_3.13","okhttp_3.14","okhttp_4.9","okhttp_4.10","okhttp_5"
|
|
97
|
-
Edge: "edge_101","edge_122","edge_127","edge_131"
|
|
98
|
-
Firefox: "firefox_109","firefox_117","firefox_128","firefox_133","firefox_135"
|
|
99
|
-
Select random: "random"
|
|
100
|
-
impersonate_os (str | None): impersonate OS. Example: "windows". Default is "linux".
|
|
101
|
-
Android: "android", iOS: "ios", Linux: "linux", Mac OS: "macos", Windows: "windows"
|
|
102
|
-
Select random: "random"
|
|
103
|
-
follow_redirects (bool | None): Whether to follow redirects. Default is True.
|
|
104
|
-
max_redirects (int | None): Maximum redirects to follow. Default 20. Applies if `follow_redirects` is True.
|
|
105
|
-
verify (bool | None): Verify SSL certificates. Default is True.
|
|
106
|
-
ca_cert_file (str | None): Path to CA certificate store. Default is None.
|
|
107
|
-
https_only (bool | None): Restrict the Client to be used with HTTPS only requests. Default is False.
|
|
108
|
-
http2_only (bool | None): If true - use only HTTP/2; if false - use only HTTP/1. Default is False.
|
|
109
|
-
pool_idle_timeout (float | None): Connection pool idle timeout in seconds. Default is None.
|
|
110
|
-
pool_max_idle_per_host (int | None): Maximum number of idle connections per host. Default is None.
|
|
111
|
-
tcp_nodelay (bool | None): Enable TCP_NODELAY (disable Nagle's algorithm). Default is None.
|
|
112
|
-
tcp_keepalive (float | None): TCP keepalive interval in seconds. Default is None.
|
|
113
|
-
retry_count (int | None): Maximum number of retry attempts. Default is None.
|
|
114
|
-
retry_backoff (float | None): Backoff time between retries in seconds. Default is None.
|
|
115
|
-
|
|
116
|
-
"""
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
#### Client methods
|
|
120
|
-
|
|
121
|
-
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`.
|
|
122
|
-
```python
|
|
123
|
-
def get(
|
|
124
|
-
url: str,
|
|
125
|
-
params: dict[str, str] | None = None,
|
|
126
|
-
headers: dict[str, str] | None = None,
|
|
127
|
-
cookies: dict[str, str] | None = None,
|
|
128
|
-
auth: tuple[str, str| None] | None = None,
|
|
129
|
-
auth_bearer: str | None = None,
|
|
130
|
-
timeout: float | None = 30,
|
|
131
|
-
):
|
|
132
|
-
"""Performs a GET request to the specified URL.
|
|
133
|
-
|
|
134
|
-
Args:
|
|
135
|
-
url (str): The URL to which the request will be made.
|
|
136
|
-
params (dict[str, str] | None): A map of query parameters to append to the URL. Default is None.
|
|
137
|
-
headers (dict[str, str] | None): A map of HTTP headers to send with the request. Default is None.
|
|
138
|
-
cookies (dict[str, str] | None): - An optional map of cookies to send with requests as the `Cookie` header.
|
|
139
|
-
auth (tuple[str, str| None] | None): A tuple containing the username and an optional password
|
|
140
|
-
for basic authentication. Default is None.
|
|
141
|
-
auth_bearer (str | None): A string representing the bearer token for bearer token authentication. Default is None.
|
|
142
|
-
timeout (float | None): The timeout for the request in seconds. Default is 30.
|
|
143
|
-
|
|
144
|
-
"""
|
|
145
|
-
```
|
|
146
|
-
```python
|
|
147
|
-
def post(
|
|
148
|
-
url: str,
|
|
149
|
-
params: dict[str, str] | None = None,
|
|
150
|
-
headers: dict[str, str] | None = None,
|
|
151
|
-
cookies: dict[str, str] | None = None,
|
|
152
|
-
content: bytes | None = None,
|
|
153
|
-
data: dict[str, Any] | None = None,
|
|
154
|
-
json: Any | None = None,
|
|
155
|
-
files: dict[str, str] | None = None,
|
|
156
|
-
auth: tuple[str, str| None] | None = None,
|
|
157
|
-
auth_bearer: str | None = None,
|
|
158
|
-
timeout: float | None = 30,
|
|
159
|
-
):
|
|
160
|
-
"""Performs a POST request to the specified URL.
|
|
161
|
-
|
|
162
|
-
Args:
|
|
163
|
-
url (str): The URL to which the request will be made.
|
|
164
|
-
params (dict[str, str] | None): A map of query parameters to append to the URL. Default is None.
|
|
165
|
-
headers (dict[str, str] | None): A map of HTTP headers to send with the request. Default is None.
|
|
166
|
-
cookies (dict[str, str] | None): - An optional map of cookies to send with requests as the `Cookie` header.
|
|
167
|
-
content (bytes | None): The content to send in the request body as bytes. Default is None.
|
|
168
|
-
data (dict[str, Any] | None): The form data to send in the request body. Default is None.
|
|
169
|
-
json (Any | None): A JSON serializable object to send in the request body. Default is None.
|
|
170
|
-
files (dict[str, str] | None): A map of file fields to file paths to be sent as multipart/form-data. Default is None.
|
|
171
|
-
auth (tuple[str, str| None] | None): A tuple containing the username and an optional password
|
|
172
|
-
for basic authentication. Default is None.
|
|
173
|
-
auth_bearer (str | None): A string representing the bearer token for bearer token authentication. Default is None.
|
|
174
|
-
timeout (float | None): The timeout for the request in seconds. Default is 30.
|
|
175
|
-
|
|
176
|
-
"""
|
|
177
|
-
```
|
|
178
|
-
#### Response object
|
|
179
|
-
```python
|
|
180
|
-
resp.content
|
|
181
|
-
resp.stream() # stream the response body in chunks of bytes
|
|
182
|
-
resp.cookies
|
|
183
|
-
resp.encoding
|
|
184
|
-
resp.headers
|
|
185
|
-
resp.json()
|
|
186
|
-
resp.status_code
|
|
187
|
-
resp.text
|
|
188
|
-
resp.text_markdown # html is converted to markdown text
|
|
189
|
-
resp.text_plain # html is converted to plain text
|
|
190
|
-
resp.text_rich # html is converted to rich text
|
|
191
|
-
resp.url
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
#### Devices
|
|
195
|
-
|
|
196
|
-
##### Impersonate
|
|
197
|
-
|
|
198
|
-
- Chrome: `chrome_100`,`chrome_101`,`chrome_104`,`chrome_105`,`chrome_106`,`chrome_107`,`chrome_108`,`chrome_109`,`chrome_114`,`chrome_116`,`chrome_117`,`chrome_118`,`chrome_119`,`chrome_120`,`chrome_123`,`chrome_124`,`chrome_126`,`chrome_127`,`chrome_128`,`chrome_129`,`chrome_130`,`chrome_131`, `chrome_133`, `chrome_134`, `chrome_135`, `chrome_136`, `chrome_137`, `chrome_138`, `chrome_139`, `chrome_140`, `chrome_141`
|
|
199
|
-
|
|
200
|
-
- Edge: `edge_101`,`edge_122`,`edge_127`, `edge_131`, `edge_134`
|
|
201
|
-
|
|
202
|
-
- Safari: `safari_ios_17.2`,`safari_ios_17.4.1`,`safari_ios_16.5`,`safari_ios_18.1.1`, `safari_15.3`,`safari_15.5`,`safari_15.6.1`,`safari_16`,`safari_16.5`,`safari_17.0`,`safari_17.2.1`,`safari_17.4.1`,`safari_17.5`,`safari_18`,`safari_18.2`, `safari_ipad_18`, `safari_ipad_26`, `safari_ios_26`, `safari_26`
|
|
203
|
-
|
|
204
|
-
- OkHttp: `okhttp_3.9`,`okhttp_3.11`,`okhttp_3.13`,`okhttp_3.14`,`okhttp_4.9`,`okhttp_4.10`,`okhttp_5`
|
|
205
|
-
|
|
206
|
-
- Firefox: `firefox_109`, `firefox_117`, `firefox_128`, `firefox_133`, `firefox_135`, `firefox_136`, `firefox_139`, `firefox_142`, `firefox_143`
|
|
207
|
-
|
|
208
|
-
##### Impersonate OS
|
|
209
|
-
|
|
210
|
-
- `android`, `ios`, `linux`, `macos`, `windows`
|
|
211
|
-
|
|
212
|
-
#### Examples
|
|
213
|
-
|
|
214
|
-
```python
|
|
215
|
-
import never_primp as primp
|
|
216
|
-
|
|
217
|
-
# Impersonate
|
|
218
|
-
client = primp.Client(impersonate="chrome_131", impersonate_os="windows")
|
|
219
|
-
|
|
220
|
-
# Performance optimization with connection pooling
|
|
221
|
-
client = primp.Client(
|
|
222
|
-
impersonate="chrome_131",
|
|
223
|
-
pool_idle_timeout=90.0, # Keep connections alive for 90 seconds
|
|
224
|
-
pool_max_idle_per_host=10, # Max 10 idle connections per host
|
|
225
|
-
tcp_nodelay=True, # Disable Nagle's algorithm for lower latency
|
|
226
|
-
tcp_keepalive=60.0, # TCP keepalive every 60 seconds
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
# Retry mechanism
|
|
230
|
-
client = primp.Client(
|
|
231
|
-
retry_count=3, # Retry up to 3 times
|
|
232
|
-
retry_backoff=1.0, # 1 second backoff between retries
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
# Dynamic configuration updates
|
|
236
|
-
client.headers = {"User-Agent": "Custom User Agent"} # Update all headers
|
|
237
|
-
client.headers_update({"Referer": "https://example.com"}) # Merge new headers
|
|
238
|
-
client.proxy = "http://127.0.0.1:8080" # Change proxy
|
|
239
|
-
client.impersonate = "chrome_133" # Change browser impersonation
|
|
240
|
-
client.impersonate_os = "macos" # Change OS impersonation
|
|
241
|
-
|
|
242
|
-
# GET request
|
|
243
|
-
resp = client.get("https://tls.peet.ws/api/all")
|
|
244
|
-
|
|
245
|
-
# GET request with passing params and setting timeout
|
|
246
|
-
params = {"param1": "value1", "param2": "value2"}
|
|
247
|
-
resp = client.post(url="https://httpbin.org/anything", params=params, timeout=10)
|
|
248
|
-
|
|
249
|
-
# Stream response
|
|
250
|
-
resp = client.get("https://nytimes")
|
|
251
|
-
for chunk in resp.stream():
|
|
252
|
-
print(chunk)
|
|
253
|
-
|
|
254
|
-
# Cookie management - Automatic (recommended)
|
|
255
|
-
client = primp.Client(cookie_store=True) # Default: enabled
|
|
256
|
-
resp = client.get("https://httpbin.org/cookies/set?session=abc123")
|
|
257
|
-
# Cookies are automatically stored and sent in subsequent requests
|
|
258
|
-
resp2 = client.get("https://httpbin.org/cookies") # Session cookie automatically included
|
|
259
|
-
|
|
260
|
-
# Cookie management - Manual
|
|
261
|
-
cookies = {"c1_n": "c1_value", "c2_n": "c2_value"}
|
|
262
|
-
client.set_cookies(url="https://nytimes.com", cookies=cookies) # Set cookies for a specific domain
|
|
263
|
-
resp = client.get("https://nytimes.com/", cookies=cookies) # Or pass cookies in request
|
|
264
|
-
|
|
265
|
-
# Get cookies
|
|
266
|
-
all_cookies = client.get_cookies(url="https://nytimes.com") # Get all cookies from jar
|
|
267
|
-
response_cookies = resp.cookies # Get cookies from response
|
|
268
|
-
|
|
269
|
-
# POST Binary Request Data
|
|
270
|
-
content = b"some_data"
|
|
271
|
-
resp = client.post(url="https://httpbin.org/anything", content=content)
|
|
272
|
-
|
|
273
|
-
# POST Form Encoded Data
|
|
274
|
-
data = {"key1": "value1", "key2": "value2"}
|
|
275
|
-
resp = client.post(url="https://httpbin.org/anything", data=data)
|
|
276
|
-
|
|
277
|
-
# POST JSON Encoded Data
|
|
278
|
-
json = {"key1": "value1", "key2": "value2"}
|
|
279
|
-
resp = client.post(url="https://httpbin.org/anything", json=json)
|
|
280
|
-
|
|
281
|
-
# POST Multipart-Encoded Files
|
|
282
|
-
files = {'file1': '/home/root/file1.txt', 'file2': 'home/root/file2.txt'}
|
|
283
|
-
resp = client.post("https://httpbin.org/post", files=files)
|
|
284
|
-
|
|
285
|
-
# Authentication using user/password
|
|
286
|
-
resp = client.post(url="https://httpbin.org/anything", auth=("user", "password"))
|
|
287
|
-
|
|
288
|
-
# Authentication using auth bearer
|
|
289
|
-
resp = client.post(url="https://httpbin.org/anything", auth_bearer="bearerXXXXXXXXXXXXXXXXXXXX")
|
|
290
|
-
|
|
291
|
-
# Using proxy or env var PRIMP_PROXY
|
|
292
|
-
resp = primp.Client(proxy="http://127.0.0.1:8080") # set proxy in Client
|
|
293
|
-
export PRIMP_PROXY="socks5://127.0.0.1:1080" # set proxy as environment variable
|
|
294
|
-
|
|
295
|
-
# SSL/TLS certificate verification
|
|
296
|
-
# Note: Primp uses your system's native certificate store by default (auto-updated with OS)
|
|
297
|
-
resp = primp.Client(verify=True) # Default: uses system certificates
|
|
298
|
-
|
|
299
|
-
# Using custom CA certificate store:
|
|
300
|
-
resp = primp.Client(ca_cert_file="/cert/cacert.pem")
|
|
301
|
-
resp = primp.Client(ca_cert_file=certifi.where())
|
|
302
|
-
export PRIMP_CA_BUNDLE="/home/user/Downloads/cert.pem" # set as environment variable
|
|
303
|
-
|
|
304
|
-
# You can also use convenience functions that use a default Client instance under the hood:
|
|
305
|
-
# primp.get() | primp.head() | primp.options() | primp.delete() | primp.post() | primp.patch() | primp.put()
|
|
306
|
-
# These functions can accept the `impersonate` parameter:
|
|
307
|
-
resp = primp.get("https://httpbin.org/anything", impersonate="chrome_131", impersonate_os="android")
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### II. AsyncClient
|
|
311
|
-
|
|
312
|
-
`primp.AsyncClient()` is an asynchronous wrapper around the `primp.Client` class, offering the same functions, behavior, and input arguments.
|
|
313
|
-
|
|
314
|
-
```python3
|
|
315
|
-
import asyncio
|
|
316
|
-
import logging
|
|
317
|
-
|
|
318
|
-
import never_primp as primp
|
|
319
|
-
|
|
320
|
-
async def aget_text(url):
|
|
321
|
-
async with primp.AsyncClient(impersonate="chrome_131") as client:
|
|
322
|
-
resp = await client.get(url)
|
|
323
|
-
return resp.text
|
|
324
|
-
|
|
325
|
-
async def main():
|
|
326
|
-
urls = ["https://nytimes.com/", "https://cnn.com/", "https://abcnews.go.com/"]
|
|
327
|
-
tasks = [aget_text(u) for u in urls]
|
|
328
|
-
results = await asyncio.gather(*tasks)
|
|
329
|
-
|
|
330
|
-
if __name__ == "__main__":
|
|
331
|
-
logging.basicConfig(level=logging.INFO)
|
|
332
|
-
asyncio.run(main())
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
## Disclaimer
|
|
336
|
-
|
|
337
|
-
This tool is for educational purposes only. Use it at your own risk.
|
|
338
|
-
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
never_primp-1.0.0.dist-info/METADATA,sha256=Cuiw8t_orxEPdw7hBh3bO5WN6uCZoeuKsgOwpJhHaUw,15657
|
|
2
|
-
never_primp-1.0.0.dist-info/WHEEL,sha256=CG8OzNtm0LMpJ2zhrjswlO8N-965OeMLklsQAG-nMvQ,94
|
|
3
|
-
never_primp/__init__.py,sha256=Y6Bs079kVXF4HWG2ZpmatSAirlcPCFZ4P0FyGG9ZvLo,12810
|
|
4
|
-
never_primp/never_primp.pyd,sha256=2bWHiIOmBgitjbGsgXNAq1YbBtPv8MSJFxzPvvKYETg,6435328
|
|
5
|
-
never_primp/never_primp.pyi,sha256=8QRuXaqNfk29qkFZrbtwKKK92Y_wL-O702nys8DCcM0,5731
|
|
6
|
-
never_primp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
never_primp-1.0.0.dist-info/RECORD,,
|
|
File without changes
|