rnet 2.4.2__cp313-cp313t-manylinux_2_34_i686.whl → 3.0.0rc10__cp313-cp313t-manylinux_2_34_i686.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 rnet might be problematic. Click here for more details.
- rnet/__init__.py +11 -3
- rnet/__init__.pyi +1044 -799
- rnet/blocking.py +434 -1
- rnet/cookie.py +141 -1
- rnet/emulation.py +199 -0
- rnet/exceptions.py +224 -1
- rnet/header.py +319 -1
- rnet/http1.py +68 -0
- rnet/http2.py +361 -0
- rnet/rnet.cpython-313t-i386-linux-gnu.so +0 -0
- rnet/tls.py +428 -0
- rnet-3.0.0rc10.dist-info/METADATA +205 -0
- rnet-3.0.0rc10.dist-info/RECORD +16 -0
- {rnet-2.4.2.dist-info → rnet-3.0.0rc10.dist-info}/WHEEL +1 -1
- rnet-3.0.0rc10.dist-info/licenses/LICENSE +201 -0
- rnet/blocking.pyi +0 -616
- rnet/cookie.pyi +0 -76
- rnet/exceptions.pyi +0 -64
- rnet/header.pyi +0 -103
- rnet/impersonate.py +0 -1
- rnet/impersonate.pyi +0 -147
- rnet-2.4.2.dist-info/METADATA +0 -186
- rnet-2.4.2.dist-info/RECORD +0 -18
- rnet-2.4.2.dist-info/licenses/LICENSE +0 -674
rnet/emulation.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides functionality for emulating various browsers and HTTP clients
|
|
3
|
+
to bypass detection and fingerprinting. It supports emulating Chrome, Firefox, Edge,
|
|
4
|
+
Safari, Opera, and OkHttp clients across different operating systems and versions.
|
|
5
|
+
|
|
6
|
+
The emulation system modifies HTTP/2 settings, TLS fingerprints, and request headers
|
|
7
|
+
to match the behavior of real browsers and clients, making requests appear more
|
|
8
|
+
authentic and less likely to be blocked by anti-bot systems.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from enum import Enum, auto
|
|
12
|
+
from typing import final
|
|
13
|
+
|
|
14
|
+
__all__ = ["Emulation", "EmulationOS", "EmulationOption"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@final
|
|
18
|
+
class Emulation(Enum):
|
|
19
|
+
r"""
|
|
20
|
+
An emulation.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# Chrome versions
|
|
24
|
+
Chrome100 = auto()
|
|
25
|
+
Chrome101 = auto()
|
|
26
|
+
Chrome104 = auto()
|
|
27
|
+
Chrome105 = auto()
|
|
28
|
+
Chrome106 = auto()
|
|
29
|
+
Chrome107 = auto()
|
|
30
|
+
Chrome108 = auto()
|
|
31
|
+
Chrome109 = auto()
|
|
32
|
+
Chrome110 = auto()
|
|
33
|
+
Chrome114 = auto()
|
|
34
|
+
Chrome116 = auto()
|
|
35
|
+
Chrome117 = auto()
|
|
36
|
+
Chrome118 = auto()
|
|
37
|
+
Chrome119 = auto()
|
|
38
|
+
Chrome120 = auto()
|
|
39
|
+
Chrome123 = auto()
|
|
40
|
+
Chrome124 = auto()
|
|
41
|
+
Chrome126 = auto()
|
|
42
|
+
Chrome127 = auto()
|
|
43
|
+
Chrome128 = auto()
|
|
44
|
+
Chrome129 = auto()
|
|
45
|
+
Chrome130 = auto()
|
|
46
|
+
Chrome131 = auto()
|
|
47
|
+
Chrome132 = auto()
|
|
48
|
+
Chrome133 = auto()
|
|
49
|
+
Chrome134 = auto()
|
|
50
|
+
Chrome135 = auto()
|
|
51
|
+
Chrome136 = auto()
|
|
52
|
+
Chrome137 = auto()
|
|
53
|
+
Chrome138 = auto()
|
|
54
|
+
Chrome139 = auto()
|
|
55
|
+
Chrome140 = auto()
|
|
56
|
+
Chrome141 = auto()
|
|
57
|
+
|
|
58
|
+
# Microsoft Edge versions
|
|
59
|
+
Edge101 = auto()
|
|
60
|
+
Edge122 = auto()
|
|
61
|
+
Edge127 = auto()
|
|
62
|
+
Edge131 = auto()
|
|
63
|
+
Edge134 = auto()
|
|
64
|
+
|
|
65
|
+
# Firefox versions
|
|
66
|
+
Firefox109 = auto()
|
|
67
|
+
Firefox117 = auto()
|
|
68
|
+
Firefox128 = auto()
|
|
69
|
+
Firefox133 = auto()
|
|
70
|
+
Firefox135 = auto()
|
|
71
|
+
FirefoxPrivate135 = auto()
|
|
72
|
+
FirefoxAndroid135 = auto()
|
|
73
|
+
Firefox136 = auto()
|
|
74
|
+
FirefoxPrivate136 = auto()
|
|
75
|
+
Firefox139 = auto()
|
|
76
|
+
Firefox142 = auto()
|
|
77
|
+
Firefox143 = auto()
|
|
78
|
+
|
|
79
|
+
# Safari versions
|
|
80
|
+
SafariIos17_2 = auto()
|
|
81
|
+
SafariIos17_4_1 = auto()
|
|
82
|
+
SafariIos16_5 = auto()
|
|
83
|
+
Safari15_3 = auto()
|
|
84
|
+
Safari15_5 = auto()
|
|
85
|
+
Safari15_6_1 = auto()
|
|
86
|
+
Safari16 = auto()
|
|
87
|
+
Safari16_5 = auto()
|
|
88
|
+
Safari17_0 = auto()
|
|
89
|
+
Safari17_2_1 = auto()
|
|
90
|
+
Safari17_4_1 = auto()
|
|
91
|
+
Safari17_5 = auto()
|
|
92
|
+
Safari18 = auto()
|
|
93
|
+
SafariIPad18 = auto()
|
|
94
|
+
Safari18_2 = auto()
|
|
95
|
+
Safari18_3 = auto()
|
|
96
|
+
Safari18_3_1 = auto()
|
|
97
|
+
SafariIos18_1_1 = auto()
|
|
98
|
+
Safari18_5 = auto()
|
|
99
|
+
Safari26 = auto()
|
|
100
|
+
SafariIos26 = auto()
|
|
101
|
+
SafariIPad26 = auto()
|
|
102
|
+
|
|
103
|
+
# OkHttp versions
|
|
104
|
+
OkHttp3_9 = auto()
|
|
105
|
+
OkHttp3_11 = auto()
|
|
106
|
+
OkHttp3_13 = auto()
|
|
107
|
+
OkHttp3_14 = auto()
|
|
108
|
+
OkHttp4_9 = auto()
|
|
109
|
+
OkHttp4_10 = auto()
|
|
110
|
+
OkHttp4_12 = auto()
|
|
111
|
+
OkHttp5 = auto()
|
|
112
|
+
|
|
113
|
+
# Opera versions
|
|
114
|
+
Opera116 = auto()
|
|
115
|
+
Opera117 = auto()
|
|
116
|
+
Opera118 = auto()
|
|
117
|
+
Opera119 = auto()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@final
|
|
121
|
+
class EmulationOS(Enum):
|
|
122
|
+
"""
|
|
123
|
+
Operating systems that can be emulated.
|
|
124
|
+
|
|
125
|
+
This enum defines the operating systems that can be combined with
|
|
126
|
+
browser emulations to create more specific fingerprints.
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
Windows = auto() # Windows (any version)
|
|
130
|
+
MacOS = auto() # macOS (any version)
|
|
131
|
+
Linux = auto() # Linux (any distribution)
|
|
132
|
+
Android = auto() # Android (mobile)
|
|
133
|
+
IOS = auto() # iOS (iPhone/iPad)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@final
|
|
137
|
+
class EmulationOption:
|
|
138
|
+
"""
|
|
139
|
+
Configuration options for browser and client emulation.
|
|
140
|
+
|
|
141
|
+
This class allows fine-grained control over emulation behavior,
|
|
142
|
+
including the ability to disable specific features or combine
|
|
143
|
+
browser types with specific operating systems.
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
def __init__(
|
|
147
|
+
self,
|
|
148
|
+
emulation: Emulation,
|
|
149
|
+
emulation_os: EmulationOS | None = None,
|
|
150
|
+
skip_http2: bool | None = None,
|
|
151
|
+
skip_headers: bool | None = None,
|
|
152
|
+
) -> None:
|
|
153
|
+
"""
|
|
154
|
+
Create a new emulation configuration.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
emulation: The browser/client type to emulate
|
|
158
|
+
emulation_os: The operating system to emulate (optional)
|
|
159
|
+
skip_http2: Whether to disable HTTP/2 emulation (default: False)
|
|
160
|
+
skip_headers: Whether to skip default browser headers (default: False)
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
A configured EmulationOption instance
|
|
164
|
+
|
|
165
|
+
Example:
|
|
166
|
+
```python
|
|
167
|
+
# Basic Chrome emulation
|
|
168
|
+
option = EmulationOption(Emulation.Chrome137)
|
|
169
|
+
|
|
170
|
+
# Chrome on Windows with HTTP/2 disabled
|
|
171
|
+
option = EmulationOption(
|
|
172
|
+
emulation=Emulation.Chrome137,
|
|
173
|
+
emulation_os=EmulationOS.Windows,
|
|
174
|
+
skip_http2=True
|
|
175
|
+
)
|
|
176
|
+
```
|
|
177
|
+
"""
|
|
178
|
+
...
|
|
179
|
+
|
|
180
|
+
@staticmethod
|
|
181
|
+
def random() -> "EmulationOption":
|
|
182
|
+
"""
|
|
183
|
+
Generate a random emulation configuration.
|
|
184
|
+
|
|
185
|
+
This method creates a randomized emulation setup using a random
|
|
186
|
+
browser/client type and operating system combination. Useful for
|
|
187
|
+
scenarios where you want to vary your fingerprint across requests.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
A randomly configured EmulationOption instance
|
|
191
|
+
|
|
192
|
+
Example:
|
|
193
|
+
```python
|
|
194
|
+
# Use different random emulation for each client
|
|
195
|
+
client1 = rnet.Client(emulation=EmulationOption.random())
|
|
196
|
+
client2 = rnet.Client(emulation=EmulationOption.random())
|
|
197
|
+
```
|
|
198
|
+
"""
|
|
199
|
+
...
|
rnet/exceptions.py
CHANGED
|
@@ -1 +1,224 @@
|
|
|
1
|
-
|
|
1
|
+
"""
|
|
2
|
+
HTTP Client Exceptions
|
|
3
|
+
|
|
4
|
+
This module defines all exceptions that can be raised by the rnet HTTP client.
|
|
5
|
+
The exceptions are organized into logical categories based on their cause and
|
|
6
|
+
severity, making it easier to handle specific types of errors appropriately.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"DNSResolverError",
|
|
11
|
+
"TlsError",
|
|
12
|
+
"ConnectionError",
|
|
13
|
+
"ConnectionResetError",
|
|
14
|
+
"BodyError",
|
|
15
|
+
"BuilderError",
|
|
16
|
+
"DecodingError",
|
|
17
|
+
"StatusError",
|
|
18
|
+
"RequestError",
|
|
19
|
+
"RedirectError",
|
|
20
|
+
"UpgradeError",
|
|
21
|
+
"WebSocketError",
|
|
22
|
+
"URLParseError",
|
|
23
|
+
"TimeoutError",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
# ========================================
|
|
27
|
+
# Network and System-Level Errors
|
|
28
|
+
# ========================================
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class RustPanic(Exception):
|
|
32
|
+
r"""
|
|
33
|
+
A panic occurred in the underlying Rust code.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class DNSResolverError(RuntimeError):
|
|
38
|
+
r"""
|
|
39
|
+
An error occurred while resolving a DNS name.
|
|
40
|
+
|
|
41
|
+
This exception is raised when the DNS resolver fails to resolve
|
|
42
|
+
a hostname to an IP address. This is typically due to network
|
|
43
|
+
issues, invalid hostnames, or DNS server problems.
|
|
44
|
+
|
|
45
|
+
Since this is a system-level issue that usually cannot be resolved
|
|
46
|
+
by retrying the request, it inherits from RuntimeError.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class TlsError(Exception):
|
|
51
|
+
r"""
|
|
52
|
+
An error occurred in the TLS security layer.
|
|
53
|
+
|
|
54
|
+
This exception covers TLS/SSL related issues such as:
|
|
55
|
+
- Certificate verification failures
|
|
56
|
+
- TLS handshake failures
|
|
57
|
+
- Protocol version mismatches
|
|
58
|
+
- Cipher suite negotiations
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ConnectionError(Exception):
|
|
63
|
+
r"""
|
|
64
|
+
An error occurred while establishing a connection.
|
|
65
|
+
|
|
66
|
+
This exception is raised when the client cannot establish a
|
|
67
|
+
TCP connection to the remote server. Common causes include:
|
|
68
|
+
- Server is unreachable
|
|
69
|
+
- Port is closed or blocked
|
|
70
|
+
- Network connectivity issues
|
|
71
|
+
- Firewall blocking the connection
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ConnectionResetError(Exception):
|
|
76
|
+
r"""
|
|
77
|
+
The connection was reset by the remote peer.
|
|
78
|
+
|
|
79
|
+
This exception occurs when an established connection is
|
|
80
|
+
unexpectedly closed by the remote server. This can happen
|
|
81
|
+
due to server overload, network issues, or server-side
|
|
82
|
+
connection limits.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# ========================================
|
|
87
|
+
# Request/Response Processing Errors
|
|
88
|
+
# ========================================
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class BodyError(Exception):
|
|
92
|
+
r"""
|
|
93
|
+
An error occurred while processing the body of a request or response.
|
|
94
|
+
|
|
95
|
+
This exception covers issues with reading, writing, or processing
|
|
96
|
+
HTTP message bodies, including:
|
|
97
|
+
- Invalid content encoding
|
|
98
|
+
- Incomplete body data
|
|
99
|
+
- Body size limit exceeded
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class BuilderError(Exception):
|
|
104
|
+
r"""
|
|
105
|
+
An error occurred while building a request or response.
|
|
106
|
+
|
|
107
|
+
This exception is raised when there are issues constructing
|
|
108
|
+
HTTP requests or responses, such as:
|
|
109
|
+
- Invalid header combinations
|
|
110
|
+
- Malformed request parameters
|
|
111
|
+
- Configuration conflicts
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class DecodingError(Exception):
|
|
116
|
+
r"""
|
|
117
|
+
An error occurred while decoding a response.
|
|
118
|
+
|
|
119
|
+
This exception covers failures in decoding response content,
|
|
120
|
+
including:
|
|
121
|
+
- Character encoding issues (UTF-8, Latin-1, etc.)
|
|
122
|
+
- Compression decompression failures (gzip, deflate, etc.)
|
|
123
|
+
- Content format parsing errors
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class StatusError(Exception):
|
|
128
|
+
r"""
|
|
129
|
+
An error occurred while processing the status code of a response.
|
|
130
|
+
|
|
131
|
+
This exception is typically raised for HTTP error status codes
|
|
132
|
+
(4xx, 5xx) when automatic error handling is enabled, or when
|
|
133
|
+
there are issues interpreting the status line.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class RequestError(Exception):
|
|
138
|
+
r"""
|
|
139
|
+
An error occurred while making a request.
|
|
140
|
+
|
|
141
|
+
This is a general exception for request-related issues that
|
|
142
|
+
don't fit into more specific categories. It covers various
|
|
143
|
+
problems during the request lifecycle.
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# ========================================
|
|
148
|
+
# HTTP Protocol and Navigation Errors
|
|
149
|
+
# ========================================
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class RedirectError(Exception):
|
|
153
|
+
r"""
|
|
154
|
+
An error occurred while following a redirect.
|
|
155
|
+
|
|
156
|
+
This exception is raised when there are issues with HTTP
|
|
157
|
+
redirects, such as:
|
|
158
|
+
- Too many redirects (redirect loop)
|
|
159
|
+
- Invalid redirect location
|
|
160
|
+
- Cross-protocol redirects when not allowed
|
|
161
|
+
- Redirect limit exceeded
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class UpgradeError(Exception):
|
|
166
|
+
r"""
|
|
167
|
+
An error occurred while upgrading a connection.
|
|
168
|
+
|
|
169
|
+
This exception covers failures when upgrading HTTP connections
|
|
170
|
+
to other protocols, such as:
|
|
171
|
+
- WebSocket upgrade failures
|
|
172
|
+
- HTTP/2 upgrade issues
|
|
173
|
+
- Protocol negotiation errors
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class WebSocketError(Exception):
|
|
178
|
+
r"""
|
|
179
|
+
An error occurred while handling a WebSocket connection.
|
|
180
|
+
|
|
181
|
+
This exception covers WebSocket-specific issues including:
|
|
182
|
+
- WebSocket handshake failures
|
|
183
|
+
- Frame parsing errors
|
|
184
|
+
- Connection state violations
|
|
185
|
+
- Message sending/receiving errors
|
|
186
|
+
"""
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# ========================================
|
|
190
|
+
# Parsing and Validation Errors
|
|
191
|
+
# ========================================
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class URLParseError(Exception):
|
|
195
|
+
r"""
|
|
196
|
+
An error occurred while parsing a URL.
|
|
197
|
+
|
|
198
|
+
This exception is raised when a provided URL cannot be parsed
|
|
199
|
+
or is malformed. Common issues include:
|
|
200
|
+
- Invalid URL schemes
|
|
201
|
+
- Malformed hostnames or ports
|
|
202
|
+
- Invalid characters in URL components
|
|
203
|
+
- Missing required URL components
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
# ========================================
|
|
208
|
+
# Timeout Errors
|
|
209
|
+
# ========================================
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class TimeoutError(Exception):
|
|
213
|
+
r"""
|
|
214
|
+
A timeout occurred while waiting for a response.
|
|
215
|
+
|
|
216
|
+
This exception is raised when operations exceed their configured
|
|
217
|
+
time limits, including:
|
|
218
|
+
- Connection timeout (time to establish connection)
|
|
219
|
+
- Read timeout (time to receive response)
|
|
220
|
+
- Total request timeout (entire request lifecycle)
|
|
221
|
+
|
|
222
|
+
Timeouts can often be resolved by increasing timeout values
|
|
223
|
+
or retrying the request.
|
|
224
|
+
"""
|