simplex 1.2.69__tar.gz → 1.2.71__tar.gz
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 simplex might be problematic. Click here for more details.
- {simplex-1.2.69 → simplex-1.2.71}/PKG-INFO +12 -2
- {simplex-1.2.69 → simplex-1.2.71}/setup.py +1 -1
- {simplex-1.2.69 → simplex-1.2.71}/simplex/simplex.py +149 -184
- {simplex-1.2.69 → simplex-1.2.71}/simplex.egg-info/PKG-INFO +12 -2
- {simplex-1.2.69 → simplex-1.2.71}/LICENSE +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/README.md +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/setup.cfg +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex/__init__.py +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex/cli.py +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex/deploy/__init__.py +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex/deploy/push.py +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex.egg-info/SOURCES.txt +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex.egg-info/dependency_links.txt +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex.egg-info/entry_points.txt +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex.egg-info/requires.txt +0 -0
- {simplex-1.2.69 → simplex-1.2.71}/simplex.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: simplex
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.71
|
|
4
4
|
Summary: Official Python SDK for Simplex API
|
|
5
5
|
Home-page: https://simplex.sh
|
|
6
6
|
Author: Simplex Labs, Inc.
|
|
@@ -19,6 +19,16 @@ Requires-Dist: python-dotenv
|
|
|
19
19
|
Requires-Dist: click
|
|
20
20
|
Provides-Extra: playwright
|
|
21
21
|
Requires-Dist: rebrowser-playwright>=1.0.0; extra == "playwright"
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: provides-extra
|
|
29
|
+
Dynamic: requires-dist
|
|
30
|
+
Dynamic: requires-python
|
|
31
|
+
Dynamic: summary
|
|
22
32
|
|
|
23
33
|
# Simplex AI Python SDK
|
|
24
34
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import atexit
|
|
3
1
|
from typing import Optional, Union
|
|
4
2
|
import os
|
|
5
3
|
import json
|
|
6
4
|
import warnings
|
|
5
|
+
import requests
|
|
7
6
|
|
|
8
7
|
try:
|
|
9
8
|
from rebrowser_playwright.sync_api import sync_playwright
|
|
@@ -77,7 +76,6 @@ class Simplex:
|
|
|
77
76
|
def __init__(self, api_key: str):
|
|
78
77
|
self.api_key = api_key
|
|
79
78
|
self.session_id = None
|
|
80
|
-
atexit.register(self.close_session)
|
|
81
79
|
if PLAYWRIGHT_AVAILABLE:
|
|
82
80
|
self.pw_browser = None
|
|
83
81
|
self.pw = None
|
|
@@ -171,19 +169,17 @@ class Simplex:
|
|
|
171
169
|
|
|
172
170
|
return self.session_id, livestream_url
|
|
173
171
|
|
|
174
|
-
def goto(self, url: str
|
|
175
|
-
if not
|
|
172
|
+
def goto(self, url: str):
|
|
173
|
+
if not self.session_id:
|
|
176
174
|
raise ValueError(f"Must call create_session before calling action goto with url='{url}'")
|
|
177
175
|
|
|
178
176
|
if not url.startswith('http://') and not url.startswith('https://'):
|
|
179
177
|
url = 'https://' + url
|
|
180
178
|
|
|
181
|
-
data = {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
else:
|
|
186
|
-
data['session_id'] = self.session_id
|
|
179
|
+
data = {
|
|
180
|
+
'url': url,
|
|
181
|
+
'session_id': self.session_id
|
|
182
|
+
}
|
|
187
183
|
|
|
188
184
|
response = requests.post(
|
|
189
185
|
f"{BASE_URL}/goto",
|
|
@@ -192,7 +188,6 @@ class Simplex:
|
|
|
192
188
|
},
|
|
193
189
|
data=data
|
|
194
190
|
)
|
|
195
|
-
|
|
196
191
|
if 'succeeded' not in response.json():
|
|
197
192
|
raise ValueError(f"It looks like the goto action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
198
193
|
|
|
@@ -200,20 +195,17 @@ class Simplex:
|
|
|
200
195
|
return
|
|
201
196
|
else:
|
|
202
197
|
raise ValueError(f"Failed to goto url: {response.json()['error']}")
|
|
203
|
-
|
|
204
198
|
|
|
205
|
-
def click(self, element_description: str
|
|
199
|
+
def click(self, element_description: str):
|
|
206
200
|
if not element_description or not element_description.strip():
|
|
207
201
|
raise ValueError("element_description cannot be empty")
|
|
208
|
-
if not
|
|
202
|
+
if not self.session_id:
|
|
209
203
|
raise ValueError(f"Must call create_session before calling action click with element_description='{element_description}'")
|
|
210
204
|
|
|
211
|
-
data = {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
else:
|
|
216
|
-
data['session_id'] = self.session_id
|
|
205
|
+
data = {
|
|
206
|
+
'element_description': element_description,
|
|
207
|
+
'session_id': self.session_id
|
|
208
|
+
}
|
|
217
209
|
|
|
218
210
|
response = requests.post(
|
|
219
211
|
f"{BASE_URL}/click",
|
|
@@ -229,19 +221,16 @@ class Simplex:
|
|
|
229
221
|
else:
|
|
230
222
|
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
231
223
|
|
|
232
|
-
def select_dropdown_option(self, element_description: str
|
|
224
|
+
def select_dropdown_option(self, element_description: str):
|
|
233
225
|
if not element_description or not element_description.strip():
|
|
234
226
|
raise ValueError("element_description cannot be empty")
|
|
235
|
-
if not
|
|
227
|
+
if not self.session_id:
|
|
236
228
|
raise ValueError(f"Must call create_session before calling action select_from_dropdown with element_description='{element_description}'")
|
|
237
229
|
|
|
238
|
-
data = {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
else:
|
|
243
|
-
data['session_id'] = self.session_id
|
|
244
|
-
|
|
230
|
+
data = {
|
|
231
|
+
'element_description': element_description,
|
|
232
|
+
'session_id': self.session_id
|
|
233
|
+
}
|
|
245
234
|
|
|
246
235
|
response = requests.post(
|
|
247
236
|
f"{BASE_URL}/select_dropdown_option",
|
|
@@ -258,19 +247,16 @@ class Simplex:
|
|
|
258
247
|
else:
|
|
259
248
|
raise ValueError(f"Failed to select dropdown option: {response.json()['error']}")
|
|
260
249
|
|
|
261
|
-
|
|
262
|
-
def scroll_to_element(self, element_description: str, cdp_url: str = None):
|
|
250
|
+
def scroll_to_element(self, element_description: str):
|
|
263
251
|
if not element_description or not element_description.strip():
|
|
264
252
|
raise ValueError("element_description cannot be empty")
|
|
265
|
-
if not
|
|
253
|
+
if not self.session_id:
|
|
266
254
|
raise ValueError(f"Must call create_session before calling action scroll_to_element with element_description='{element_description}'")
|
|
267
255
|
|
|
268
|
-
data = {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
else:
|
|
273
|
-
data['session_id'] = self.session_id
|
|
256
|
+
data = {
|
|
257
|
+
'element_description': element_description,
|
|
258
|
+
'session_id': self.session_id
|
|
259
|
+
}
|
|
274
260
|
|
|
275
261
|
response = requests.post(
|
|
276
262
|
f"{BASE_URL}/scroll_to_element",
|
|
@@ -286,21 +272,17 @@ class Simplex:
|
|
|
286
272
|
return
|
|
287
273
|
else:
|
|
288
274
|
raise ValueError(f"Failed to scroll element into view: {response.json()['error']}")
|
|
289
|
-
|
|
290
|
-
|
|
291
275
|
|
|
292
|
-
def hover(self, element_description: str
|
|
276
|
+
def hover(self, element_description: str):
|
|
293
277
|
if not element_description or not element_description.strip():
|
|
294
278
|
raise ValueError("element_description cannot be empty")
|
|
295
|
-
if not
|
|
279
|
+
if not self.session_id:
|
|
296
280
|
raise ValueError(f"Must call create_session before calling action hover with element_description='{element_description}'")
|
|
297
281
|
|
|
298
|
-
data = {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
else:
|
|
303
|
-
data['session_id'] = self.session_id
|
|
282
|
+
data = {
|
|
283
|
+
'element_description': element_description,
|
|
284
|
+
'session_id': self.session_id
|
|
285
|
+
}
|
|
304
286
|
|
|
305
287
|
response = requests.post(
|
|
306
288
|
f"{BASE_URL}/hover",
|
|
@@ -317,18 +299,16 @@ class Simplex:
|
|
|
317
299
|
else:
|
|
318
300
|
raise ValueError(f"Failed to hover: {response.json()['error']}")
|
|
319
301
|
|
|
320
|
-
def type(self, text: str
|
|
302
|
+
def type(self, text: str):
|
|
321
303
|
if not text or not text.strip():
|
|
322
304
|
raise ValueError("text cannot be empty")
|
|
323
|
-
if not
|
|
305
|
+
if not self.session_id:
|
|
324
306
|
raise ValueError(f"Must call create_session before calling action type with text='{text}'")
|
|
325
307
|
|
|
326
|
-
data = {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
else:
|
|
331
|
-
data['session_id'] = self.session_id
|
|
308
|
+
data = {
|
|
309
|
+
'text': text,
|
|
310
|
+
'session_id': self.session_id
|
|
311
|
+
}
|
|
332
312
|
|
|
333
313
|
response = requests.post(
|
|
334
314
|
f"{BASE_URL}/type",
|
|
@@ -340,19 +320,15 @@ class Simplex:
|
|
|
340
320
|
if response.json()['succeeded']:
|
|
341
321
|
return
|
|
342
322
|
else:
|
|
343
|
-
raise ValueError(f"Failed to type text: {response.json()['error']}")
|
|
344
|
-
|
|
323
|
+
raise ValueError(f"Failed to type text: {response.json()['error']}")
|
|
345
324
|
|
|
346
|
-
def reload(self
|
|
347
|
-
if not
|
|
325
|
+
def reload(self):
|
|
326
|
+
if not self.session_id:
|
|
348
327
|
raise ValueError("Must call create_session before calling action reload")
|
|
349
328
|
|
|
350
|
-
data = {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
data['cdp_url'] = cdp_url
|
|
354
|
-
else:
|
|
355
|
-
data['session_id'] = self.session_id
|
|
329
|
+
data = {
|
|
330
|
+
'session_id': self.session_id
|
|
331
|
+
}
|
|
356
332
|
|
|
357
333
|
response = requests.post(
|
|
358
334
|
f"{BASE_URL}/reload",
|
|
@@ -368,16 +344,13 @@ class Simplex:
|
|
|
368
344
|
else:
|
|
369
345
|
raise ValueError(f"Failed to reload: {response.json()['error']}")
|
|
370
346
|
|
|
371
|
-
def press_enter(self
|
|
372
|
-
if not
|
|
347
|
+
def press_enter(self):
|
|
348
|
+
if not self.session_id:
|
|
373
349
|
raise ValueError("Must call create_session before calling action press_enter")
|
|
374
350
|
|
|
375
|
-
data = {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
data['cdp_url'] = cdp_url
|
|
379
|
-
else:
|
|
380
|
-
data['session_id'] = self.session_id
|
|
351
|
+
data = {
|
|
352
|
+
'session_id': self.session_id
|
|
353
|
+
}
|
|
381
354
|
|
|
382
355
|
response = requests.post(
|
|
383
356
|
f"{BASE_URL}/press_enter",
|
|
@@ -393,16 +366,13 @@ class Simplex:
|
|
|
393
366
|
else:
|
|
394
367
|
raise ValueError(f"Failed to press enter: {response.json()['error']}")
|
|
395
368
|
|
|
396
|
-
def press_tab(self
|
|
397
|
-
if not
|
|
369
|
+
def press_tab(self):
|
|
370
|
+
if not self.session_id:
|
|
398
371
|
raise ValueError("Must call create_session before calling action press_tab")
|
|
399
372
|
|
|
400
|
-
data = {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
data['cdp_url'] = cdp_url
|
|
404
|
-
else:
|
|
405
|
-
data['session_id'] = self.session_id
|
|
373
|
+
data = {
|
|
374
|
+
'session_id': self.session_id
|
|
375
|
+
}
|
|
406
376
|
|
|
407
377
|
response = requests.post(
|
|
408
378
|
f"{BASE_URL}/press_tab",
|
|
@@ -418,16 +388,13 @@ class Simplex:
|
|
|
418
388
|
else:
|
|
419
389
|
raise ValueError(f"Failed to press tab: {response.json()['error']}")
|
|
420
390
|
|
|
421
|
-
def delete_text(self
|
|
422
|
-
if not
|
|
391
|
+
def delete_text(self):
|
|
392
|
+
if not self.session_id:
|
|
423
393
|
raise ValueError("Must call create_session before calling action delete_text")
|
|
424
394
|
|
|
425
|
-
data = {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
data['cdp_url'] = cdp_url
|
|
429
|
-
else:
|
|
430
|
-
data['session_id'] = self.session_id
|
|
395
|
+
data = {
|
|
396
|
+
'session_id': self.session_id
|
|
397
|
+
}
|
|
431
398
|
|
|
432
399
|
response = requests.post(
|
|
433
400
|
f"{BASE_URL}/delete_text",
|
|
@@ -443,45 +410,38 @@ class Simplex:
|
|
|
443
410
|
else:
|
|
444
411
|
raise ValueError(f"Failed to delete text: {response.json()['error']}")
|
|
445
412
|
|
|
446
|
-
def
|
|
447
|
-
if not
|
|
448
|
-
raise ValueError("
|
|
449
|
-
if not cdp_url and not self.session_id:
|
|
450
|
-
raise ValueError(f"Must call create_session before calling action extract_bbox with element_description='{element_description}'")
|
|
451
|
-
|
|
452
|
-
data = {'element_description': element_description}
|
|
413
|
+
def bot_tests(self):
|
|
414
|
+
if not self.session_id:
|
|
415
|
+
raise ValueError("Must call create_session before calling action bot_tests")
|
|
453
416
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
data['session_id'] = self.session_id
|
|
417
|
+
data = {
|
|
418
|
+
'session_id': self.session_id
|
|
419
|
+
}
|
|
458
420
|
|
|
459
|
-
response = requests.
|
|
460
|
-
f"{BASE_URL}/
|
|
421
|
+
response = requests.post(
|
|
422
|
+
f"{BASE_URL}/bot_tests",
|
|
461
423
|
headers={
|
|
462
424
|
'x-api-key': self.api_key
|
|
463
425
|
},
|
|
464
|
-
|
|
426
|
+
data=data
|
|
465
427
|
)
|
|
466
428
|
if 'succeeded' not in response.json():
|
|
467
|
-
raise ValueError(f"It looks like the
|
|
429
|
+
raise ValueError(f"It looks like the bot_tests action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
468
430
|
if response.json()['succeeded']:
|
|
469
|
-
return
|
|
431
|
+
return
|
|
470
432
|
else:
|
|
471
|
-
raise ValueError(f"Failed to
|
|
433
|
+
raise ValueError(f"Failed to run bot tests: {response.json()['error']}")
|
|
472
434
|
|
|
473
|
-
def extract_text(self, element_description: str
|
|
435
|
+
def extract_text(self, element_description: str):
|
|
474
436
|
if not element_description or not element_description.strip():
|
|
475
437
|
raise ValueError("element_description cannot be empty")
|
|
476
|
-
if not
|
|
438
|
+
if not self.session_id:
|
|
477
439
|
raise ValueError(f"Must call create_session before calling action extract_text with element_description='{element_description}'")
|
|
478
440
|
|
|
479
|
-
data = {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
else:
|
|
484
|
-
data['session_id'] = self.session_id
|
|
441
|
+
data = {
|
|
442
|
+
'element_description': element_description,
|
|
443
|
+
'session_id': self.session_id
|
|
444
|
+
}
|
|
485
445
|
|
|
486
446
|
response = requests.post(
|
|
487
447
|
f"{BASE_URL}/extract-text",
|
|
@@ -493,48 +453,19 @@ class Simplex:
|
|
|
493
453
|
response_json = response.json()
|
|
494
454
|
if 'succeeded' not in response_json:
|
|
495
455
|
raise ValueError(f"It looks like the extract_text action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
496
|
-
if "succeeded"
|
|
456
|
+
if response_json["succeeded"]:
|
|
497
457
|
return response_json["text"]
|
|
498
458
|
else:
|
|
499
459
|
raise ValueError(f"Failed to extract text: {response_json['error']}")
|
|
500
460
|
|
|
501
|
-
def
|
|
502
|
-
if not
|
|
503
|
-
raise ValueError("element_description cannot be empty")
|
|
504
|
-
if not cdp_url and not self.session_id:
|
|
505
|
-
raise ValueError(f"Must call create_session before calling action extract_image with element_description='{element_description}'")
|
|
506
|
-
|
|
507
|
-
data = {'element_description': element_description}
|
|
508
|
-
|
|
509
|
-
if cdp_url:
|
|
510
|
-
data['cdp_url'] = cdp_url
|
|
511
|
-
else:
|
|
512
|
-
data['session_id'] = self.session_id
|
|
513
|
-
|
|
514
|
-
response = requests.get(
|
|
515
|
-
f"{BASE_URL}/extract-image",
|
|
516
|
-
headers={
|
|
517
|
-
'x-api-key': self.api_key
|
|
518
|
-
},
|
|
519
|
-
params=data
|
|
520
|
-
)
|
|
521
|
-
if 'succeeded' not in response.json():
|
|
522
|
-
raise ValueError(f"It looks like the extract_image action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
523
|
-
if response.json()['succeeded']:
|
|
524
|
-
return response.json()["image"]
|
|
525
|
-
else:
|
|
526
|
-
raise ValueError(f"Failed to extract image: {response.json()['error']}")
|
|
527
|
-
|
|
528
|
-
def scroll(self, pixels: float, cdp_url: str = None):
|
|
529
|
-
if not cdp_url and not self.session_id:
|
|
461
|
+
def scroll(self, pixels: float):
|
|
462
|
+
if not self.session_id:
|
|
530
463
|
raise ValueError(f"Must call create_session before calling action scroll with pixels={pixels}")
|
|
531
464
|
|
|
532
|
-
data = {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
else:
|
|
537
|
-
data['session_id'] = self.session_id
|
|
465
|
+
data = {
|
|
466
|
+
'pixels': pixels,
|
|
467
|
+
'session_id': self.session_id
|
|
468
|
+
}
|
|
538
469
|
|
|
539
470
|
response = requests.post(
|
|
540
471
|
f"{BASE_URL}/scroll",
|
|
@@ -550,16 +481,14 @@ class Simplex:
|
|
|
550
481
|
else:
|
|
551
482
|
raise ValueError(f"Failed to scroll: {response.json()['error']}")
|
|
552
483
|
|
|
553
|
-
def wait(self, milliseconds: int
|
|
554
|
-
if not
|
|
484
|
+
def wait(self, milliseconds: int):
|
|
485
|
+
if not self.session_id:
|
|
555
486
|
raise ValueError(f"Must call create_session before calling action wait with milliseconds={milliseconds}")
|
|
556
487
|
|
|
557
|
-
data = {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
else:
|
|
562
|
-
data['session_id'] = self.session_id
|
|
488
|
+
data = {
|
|
489
|
+
'milliseconds': milliseconds,
|
|
490
|
+
'session_id': self.session_id
|
|
491
|
+
}
|
|
563
492
|
|
|
564
493
|
response = requests.post(
|
|
565
494
|
f"{BASE_URL}/wait",
|
|
@@ -670,17 +599,15 @@ class Simplex:
|
|
|
670
599
|
|
|
671
600
|
return filename
|
|
672
601
|
|
|
673
|
-
def get_network_response(self, url: str
|
|
602
|
+
def get_network_response(self, url: str):
|
|
674
603
|
print(f"Getting network response for {url}")
|
|
675
|
-
if not
|
|
604
|
+
if not self.session_id:
|
|
676
605
|
raise ValueError(f"Must call create_session before calling action get_network_response with url='{url}'")
|
|
677
606
|
|
|
678
|
-
data = {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
else:
|
|
683
|
-
data['session_id'] = self.session_id
|
|
607
|
+
data = {
|
|
608
|
+
'url': url,
|
|
609
|
+
'session_id': self.session_id
|
|
610
|
+
}
|
|
684
611
|
|
|
685
612
|
response = requests.post(
|
|
686
613
|
f"{BASE_URL}/get_network_response",
|
|
@@ -697,13 +624,12 @@ class Simplex:
|
|
|
697
624
|
else:
|
|
698
625
|
raise ValueError(f"Failed to get network response: {response.json()['error']}")
|
|
699
626
|
|
|
700
|
-
def restore_login_session(self, session_data: str
|
|
627
|
+
def restore_login_session(self, session_data: str):
|
|
701
628
|
"""
|
|
702
629
|
Restore a login session from either a file path or a JSON string.
|
|
703
630
|
|
|
704
631
|
Args:
|
|
705
632
|
session_data: Either a file path to JSON file or a JSON string
|
|
706
|
-
cdp_url: Optional CDP URL for remote debugging
|
|
707
633
|
"""
|
|
708
634
|
try:
|
|
709
635
|
# Try to parse as JSON string first
|
|
@@ -717,12 +643,9 @@ class Simplex:
|
|
|
717
643
|
raise ValueError(f"Failed to load session data. Input must be valid JSON string or path to JSON file. Error: {str(e)}")
|
|
718
644
|
|
|
719
645
|
data = {
|
|
720
|
-
'session_data': json.dumps(session_data_dict)
|
|
646
|
+
'session_data': json.dumps(session_data_dict),
|
|
647
|
+
'session_id': self.session_id
|
|
721
648
|
}
|
|
722
|
-
if cdp_url:
|
|
723
|
-
data['cdp_url'] = cdp_url
|
|
724
|
-
else:
|
|
725
|
-
data['session_id'] = self.session_id
|
|
726
649
|
|
|
727
650
|
response = requests.post(
|
|
728
651
|
f"{BASE_URL}/restore_login_session",
|
|
@@ -830,18 +753,16 @@ class Simplex:
|
|
|
830
753
|
|
|
831
754
|
return filename, response.content
|
|
832
755
|
|
|
833
|
-
def exists(self, element_description: str
|
|
756
|
+
def exists(self, element_description: str):
|
|
834
757
|
if not element_description or not element_description.strip():
|
|
835
758
|
raise ValueError("element_description cannot be empty")
|
|
836
|
-
if not
|
|
759
|
+
if not self.session_id:
|
|
837
760
|
raise ValueError(f"Must call create_session before calling action exists with element_description='{element_description}'")
|
|
838
761
|
|
|
839
|
-
data = {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
else:
|
|
844
|
-
data['session_id'] = self.session_id
|
|
762
|
+
data = {
|
|
763
|
+
'element_description': element_description,
|
|
764
|
+
'session_id': self.session_id
|
|
765
|
+
}
|
|
845
766
|
|
|
846
767
|
response = requests.post(
|
|
847
768
|
f"{BASE_URL}/exists",
|
|
@@ -857,4 +778,48 @@ class Simplex:
|
|
|
857
778
|
if response_json['succeeded']:
|
|
858
779
|
return response_json['exists'], response_json['reasoning']
|
|
859
780
|
else:
|
|
860
|
-
raise ValueError(f"Failed to check if element exists: {response_json['error']}")
|
|
781
|
+
raise ValueError(f"Failed to check if element exists: {response_json['error']}")
|
|
782
|
+
|
|
783
|
+
def capture_login_session(self):
|
|
784
|
+
data = {
|
|
785
|
+
'session_id': self.session_id
|
|
786
|
+
}
|
|
787
|
+
response = requests.post(
|
|
788
|
+
f"{BASE_URL}/capture_login_session",
|
|
789
|
+
headers={
|
|
790
|
+
'x-api-key': self.api_key
|
|
791
|
+
},
|
|
792
|
+
data=data
|
|
793
|
+
)
|
|
794
|
+
if 'succeeded' not in response.json():
|
|
795
|
+
raise ValueError(f"It looks like the capture_login_session action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
796
|
+
response_json = response.json()
|
|
797
|
+
if "storage_state" in response_json:
|
|
798
|
+
print("response keys: ", response_json['storage_state'].keys())
|
|
799
|
+
# print(response_json)
|
|
800
|
+
if response_json['succeeded']:
|
|
801
|
+
return response_json['storage_state']
|
|
802
|
+
else:
|
|
803
|
+
raise ValueError(f"Failed to capture login session: {response_json['error']}")
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
def get_page_url(self):
|
|
807
|
+
data = {
|
|
808
|
+
'session_id': self.session_id
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
response = requests.post(
|
|
812
|
+
f"{BASE_URL}/get_page_url",
|
|
813
|
+
headers={
|
|
814
|
+
'x-api-key': self.api_key
|
|
815
|
+
},
|
|
816
|
+
data=data
|
|
817
|
+
)
|
|
818
|
+
if 'succeeded' not in response.json():
|
|
819
|
+
raise ValueError(f"It looks like the get_page_url action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
820
|
+
response_json = response.json()
|
|
821
|
+
# print(response_json)
|
|
822
|
+
if response_json['succeeded']:
|
|
823
|
+
return response_json['url']
|
|
824
|
+
else:
|
|
825
|
+
raise ValueError(f"Failed to get page url: {response_json['error']}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: simplex
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.71
|
|
4
4
|
Summary: Official Python SDK for Simplex API
|
|
5
5
|
Home-page: https://simplex.sh
|
|
6
6
|
Author: Simplex Labs, Inc.
|
|
@@ -19,6 +19,16 @@ Requires-Dist: python-dotenv
|
|
|
19
19
|
Requires-Dist: click
|
|
20
20
|
Provides-Extra: playwright
|
|
21
21
|
Requires-Dist: rebrowser-playwright>=1.0.0; extra == "playwright"
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: description-content-type
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: provides-extra
|
|
29
|
+
Dynamic: requires-dist
|
|
30
|
+
Dynamic: requires-python
|
|
31
|
+
Dynamic: summary
|
|
22
32
|
|
|
23
33
|
# Simplex AI Python SDK
|
|
24
34
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|