hyperbrowser 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.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 hyperbrowser might be problematic. Click here for more details.
- hyperbrowser/client/async_client.py +6 -2
- hyperbrowser/client/sync.py +6 -2
- hyperbrowser/models/consts.py +481 -0
- hyperbrowser/models/session.py +41 -0
- hyperbrowser/transport/async_transport.py +2 -2
- hyperbrowser/transport/sync.py +2 -2
- {hyperbrowser-0.3.0.dist-info → hyperbrowser-0.4.0.dist-info}/METADATA +8 -6
- hyperbrowser-0.4.0.dist-info/RECORD +16 -0
- hyperbrowser-0.3.0.dist-info/RECORD +0 -15
- {hyperbrowser-0.3.0.dist-info → hyperbrowser-0.4.0.dist-info}/LICENSE +0 -0
- {hyperbrowser-0.3.0.dist-info → hyperbrowser-0.4.0.dist-info}/WHEEL +0 -0
|
@@ -3,6 +3,7 @@ from ..transport.async_transport import AsyncTransport
|
|
|
3
3
|
from .base import HyperbrowserBase
|
|
4
4
|
from ..models.session import (
|
|
5
5
|
BasicResponse,
|
|
6
|
+
CreateSessionParams,
|
|
6
7
|
SessionDetail,
|
|
7
8
|
SessionListParams,
|
|
8
9
|
SessionListResponse,
|
|
@@ -21,8 +22,11 @@ class AsyncHyperbrowser(HyperbrowserBase):
|
|
|
21
22
|
):
|
|
22
23
|
super().__init__(AsyncTransport, config, api_key, base_url)
|
|
23
24
|
|
|
24
|
-
async def create_session(self) -> SessionDetail:
|
|
25
|
-
response = await self.transport.post(
|
|
25
|
+
async def create_session(self, params: CreateSessionParams) -> SessionDetail:
|
|
26
|
+
response = await self.transport.post(
|
|
27
|
+
self._build_url("/session"),
|
|
28
|
+
data=params.model_dump(exclude_none=True, by_alias=True),
|
|
29
|
+
)
|
|
26
30
|
return SessionDetail(**response.data)
|
|
27
31
|
|
|
28
32
|
async def get_session(self, id: str) -> SessionDetail:
|
hyperbrowser/client/sync.py
CHANGED
|
@@ -3,6 +3,7 @@ from ..transport.sync import SyncTransport
|
|
|
3
3
|
from .base import HyperbrowserBase
|
|
4
4
|
from ..models.session import (
|
|
5
5
|
BasicResponse,
|
|
6
|
+
CreateSessionParams,
|
|
6
7
|
SessionDetail,
|
|
7
8
|
SessionListParams,
|
|
8
9
|
SessionListResponse,
|
|
@@ -21,8 +22,11 @@ class Hyperbrowser(HyperbrowserBase):
|
|
|
21
22
|
):
|
|
22
23
|
super().__init__(SyncTransport, config, api_key, base_url)
|
|
23
24
|
|
|
24
|
-
def create_session(self) -> SessionDetail:
|
|
25
|
-
response = self.transport.post(
|
|
25
|
+
def create_session(self, params: CreateSessionParams) -> SessionDetail:
|
|
26
|
+
response = self.transport.post(
|
|
27
|
+
self._build_url("/session"),
|
|
28
|
+
data=params.model_dump(exclude_none=True, by_alias=True),
|
|
29
|
+
)
|
|
26
30
|
return SessionDetail(**response.data)
|
|
27
31
|
|
|
28
32
|
def get_session(self, id: str) -> SessionDetail:
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
Country = Literal[
|
|
4
|
+
"AD",
|
|
5
|
+
"AE",
|
|
6
|
+
"AF",
|
|
7
|
+
"AL",
|
|
8
|
+
"AM",
|
|
9
|
+
"AO",
|
|
10
|
+
"AR",
|
|
11
|
+
"AT",
|
|
12
|
+
"AU",
|
|
13
|
+
"AW",
|
|
14
|
+
"AZ",
|
|
15
|
+
"BA",
|
|
16
|
+
"BD",
|
|
17
|
+
"BE",
|
|
18
|
+
"BG",
|
|
19
|
+
"BH",
|
|
20
|
+
"BJ",
|
|
21
|
+
"BO",
|
|
22
|
+
"BR",
|
|
23
|
+
"BS",
|
|
24
|
+
"BT",
|
|
25
|
+
"BY",
|
|
26
|
+
"BZ",
|
|
27
|
+
"CA",
|
|
28
|
+
"CF",
|
|
29
|
+
"CH",
|
|
30
|
+
"CI",
|
|
31
|
+
"CL",
|
|
32
|
+
"CM",
|
|
33
|
+
"CN",
|
|
34
|
+
"CO",
|
|
35
|
+
"CR",
|
|
36
|
+
"CU",
|
|
37
|
+
"CY",
|
|
38
|
+
"CZ",
|
|
39
|
+
"DE",
|
|
40
|
+
"DJ",
|
|
41
|
+
"DK",
|
|
42
|
+
"DM",
|
|
43
|
+
"EC",
|
|
44
|
+
"EE",
|
|
45
|
+
"EG",
|
|
46
|
+
"ES",
|
|
47
|
+
"ET",
|
|
48
|
+
"EU",
|
|
49
|
+
"FI",
|
|
50
|
+
"FJ",
|
|
51
|
+
"FR",
|
|
52
|
+
"GB",
|
|
53
|
+
"GE",
|
|
54
|
+
"GH",
|
|
55
|
+
"GM",
|
|
56
|
+
"GR",
|
|
57
|
+
"HK",
|
|
58
|
+
"HN",
|
|
59
|
+
"HR",
|
|
60
|
+
"HT",
|
|
61
|
+
"HU",
|
|
62
|
+
"ID",
|
|
63
|
+
"IE",
|
|
64
|
+
"IL",
|
|
65
|
+
"IN",
|
|
66
|
+
"IQ",
|
|
67
|
+
"IR",
|
|
68
|
+
"IS",
|
|
69
|
+
"IT",
|
|
70
|
+
"JM",
|
|
71
|
+
"JO",
|
|
72
|
+
"JP",
|
|
73
|
+
"KE",
|
|
74
|
+
"KH",
|
|
75
|
+
"KR",
|
|
76
|
+
"KW",
|
|
77
|
+
"KZ",
|
|
78
|
+
"LB",
|
|
79
|
+
"LI",
|
|
80
|
+
"LR",
|
|
81
|
+
"LT",
|
|
82
|
+
"LU",
|
|
83
|
+
"LV",
|
|
84
|
+
"MA",
|
|
85
|
+
"MC",
|
|
86
|
+
"MD",
|
|
87
|
+
"ME",
|
|
88
|
+
"MG",
|
|
89
|
+
"MK",
|
|
90
|
+
"ML",
|
|
91
|
+
"MM",
|
|
92
|
+
"MN",
|
|
93
|
+
"MR",
|
|
94
|
+
"MT",
|
|
95
|
+
"MU",
|
|
96
|
+
"MV",
|
|
97
|
+
"MX",
|
|
98
|
+
"MY",
|
|
99
|
+
"MZ",
|
|
100
|
+
"NG",
|
|
101
|
+
"NL",
|
|
102
|
+
"NO",
|
|
103
|
+
"NZ",
|
|
104
|
+
"OM",
|
|
105
|
+
"PA",
|
|
106
|
+
"PE",
|
|
107
|
+
"PH",
|
|
108
|
+
"PK",
|
|
109
|
+
"PL",
|
|
110
|
+
"PR",
|
|
111
|
+
"PT",
|
|
112
|
+
"PY",
|
|
113
|
+
"QA",
|
|
114
|
+
"RANDOM_COUNTRY",
|
|
115
|
+
"RO",
|
|
116
|
+
"RS",
|
|
117
|
+
"RU",
|
|
118
|
+
"SA",
|
|
119
|
+
"SC",
|
|
120
|
+
"SD",
|
|
121
|
+
"SE",
|
|
122
|
+
"SG",
|
|
123
|
+
"SI",
|
|
124
|
+
"SK",
|
|
125
|
+
"SN",
|
|
126
|
+
"SS",
|
|
127
|
+
"TD",
|
|
128
|
+
"TG",
|
|
129
|
+
"TH",
|
|
130
|
+
"TM",
|
|
131
|
+
"TN",
|
|
132
|
+
"TR",
|
|
133
|
+
"TT",
|
|
134
|
+
"TW",
|
|
135
|
+
"UA",
|
|
136
|
+
"UG",
|
|
137
|
+
"US",
|
|
138
|
+
"UY",
|
|
139
|
+
"UZ",
|
|
140
|
+
"VE",
|
|
141
|
+
"VG",
|
|
142
|
+
"VN",
|
|
143
|
+
"YE",
|
|
144
|
+
"ZA",
|
|
145
|
+
"ZM",
|
|
146
|
+
"ZW",
|
|
147
|
+
"ad",
|
|
148
|
+
"ae",
|
|
149
|
+
"af",
|
|
150
|
+
"al",
|
|
151
|
+
"am",
|
|
152
|
+
"ao",
|
|
153
|
+
"ar",
|
|
154
|
+
"at",
|
|
155
|
+
"au",
|
|
156
|
+
"aw",
|
|
157
|
+
"az",
|
|
158
|
+
"ba",
|
|
159
|
+
"bd",
|
|
160
|
+
"be",
|
|
161
|
+
"bg",
|
|
162
|
+
"bh",
|
|
163
|
+
"bj",
|
|
164
|
+
"bo",
|
|
165
|
+
"br",
|
|
166
|
+
"bs",
|
|
167
|
+
"bt",
|
|
168
|
+
"by",
|
|
169
|
+
"bz",
|
|
170
|
+
"ca",
|
|
171
|
+
"cf",
|
|
172
|
+
"ch",
|
|
173
|
+
"ci",
|
|
174
|
+
"cl",
|
|
175
|
+
"cm",
|
|
176
|
+
"cn",
|
|
177
|
+
"co",
|
|
178
|
+
"cr",
|
|
179
|
+
"cu",
|
|
180
|
+
"cy",
|
|
181
|
+
"cz",
|
|
182
|
+
"de",
|
|
183
|
+
"dj",
|
|
184
|
+
"dk",
|
|
185
|
+
"dm",
|
|
186
|
+
"ec",
|
|
187
|
+
"ee",
|
|
188
|
+
"eg",
|
|
189
|
+
"es",
|
|
190
|
+
"et",
|
|
191
|
+
"eu",
|
|
192
|
+
"fi",
|
|
193
|
+
"fj",
|
|
194
|
+
"fr",
|
|
195
|
+
"gb",
|
|
196
|
+
"ge",
|
|
197
|
+
"gh",
|
|
198
|
+
"gm",
|
|
199
|
+
"gr",
|
|
200
|
+
"hk",
|
|
201
|
+
"hn",
|
|
202
|
+
"hr",
|
|
203
|
+
"ht",
|
|
204
|
+
"hu",
|
|
205
|
+
"id",
|
|
206
|
+
"ie",
|
|
207
|
+
"il",
|
|
208
|
+
"in",
|
|
209
|
+
"iq",
|
|
210
|
+
"ir",
|
|
211
|
+
"is",
|
|
212
|
+
"it",
|
|
213
|
+
"jm",
|
|
214
|
+
"jo",
|
|
215
|
+
"jp",
|
|
216
|
+
"ke",
|
|
217
|
+
"kh",
|
|
218
|
+
"kr",
|
|
219
|
+
"kw",
|
|
220
|
+
"kz",
|
|
221
|
+
"lb",
|
|
222
|
+
"li",
|
|
223
|
+
"lr",
|
|
224
|
+
"lt",
|
|
225
|
+
"lu",
|
|
226
|
+
"lv",
|
|
227
|
+
"ma",
|
|
228
|
+
"mc",
|
|
229
|
+
"md",
|
|
230
|
+
"me",
|
|
231
|
+
"mg",
|
|
232
|
+
"mk",
|
|
233
|
+
"ml",
|
|
234
|
+
"mm",
|
|
235
|
+
"mn",
|
|
236
|
+
"mr",
|
|
237
|
+
"mt",
|
|
238
|
+
"mu",
|
|
239
|
+
"mv",
|
|
240
|
+
"mx",
|
|
241
|
+
"my",
|
|
242
|
+
"mz",
|
|
243
|
+
"ng",
|
|
244
|
+
"nl",
|
|
245
|
+
"no",
|
|
246
|
+
"nz",
|
|
247
|
+
"om",
|
|
248
|
+
"pa",
|
|
249
|
+
"pe",
|
|
250
|
+
"ph",
|
|
251
|
+
"pk",
|
|
252
|
+
"pl",
|
|
253
|
+
"pr",
|
|
254
|
+
"pt",
|
|
255
|
+
"py",
|
|
256
|
+
"qa",
|
|
257
|
+
"ro",
|
|
258
|
+
"rs",
|
|
259
|
+
"ru",
|
|
260
|
+
"sa",
|
|
261
|
+
"sc",
|
|
262
|
+
"sd",
|
|
263
|
+
"se",
|
|
264
|
+
"sg",
|
|
265
|
+
"si",
|
|
266
|
+
"sk",
|
|
267
|
+
"sn",
|
|
268
|
+
"ss",
|
|
269
|
+
"td",
|
|
270
|
+
"tg",
|
|
271
|
+
"th",
|
|
272
|
+
"tm",
|
|
273
|
+
"tn",
|
|
274
|
+
"tr",
|
|
275
|
+
"tt",
|
|
276
|
+
"tw",
|
|
277
|
+
"ua",
|
|
278
|
+
"ug",
|
|
279
|
+
"us",
|
|
280
|
+
"uy",
|
|
281
|
+
"uz",
|
|
282
|
+
"ve",
|
|
283
|
+
"vg",
|
|
284
|
+
"vn",
|
|
285
|
+
"ye",
|
|
286
|
+
"za",
|
|
287
|
+
"zm",
|
|
288
|
+
"zw",
|
|
289
|
+
]
|
|
290
|
+
|
|
291
|
+
OperatingSystem = Literal["windows", "android", "macos", "linux", "ios"]
|
|
292
|
+
|
|
293
|
+
Platform = Literal["chrome", "firefox", "safari", "edge"]
|
|
294
|
+
|
|
295
|
+
ISO639_1 = Literal[
|
|
296
|
+
"aa",
|
|
297
|
+
"ab",
|
|
298
|
+
"ae",
|
|
299
|
+
"af",
|
|
300
|
+
"ak",
|
|
301
|
+
"am",
|
|
302
|
+
"an",
|
|
303
|
+
"ar",
|
|
304
|
+
"as",
|
|
305
|
+
"av",
|
|
306
|
+
"ay",
|
|
307
|
+
"az",
|
|
308
|
+
"ba",
|
|
309
|
+
"be",
|
|
310
|
+
"bg",
|
|
311
|
+
"bh",
|
|
312
|
+
"bi",
|
|
313
|
+
"bm",
|
|
314
|
+
"bn",
|
|
315
|
+
"bo",
|
|
316
|
+
"br",
|
|
317
|
+
"bs",
|
|
318
|
+
"ca",
|
|
319
|
+
"ce",
|
|
320
|
+
"ch",
|
|
321
|
+
"co",
|
|
322
|
+
"cr",
|
|
323
|
+
"cs",
|
|
324
|
+
"cu",
|
|
325
|
+
"cv",
|
|
326
|
+
"cy",
|
|
327
|
+
"da",
|
|
328
|
+
"de",
|
|
329
|
+
"dv",
|
|
330
|
+
"dz",
|
|
331
|
+
"ee",
|
|
332
|
+
"el",
|
|
333
|
+
"en",
|
|
334
|
+
"eo",
|
|
335
|
+
"es",
|
|
336
|
+
"et",
|
|
337
|
+
"eu",
|
|
338
|
+
"fa",
|
|
339
|
+
"ff",
|
|
340
|
+
"fi",
|
|
341
|
+
"fj",
|
|
342
|
+
"fo",
|
|
343
|
+
"fr",
|
|
344
|
+
"fy",
|
|
345
|
+
"ga",
|
|
346
|
+
"gd",
|
|
347
|
+
"gl",
|
|
348
|
+
"gn",
|
|
349
|
+
"gu",
|
|
350
|
+
"gv",
|
|
351
|
+
"ha",
|
|
352
|
+
"he",
|
|
353
|
+
"hi",
|
|
354
|
+
"ho",
|
|
355
|
+
"hr",
|
|
356
|
+
"ht",
|
|
357
|
+
"hu",
|
|
358
|
+
"hy",
|
|
359
|
+
"hz",
|
|
360
|
+
"ia",
|
|
361
|
+
"id",
|
|
362
|
+
"ie",
|
|
363
|
+
"ig",
|
|
364
|
+
"ii",
|
|
365
|
+
"ik",
|
|
366
|
+
"io",
|
|
367
|
+
"is",
|
|
368
|
+
"it",
|
|
369
|
+
"iu",
|
|
370
|
+
"ja",
|
|
371
|
+
"jv",
|
|
372
|
+
"ka",
|
|
373
|
+
"kg",
|
|
374
|
+
"ki",
|
|
375
|
+
"kj",
|
|
376
|
+
"kk",
|
|
377
|
+
"kl",
|
|
378
|
+
"km",
|
|
379
|
+
"kn",
|
|
380
|
+
"ko",
|
|
381
|
+
"kr",
|
|
382
|
+
"ks",
|
|
383
|
+
"ku",
|
|
384
|
+
"kv",
|
|
385
|
+
"kw",
|
|
386
|
+
"ky",
|
|
387
|
+
"la",
|
|
388
|
+
"lb",
|
|
389
|
+
"lg",
|
|
390
|
+
"li",
|
|
391
|
+
"ln",
|
|
392
|
+
"lo",
|
|
393
|
+
"lt",
|
|
394
|
+
"lu",
|
|
395
|
+
"lv",
|
|
396
|
+
"mg",
|
|
397
|
+
"mh",
|
|
398
|
+
"mi",
|
|
399
|
+
"mk",
|
|
400
|
+
"ml",
|
|
401
|
+
"mn",
|
|
402
|
+
"mo",
|
|
403
|
+
"mr",
|
|
404
|
+
"ms",
|
|
405
|
+
"mt",
|
|
406
|
+
"my",
|
|
407
|
+
"na",
|
|
408
|
+
"nb",
|
|
409
|
+
"nd",
|
|
410
|
+
"ne",
|
|
411
|
+
"ng",
|
|
412
|
+
"nl",
|
|
413
|
+
"nn",
|
|
414
|
+
"no",
|
|
415
|
+
"nr",
|
|
416
|
+
"nv",
|
|
417
|
+
"ny",
|
|
418
|
+
"oc",
|
|
419
|
+
"oj",
|
|
420
|
+
"om",
|
|
421
|
+
"or",
|
|
422
|
+
"os",
|
|
423
|
+
"pa",
|
|
424
|
+
"pi",
|
|
425
|
+
"pl",
|
|
426
|
+
"ps",
|
|
427
|
+
"pt",
|
|
428
|
+
"qu",
|
|
429
|
+
"rm",
|
|
430
|
+
"rn",
|
|
431
|
+
"ro",
|
|
432
|
+
"ru",
|
|
433
|
+
"rw",
|
|
434
|
+
"sa",
|
|
435
|
+
"sc",
|
|
436
|
+
"sd",
|
|
437
|
+
"se",
|
|
438
|
+
"sg",
|
|
439
|
+
"si",
|
|
440
|
+
"sk",
|
|
441
|
+
"sl",
|
|
442
|
+
"sm",
|
|
443
|
+
"sn",
|
|
444
|
+
"so",
|
|
445
|
+
"sq",
|
|
446
|
+
"sr",
|
|
447
|
+
"ss",
|
|
448
|
+
"st",
|
|
449
|
+
"su",
|
|
450
|
+
"sv",
|
|
451
|
+
"sw",
|
|
452
|
+
"ta",
|
|
453
|
+
"te",
|
|
454
|
+
"tg",
|
|
455
|
+
"th",
|
|
456
|
+
"ti",
|
|
457
|
+
"tk",
|
|
458
|
+
"tl",
|
|
459
|
+
"tn",
|
|
460
|
+
"to",
|
|
461
|
+
"tr",
|
|
462
|
+
"ts",
|
|
463
|
+
"tt",
|
|
464
|
+
"tw",
|
|
465
|
+
"ty",
|
|
466
|
+
"ug",
|
|
467
|
+
"uk",
|
|
468
|
+
"ur",
|
|
469
|
+
"uz",
|
|
470
|
+
"ve",
|
|
471
|
+
"vi",
|
|
472
|
+
"vo",
|
|
473
|
+
"wa",
|
|
474
|
+
"wo",
|
|
475
|
+
"xh",
|
|
476
|
+
"yi",
|
|
477
|
+
"yo",
|
|
478
|
+
"za",
|
|
479
|
+
"zh",
|
|
480
|
+
"zu",
|
|
481
|
+
]
|
hyperbrowser/models/session.py
CHANGED
|
@@ -2,6 +2,8 @@ from typing import List, Literal, Optional, Union
|
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from pydantic import BaseModel, Field, ConfigDict, field_validator
|
|
4
4
|
|
|
5
|
+
from hyperbrowser.models.consts import Country, OperatingSystem, Platform, ISO639_1
|
|
6
|
+
|
|
5
7
|
SessionStatus = Literal["active", "closed", "error"]
|
|
6
8
|
|
|
7
9
|
|
|
@@ -87,3 +89,42 @@ class SessionListResponse(BaseModel):
|
|
|
87
89
|
def total_pages(self) -> int:
|
|
88
90
|
"""Calculate the total number of pages."""
|
|
89
91
|
return -(-self.total_count // self.per_page)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ScreenConfig(BaseModel):
|
|
95
|
+
"""
|
|
96
|
+
Screen configuration parameters for browser session.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
max_width: int = Field(default=1280, le=4096, serialization_alias="maxWidth")
|
|
100
|
+
max_height: int = Field(default=720, le=4096, serialization_alias="maxHeight")
|
|
101
|
+
min_width: int = Field(default=800, ge=360, serialization_alias="minWidth")
|
|
102
|
+
min_height: int = Field(default=480, ge=360, serialization_alias="minHeight")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class CreateSessionParams(BaseModel):
|
|
106
|
+
"""
|
|
107
|
+
Parameters for creating a new browser session.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
model_config = ConfigDict(
|
|
111
|
+
populate_by_alias=True,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
proxy_server: Optional[str] = Field(default=None, serialization_alias="proxyServer")
|
|
115
|
+
proxy_server_password: Optional[str] = Field(
|
|
116
|
+
default=None, serialization_alias="proxyServerPassword"
|
|
117
|
+
)
|
|
118
|
+
proxy_server_username: Optional[str] = Field(
|
|
119
|
+
default=None, serialization_alias="proxyServerUsername"
|
|
120
|
+
)
|
|
121
|
+
proxy_country: Optional[Country] = Field(
|
|
122
|
+
default="US", serialization_alias="proxyCountry"
|
|
123
|
+
)
|
|
124
|
+
operating_systems: Optional[List[OperatingSystem]] = Field(
|
|
125
|
+
default=None, serialization_alias="operatingSystems"
|
|
126
|
+
)
|
|
127
|
+
device: Optional[List[Literal["desktop", "mobile"]]] = Field(default=None)
|
|
128
|
+
platform: Optional[List[Platform]] = Field(default=None)
|
|
129
|
+
locales: List[ISO639_1] = Field(default=["en"])
|
|
130
|
+
screen: Optional[ScreenConfig] = Field(default=None)
|
|
@@ -66,9 +66,9 @@ class AsyncTransport(TransportStrategy):
|
|
|
66
66
|
except httpx.RequestError as e:
|
|
67
67
|
raise HyperbrowserError("Request failed", original_error=e)
|
|
68
68
|
|
|
69
|
-
async def post(self, url: str) -> APIResponse:
|
|
69
|
+
async def post(self, url: str, data: Optional[dict] = None) -> APIResponse:
|
|
70
70
|
try:
|
|
71
|
-
response = await self.client.post(url)
|
|
71
|
+
response = await self.client.post(url, json=data)
|
|
72
72
|
return await self._handle_response(response)
|
|
73
73
|
except HyperbrowserError:
|
|
74
74
|
raise
|
hyperbrowser/transport/sync.py
CHANGED
|
@@ -45,9 +45,9 @@ class SyncTransport(TransportStrategy):
|
|
|
45
45
|
def close(self) -> None:
|
|
46
46
|
self.client.close()
|
|
47
47
|
|
|
48
|
-
def post(self, url: str) -> APIResponse:
|
|
48
|
+
def post(self, url: str, data: Optional[dict] = None) -> APIResponse:
|
|
49
49
|
try:
|
|
50
|
-
response = self.client.post(url)
|
|
50
|
+
response = self.client.post(url, json=data)
|
|
51
51
|
return self._handle_response(response)
|
|
52
52
|
except HyperbrowserError:
|
|
53
53
|
raise
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hyperbrowser
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Python SDK for hyperbrowser
|
|
5
5
|
Home-page: https://github.com/hyperbrowserai/python-sdk
|
|
6
6
|
License: MIT
|
|
@@ -46,15 +46,15 @@ The API key can be configured either from the constructor arguments or environme
|
|
|
46
46
|
```python
|
|
47
47
|
import asyncio
|
|
48
48
|
from pyppeteer import connect
|
|
49
|
-
from hyperbrowser
|
|
49
|
+
from hyperbrowser import AsyncHyperbrowser
|
|
50
50
|
|
|
51
51
|
HYPERBROWSER_API_KEY = "test-key"
|
|
52
52
|
|
|
53
53
|
async def main():
|
|
54
|
-
async with
|
|
54
|
+
async with AsyncHyperbrowser(api_key=HYPERBROWSER_API_KEY) as client:
|
|
55
55
|
session = await client.create_session()
|
|
56
56
|
|
|
57
|
-
ws_endpoint =
|
|
57
|
+
ws_endpoint = session.websocket_url
|
|
58
58
|
browser = await connect(browserWSEndpoint=ws_endpoint, defaultViewport=None)
|
|
59
59
|
|
|
60
60
|
# Get pages
|
|
@@ -72,6 +72,7 @@ async def main():
|
|
|
72
72
|
|
|
73
73
|
await page.close()
|
|
74
74
|
await browser.disconnect()
|
|
75
|
+
await client.stop_session(session.id)
|
|
75
76
|
print("Session completed!")
|
|
76
77
|
|
|
77
78
|
# Run the asyncio event loop
|
|
@@ -81,7 +82,7 @@ asyncio.get_event_loop().run_until_complete(main())
|
|
|
81
82
|
|
|
82
83
|
```python
|
|
83
84
|
from playwright.sync_api import sync_playwright
|
|
84
|
-
from hyperbrowser
|
|
85
|
+
from hyperbrowser import Hyperbrowser
|
|
85
86
|
|
|
86
87
|
HYPERBROWSER_API_KEY = "test-key"
|
|
87
88
|
|
|
@@ -89,7 +90,7 @@ def main():
|
|
|
89
90
|
client = Hyperbrowser(api_key=HYPERBROWSER_API_KEY)
|
|
90
91
|
session = client.create_session()
|
|
91
92
|
|
|
92
|
-
ws_endpoint =
|
|
93
|
+
ws_endpoint = session.websocket_url
|
|
93
94
|
|
|
94
95
|
# Launch Playwright and connect to the remote browser
|
|
95
96
|
with sync_playwright() as p:
|
|
@@ -111,6 +112,7 @@ def main():
|
|
|
111
112
|
page.close()
|
|
112
113
|
browser.close()
|
|
113
114
|
print("Session completed!")
|
|
115
|
+
client.stop_session(session.id)
|
|
114
116
|
|
|
115
117
|
# Run the asyncio event loop
|
|
116
118
|
main()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE,sha256=6rUGKlyKb_1ZAH7h7YITYAAUNFN3MNGGKCyfrw49NLE,1071
|
|
2
|
+
hyperbrowser/__init__.py,sha256=zWGcLhqhvWy6BTwuNpzWK1-0LpIn311ks-4U9nrsb7Y,187
|
|
3
|
+
hyperbrowser/client/async_client.py,sha256=wHQZs1o1xLXbbaqniq5chvmlEf2pJ9jZUcS5bOO_Ids,1799
|
|
4
|
+
hyperbrowser/client/base.py,sha256=9gFma7RdvJBUlDCqr8tZd315UPrjn4ldU4B0-Y-L4O4,1268
|
|
5
|
+
hyperbrowser/client/sync.py,sha256=joOadvrAzducl8QABW5C5ilWDf52OybWS-Nv0cQBkVo,1545
|
|
6
|
+
hyperbrowser/config.py,sha256=2J6GYNR_83vzJZ6jEV-LXO1U-q6DHIrfyAU0WrUPhw8,625
|
|
7
|
+
hyperbrowser/exceptions.py,sha256=SUUkptK2OL36xDORYmSicaTYR7pMbxeWAjAgz35xnM8,1171
|
|
8
|
+
hyperbrowser/models/consts.py,sha256=VmtqbXqK6WTvlD5XExL3e2JE3WaFTi_iniEAQlRSQgs,4917
|
|
9
|
+
hyperbrowser/models/session.py,sha256=bHUesek0izWAaTaIam19lPgjjh65rGf2qTPDodhl2Lk,3870
|
|
10
|
+
hyperbrowser/transport/async_transport.py,sha256=P-nX9iczGVYJyvqtqlGAOFQ3PghRC2_bE6Lruiiecn0,3511
|
|
11
|
+
hyperbrowser/transport/base.py,sha256=9l7k-qTX4Q2KaZIR_fwsNlxDgOzsmc8zgucZ9tfHgkw,1622
|
|
12
|
+
hyperbrowser/transport/sync.py,sha256=DFDPYqF-_WQSZkRbWDRFTPowQMzz-B3N869r2vvocPc,2829
|
|
13
|
+
hyperbrowser-0.4.0.dist-info/LICENSE,sha256=6rUGKlyKb_1ZAH7h7YITYAAUNFN3MNGGKCyfrw49NLE,1071
|
|
14
|
+
hyperbrowser-0.4.0.dist-info/METADATA,sha256=u1ZLB_1zbga-Wh1WCc6dZe5diVxd9b2WCPidb1g_mAM,3289
|
|
15
|
+
hyperbrowser-0.4.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
16
|
+
hyperbrowser-0.4.0.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
LICENSE,sha256=6rUGKlyKb_1ZAH7h7YITYAAUNFN3MNGGKCyfrw49NLE,1071
|
|
2
|
-
hyperbrowser/__init__.py,sha256=zWGcLhqhvWy6BTwuNpzWK1-0LpIn311ks-4U9nrsb7Y,187
|
|
3
|
-
hyperbrowser/client/async_client.py,sha256=F4jHMY77mfNhe-2w9NiIGb_ycbw-ccUBBvRSMKw2Hzg,1652
|
|
4
|
-
hyperbrowser/client/base.py,sha256=9gFma7RdvJBUlDCqr8tZd315UPrjn4ldU4B0-Y-L4O4,1268
|
|
5
|
-
hyperbrowser/client/sync.py,sha256=9a3IOwMbsAx8lkYFN-xmbx_G5rjzoPrTc8PXUduuI74,1398
|
|
6
|
-
hyperbrowser/config.py,sha256=2J6GYNR_83vzJZ6jEV-LXO1U-q6DHIrfyAU0WrUPhw8,625
|
|
7
|
-
hyperbrowser/exceptions.py,sha256=SUUkptK2OL36xDORYmSicaTYR7pMbxeWAjAgz35xnM8,1171
|
|
8
|
-
hyperbrowser/models/session.py,sha256=LgyozjvYyMGCRFEcH_a9ufu8MRW7U0BQpeVA6zOIcIw,2355
|
|
9
|
-
hyperbrowser/transport/async_transport.py,sha256=-1GfGrFnYyGovrRDWhDVtbjKjqmvD_NEmoYvgrfjaQg,3471
|
|
10
|
-
hyperbrowser/transport/base.py,sha256=9l7k-qTX4Q2KaZIR_fwsNlxDgOzsmc8zgucZ9tfHgkw,1622
|
|
11
|
-
hyperbrowser/transport/sync.py,sha256=ZS1upJNmQlFEzV_53nqTgArqO0a3uByYYzY_DGEPQxk,2789
|
|
12
|
-
hyperbrowser-0.3.0.dist-info/LICENSE,sha256=6rUGKlyKb_1ZAH7h7YITYAAUNFN3MNGGKCyfrw49NLE,1071
|
|
13
|
-
hyperbrowser-0.3.0.dist-info/METADATA,sha256=oszbPN4IBc4yMEK_4VSI4hu-ramXIPb9J2GrXRYPvYo,3320
|
|
14
|
-
hyperbrowser-0.3.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
15
|
-
hyperbrowser-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|