simplex 1.2.70__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.70 → simplex-1.2.71}/PKG-INFO +1 -1
- {simplex-1.2.70 → simplex-1.2.71}/setup.py +1 -1
- {simplex-1.2.70 → simplex-1.2.71}/simplex/simplex.py +149 -183
- {simplex-1.2.70 → simplex-1.2.71}/simplex.egg-info/PKG-INFO +1 -1
- {simplex-1.2.70 → simplex-1.2.71}/LICENSE +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/README.md +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/setup.cfg +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex/__init__.py +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex/cli.py +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex/deploy/__init__.py +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex/deploy/push.py +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex.egg-info/SOURCES.txt +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex.egg-info/dependency_links.txt +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex.egg-info/entry_points.txt +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex.egg-info/requires.txt +0 -0
- {simplex-1.2.70 → simplex-1.2.71}/simplex.egg-info/top_level.txt +0 -0
|
@@ -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",
|
|
@@ -199,20 +195,17 @@ class Simplex:
|
|
|
199
195
|
return
|
|
200
196
|
else:
|
|
201
197
|
raise ValueError(f"Failed to goto url: {response.json()['error']}")
|
|
202
|
-
|
|
203
198
|
|
|
204
|
-
def click(self, element_description: str
|
|
199
|
+
def click(self, element_description: str):
|
|
205
200
|
if not element_description or not element_description.strip():
|
|
206
201
|
raise ValueError("element_description cannot be empty")
|
|
207
|
-
if not
|
|
202
|
+
if not self.session_id:
|
|
208
203
|
raise ValueError(f"Must call create_session before calling action click with element_description='{element_description}'")
|
|
209
204
|
|
|
210
|
-
data = {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
else:
|
|
215
|
-
data['session_id'] = self.session_id
|
|
205
|
+
data = {
|
|
206
|
+
'element_description': element_description,
|
|
207
|
+
'session_id': self.session_id
|
|
208
|
+
}
|
|
216
209
|
|
|
217
210
|
response = requests.post(
|
|
218
211
|
f"{BASE_URL}/click",
|
|
@@ -228,19 +221,16 @@ class Simplex:
|
|
|
228
221
|
else:
|
|
229
222
|
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
230
223
|
|
|
231
|
-
def select_dropdown_option(self, element_description: str
|
|
224
|
+
def select_dropdown_option(self, element_description: str):
|
|
232
225
|
if not element_description or not element_description.strip():
|
|
233
226
|
raise ValueError("element_description cannot be empty")
|
|
234
|
-
if not
|
|
227
|
+
if not self.session_id:
|
|
235
228
|
raise ValueError(f"Must call create_session before calling action select_from_dropdown with element_description='{element_description}'")
|
|
236
229
|
|
|
237
|
-
data = {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
else:
|
|
242
|
-
data['session_id'] = self.session_id
|
|
243
|
-
|
|
230
|
+
data = {
|
|
231
|
+
'element_description': element_description,
|
|
232
|
+
'session_id': self.session_id
|
|
233
|
+
}
|
|
244
234
|
|
|
245
235
|
response = requests.post(
|
|
246
236
|
f"{BASE_URL}/select_dropdown_option",
|
|
@@ -257,19 +247,16 @@ class Simplex:
|
|
|
257
247
|
else:
|
|
258
248
|
raise ValueError(f"Failed to select dropdown option: {response.json()['error']}")
|
|
259
249
|
|
|
260
|
-
|
|
261
|
-
def scroll_to_element(self, element_description: str, cdp_url: str = None):
|
|
250
|
+
def scroll_to_element(self, element_description: str):
|
|
262
251
|
if not element_description or not element_description.strip():
|
|
263
252
|
raise ValueError("element_description cannot be empty")
|
|
264
|
-
if not
|
|
253
|
+
if not self.session_id:
|
|
265
254
|
raise ValueError(f"Must call create_session before calling action scroll_to_element with element_description='{element_description}'")
|
|
266
255
|
|
|
267
|
-
data = {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
else:
|
|
272
|
-
data['session_id'] = self.session_id
|
|
256
|
+
data = {
|
|
257
|
+
'element_description': element_description,
|
|
258
|
+
'session_id': self.session_id
|
|
259
|
+
}
|
|
273
260
|
|
|
274
261
|
response = requests.post(
|
|
275
262
|
f"{BASE_URL}/scroll_to_element",
|
|
@@ -285,21 +272,17 @@ class Simplex:
|
|
|
285
272
|
return
|
|
286
273
|
else:
|
|
287
274
|
raise ValueError(f"Failed to scroll element into view: {response.json()['error']}")
|
|
288
|
-
|
|
289
|
-
|
|
290
275
|
|
|
291
|
-
def hover(self, element_description: str
|
|
276
|
+
def hover(self, element_description: str):
|
|
292
277
|
if not element_description or not element_description.strip():
|
|
293
278
|
raise ValueError("element_description cannot be empty")
|
|
294
|
-
if not
|
|
279
|
+
if not self.session_id:
|
|
295
280
|
raise ValueError(f"Must call create_session before calling action hover with element_description='{element_description}'")
|
|
296
281
|
|
|
297
|
-
data = {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
else:
|
|
302
|
-
data['session_id'] = self.session_id
|
|
282
|
+
data = {
|
|
283
|
+
'element_description': element_description,
|
|
284
|
+
'session_id': self.session_id
|
|
285
|
+
}
|
|
303
286
|
|
|
304
287
|
response = requests.post(
|
|
305
288
|
f"{BASE_URL}/hover",
|
|
@@ -316,18 +299,16 @@ class Simplex:
|
|
|
316
299
|
else:
|
|
317
300
|
raise ValueError(f"Failed to hover: {response.json()['error']}")
|
|
318
301
|
|
|
319
|
-
def type(self, text: str
|
|
302
|
+
def type(self, text: str):
|
|
320
303
|
if not text or not text.strip():
|
|
321
304
|
raise ValueError("text cannot be empty")
|
|
322
|
-
if not
|
|
305
|
+
if not self.session_id:
|
|
323
306
|
raise ValueError(f"Must call create_session before calling action type with text='{text}'")
|
|
324
307
|
|
|
325
|
-
data = {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
else:
|
|
330
|
-
data['session_id'] = self.session_id
|
|
308
|
+
data = {
|
|
309
|
+
'text': text,
|
|
310
|
+
'session_id': self.session_id
|
|
311
|
+
}
|
|
331
312
|
|
|
332
313
|
response = requests.post(
|
|
333
314
|
f"{BASE_URL}/type",
|
|
@@ -339,19 +320,15 @@ class Simplex:
|
|
|
339
320
|
if response.json()['succeeded']:
|
|
340
321
|
return
|
|
341
322
|
else:
|
|
342
|
-
raise ValueError(f"Failed to type text: {response.json()['error']}")
|
|
343
|
-
|
|
323
|
+
raise ValueError(f"Failed to type text: {response.json()['error']}")
|
|
344
324
|
|
|
345
|
-
def reload(self
|
|
346
|
-
if not
|
|
325
|
+
def reload(self):
|
|
326
|
+
if not self.session_id:
|
|
347
327
|
raise ValueError("Must call create_session before calling action reload")
|
|
348
328
|
|
|
349
|
-
data = {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
data['cdp_url'] = cdp_url
|
|
353
|
-
else:
|
|
354
|
-
data['session_id'] = self.session_id
|
|
329
|
+
data = {
|
|
330
|
+
'session_id': self.session_id
|
|
331
|
+
}
|
|
355
332
|
|
|
356
333
|
response = requests.post(
|
|
357
334
|
f"{BASE_URL}/reload",
|
|
@@ -367,16 +344,13 @@ class Simplex:
|
|
|
367
344
|
else:
|
|
368
345
|
raise ValueError(f"Failed to reload: {response.json()['error']}")
|
|
369
346
|
|
|
370
|
-
def press_enter(self
|
|
371
|
-
if not
|
|
347
|
+
def press_enter(self):
|
|
348
|
+
if not self.session_id:
|
|
372
349
|
raise ValueError("Must call create_session before calling action press_enter")
|
|
373
350
|
|
|
374
|
-
data = {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
data['cdp_url'] = cdp_url
|
|
378
|
-
else:
|
|
379
|
-
data['session_id'] = self.session_id
|
|
351
|
+
data = {
|
|
352
|
+
'session_id': self.session_id
|
|
353
|
+
}
|
|
380
354
|
|
|
381
355
|
response = requests.post(
|
|
382
356
|
f"{BASE_URL}/press_enter",
|
|
@@ -392,16 +366,13 @@ class Simplex:
|
|
|
392
366
|
else:
|
|
393
367
|
raise ValueError(f"Failed to press enter: {response.json()['error']}")
|
|
394
368
|
|
|
395
|
-
def press_tab(self
|
|
396
|
-
if not
|
|
369
|
+
def press_tab(self):
|
|
370
|
+
if not self.session_id:
|
|
397
371
|
raise ValueError("Must call create_session before calling action press_tab")
|
|
398
372
|
|
|
399
|
-
data = {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
data['cdp_url'] = cdp_url
|
|
403
|
-
else:
|
|
404
|
-
data['session_id'] = self.session_id
|
|
373
|
+
data = {
|
|
374
|
+
'session_id': self.session_id
|
|
375
|
+
}
|
|
405
376
|
|
|
406
377
|
response = requests.post(
|
|
407
378
|
f"{BASE_URL}/press_tab",
|
|
@@ -417,16 +388,13 @@ class Simplex:
|
|
|
417
388
|
else:
|
|
418
389
|
raise ValueError(f"Failed to press tab: {response.json()['error']}")
|
|
419
390
|
|
|
420
|
-
def delete_text(self
|
|
421
|
-
if not
|
|
391
|
+
def delete_text(self):
|
|
392
|
+
if not self.session_id:
|
|
422
393
|
raise ValueError("Must call create_session before calling action delete_text")
|
|
423
394
|
|
|
424
|
-
data = {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
data['cdp_url'] = cdp_url
|
|
428
|
-
else:
|
|
429
|
-
data['session_id'] = self.session_id
|
|
395
|
+
data = {
|
|
396
|
+
'session_id': self.session_id
|
|
397
|
+
}
|
|
430
398
|
|
|
431
399
|
response = requests.post(
|
|
432
400
|
f"{BASE_URL}/delete_text",
|
|
@@ -442,45 +410,38 @@ class Simplex:
|
|
|
442
410
|
else:
|
|
443
411
|
raise ValueError(f"Failed to delete text: {response.json()['error']}")
|
|
444
412
|
|
|
445
|
-
def
|
|
446
|
-
if not
|
|
447
|
-
raise ValueError("
|
|
448
|
-
if not cdp_url and not self.session_id:
|
|
449
|
-
raise ValueError(f"Must call create_session before calling action extract_bbox with element_description='{element_description}'")
|
|
450
|
-
|
|
451
|
-
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")
|
|
452
416
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
data['session_id'] = self.session_id
|
|
417
|
+
data = {
|
|
418
|
+
'session_id': self.session_id
|
|
419
|
+
}
|
|
457
420
|
|
|
458
|
-
response = requests.
|
|
459
|
-
f"{BASE_URL}/
|
|
421
|
+
response = requests.post(
|
|
422
|
+
f"{BASE_URL}/bot_tests",
|
|
460
423
|
headers={
|
|
461
424
|
'x-api-key': self.api_key
|
|
462
425
|
},
|
|
463
|
-
|
|
426
|
+
data=data
|
|
464
427
|
)
|
|
465
428
|
if 'succeeded' not in response.json():
|
|
466
|
-
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?")
|
|
467
430
|
if response.json()['succeeded']:
|
|
468
|
-
return
|
|
431
|
+
return
|
|
469
432
|
else:
|
|
470
|
-
raise ValueError(f"Failed to
|
|
433
|
+
raise ValueError(f"Failed to run bot tests: {response.json()['error']}")
|
|
471
434
|
|
|
472
|
-
def extract_text(self, element_description: str
|
|
435
|
+
def extract_text(self, element_description: str):
|
|
473
436
|
if not element_description or not element_description.strip():
|
|
474
437
|
raise ValueError("element_description cannot be empty")
|
|
475
|
-
if not
|
|
438
|
+
if not self.session_id:
|
|
476
439
|
raise ValueError(f"Must call create_session before calling action extract_text with element_description='{element_description}'")
|
|
477
440
|
|
|
478
|
-
data = {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
else:
|
|
483
|
-
data['session_id'] = self.session_id
|
|
441
|
+
data = {
|
|
442
|
+
'element_description': element_description,
|
|
443
|
+
'session_id': self.session_id
|
|
444
|
+
}
|
|
484
445
|
|
|
485
446
|
response = requests.post(
|
|
486
447
|
f"{BASE_URL}/extract-text",
|
|
@@ -492,48 +453,19 @@ class Simplex:
|
|
|
492
453
|
response_json = response.json()
|
|
493
454
|
if 'succeeded' not in response_json:
|
|
494
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?")
|
|
495
|
-
if "succeeded"
|
|
456
|
+
if response_json["succeeded"]:
|
|
496
457
|
return response_json["text"]
|
|
497
458
|
else:
|
|
498
459
|
raise ValueError(f"Failed to extract text: {response_json['error']}")
|
|
499
460
|
|
|
500
|
-
def
|
|
501
|
-
if not
|
|
502
|
-
raise ValueError("element_description cannot be empty")
|
|
503
|
-
if not cdp_url and not self.session_id:
|
|
504
|
-
raise ValueError(f"Must call create_session before calling action extract_image with element_description='{element_description}'")
|
|
505
|
-
|
|
506
|
-
data = {'element_description': element_description}
|
|
507
|
-
|
|
508
|
-
if cdp_url:
|
|
509
|
-
data['cdp_url'] = cdp_url
|
|
510
|
-
else:
|
|
511
|
-
data['session_id'] = self.session_id
|
|
512
|
-
|
|
513
|
-
response = requests.get(
|
|
514
|
-
f"{BASE_URL}/extract-image",
|
|
515
|
-
headers={
|
|
516
|
-
'x-api-key': self.api_key
|
|
517
|
-
},
|
|
518
|
-
params=data
|
|
519
|
-
)
|
|
520
|
-
if 'succeeded' not in response.json():
|
|
521
|
-
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?")
|
|
522
|
-
if response.json()['succeeded']:
|
|
523
|
-
return response.json()["image"]
|
|
524
|
-
else:
|
|
525
|
-
raise ValueError(f"Failed to extract image: {response.json()['error']}")
|
|
526
|
-
|
|
527
|
-
def scroll(self, pixels: float, cdp_url: str = None):
|
|
528
|
-
if not cdp_url and not self.session_id:
|
|
461
|
+
def scroll(self, pixels: float):
|
|
462
|
+
if not self.session_id:
|
|
529
463
|
raise ValueError(f"Must call create_session before calling action scroll with pixels={pixels}")
|
|
530
464
|
|
|
531
|
-
data = {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
else:
|
|
536
|
-
data['session_id'] = self.session_id
|
|
465
|
+
data = {
|
|
466
|
+
'pixels': pixels,
|
|
467
|
+
'session_id': self.session_id
|
|
468
|
+
}
|
|
537
469
|
|
|
538
470
|
response = requests.post(
|
|
539
471
|
f"{BASE_URL}/scroll",
|
|
@@ -549,16 +481,14 @@ class Simplex:
|
|
|
549
481
|
else:
|
|
550
482
|
raise ValueError(f"Failed to scroll: {response.json()['error']}")
|
|
551
483
|
|
|
552
|
-
def wait(self, milliseconds: int
|
|
553
|
-
if not
|
|
484
|
+
def wait(self, milliseconds: int):
|
|
485
|
+
if not self.session_id:
|
|
554
486
|
raise ValueError(f"Must call create_session before calling action wait with milliseconds={milliseconds}")
|
|
555
487
|
|
|
556
|
-
data = {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
else:
|
|
561
|
-
data['session_id'] = self.session_id
|
|
488
|
+
data = {
|
|
489
|
+
'milliseconds': milliseconds,
|
|
490
|
+
'session_id': self.session_id
|
|
491
|
+
}
|
|
562
492
|
|
|
563
493
|
response = requests.post(
|
|
564
494
|
f"{BASE_URL}/wait",
|
|
@@ -669,17 +599,15 @@ class Simplex:
|
|
|
669
599
|
|
|
670
600
|
return filename
|
|
671
601
|
|
|
672
|
-
def get_network_response(self, url: str
|
|
602
|
+
def get_network_response(self, url: str):
|
|
673
603
|
print(f"Getting network response for {url}")
|
|
674
|
-
if not
|
|
604
|
+
if not self.session_id:
|
|
675
605
|
raise ValueError(f"Must call create_session before calling action get_network_response with url='{url}'")
|
|
676
606
|
|
|
677
|
-
data = {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
else:
|
|
682
|
-
data['session_id'] = self.session_id
|
|
607
|
+
data = {
|
|
608
|
+
'url': url,
|
|
609
|
+
'session_id': self.session_id
|
|
610
|
+
}
|
|
683
611
|
|
|
684
612
|
response = requests.post(
|
|
685
613
|
f"{BASE_URL}/get_network_response",
|
|
@@ -696,13 +624,12 @@ class Simplex:
|
|
|
696
624
|
else:
|
|
697
625
|
raise ValueError(f"Failed to get network response: {response.json()['error']}")
|
|
698
626
|
|
|
699
|
-
def restore_login_session(self, session_data: str
|
|
627
|
+
def restore_login_session(self, session_data: str):
|
|
700
628
|
"""
|
|
701
629
|
Restore a login session from either a file path or a JSON string.
|
|
702
630
|
|
|
703
631
|
Args:
|
|
704
632
|
session_data: Either a file path to JSON file or a JSON string
|
|
705
|
-
cdp_url: Optional CDP URL for remote debugging
|
|
706
633
|
"""
|
|
707
634
|
try:
|
|
708
635
|
# Try to parse as JSON string first
|
|
@@ -716,12 +643,9 @@ class Simplex:
|
|
|
716
643
|
raise ValueError(f"Failed to load session data. Input must be valid JSON string or path to JSON file. Error: {str(e)}")
|
|
717
644
|
|
|
718
645
|
data = {
|
|
719
|
-
'session_data': json.dumps(session_data_dict)
|
|
646
|
+
'session_data': json.dumps(session_data_dict),
|
|
647
|
+
'session_id': self.session_id
|
|
720
648
|
}
|
|
721
|
-
if cdp_url:
|
|
722
|
-
data['cdp_url'] = cdp_url
|
|
723
|
-
else:
|
|
724
|
-
data['session_id'] = self.session_id
|
|
725
649
|
|
|
726
650
|
response = requests.post(
|
|
727
651
|
f"{BASE_URL}/restore_login_session",
|
|
@@ -829,18 +753,16 @@ class Simplex:
|
|
|
829
753
|
|
|
830
754
|
return filename, response.content
|
|
831
755
|
|
|
832
|
-
def exists(self, element_description: str
|
|
756
|
+
def exists(self, element_description: str):
|
|
833
757
|
if not element_description or not element_description.strip():
|
|
834
758
|
raise ValueError("element_description cannot be empty")
|
|
835
|
-
if not
|
|
759
|
+
if not self.session_id:
|
|
836
760
|
raise ValueError(f"Must call create_session before calling action exists with element_description='{element_description}'")
|
|
837
761
|
|
|
838
|
-
data = {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
else:
|
|
843
|
-
data['session_id'] = self.session_id
|
|
762
|
+
data = {
|
|
763
|
+
'element_description': element_description,
|
|
764
|
+
'session_id': self.session_id
|
|
765
|
+
}
|
|
844
766
|
|
|
845
767
|
response = requests.post(
|
|
846
768
|
f"{BASE_URL}/exists",
|
|
@@ -856,4 +778,48 @@ class Simplex:
|
|
|
856
778
|
if response_json['succeeded']:
|
|
857
779
|
return response_json['exists'], response_json['reasoning']
|
|
858
780
|
else:
|
|
859
|
-
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']}")
|
|
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
|