simplex 1.2.37__py3-none-any.whl → 1.2.38__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 simplex might be problematic. Click here for more details.
- simplex/cli.py +1 -1
- simplex/simplex.py +39 -24
- {simplex-1.2.37.dist-info → simplex-1.2.38.dist-info}/METADATA +1 -1
- simplex-1.2.38.dist-info/RECORD +11 -0
- simplex-1.2.37.dist-info/RECORD +0 -11
- {simplex-1.2.37.dist-info → simplex-1.2.38.dist-info}/LICENSE +0 -0
- {simplex-1.2.37.dist-info → simplex-1.2.38.dist-info}/WHEEL +0 -0
- {simplex-1.2.37.dist-info → simplex-1.2.38.dist-info}/entry_points.txt +0 -0
- {simplex-1.2.37.dist-info → simplex-1.2.38.dist-info}/top_level.txt +0 -0
simplex/cli.py
CHANGED
|
@@ -64,7 +64,7 @@ def login(website, proxies):
|
|
|
64
64
|
|
|
65
65
|
animated_print(f"[SIMPLEX] Creating login session for {website}")
|
|
66
66
|
|
|
67
|
-
fileName = simplex.create_login_session(website
|
|
67
|
+
fileName = simplex.create_login_session(website)
|
|
68
68
|
|
|
69
69
|
if fileName:
|
|
70
70
|
animated_print(f"[SIMPLEX] Login session created and saved to {fileName}")
|
simplex/simplex.py
CHANGED
|
@@ -53,8 +53,6 @@ class Playwright:
|
|
|
53
53
|
return
|
|
54
54
|
else:
|
|
55
55
|
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
56
|
-
|
|
57
|
-
|
|
58
56
|
|
|
59
57
|
class Simplex:
|
|
60
58
|
def __init__(self, api_key: str):
|
|
@@ -83,13 +81,33 @@ class Simplex:
|
|
|
83
81
|
raise ValueError(f"Failed to close session: {response.json()['error']}")
|
|
84
82
|
|
|
85
83
|
def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[str] = None):
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
if session_data:
|
|
85
|
+
try:
|
|
86
|
+
# Try to parse as JSON string first
|
|
87
|
+
session_data_dict = json.loads(session_data)
|
|
88
|
+
except json.JSONDecodeError:
|
|
89
|
+
# If parsing fails, treat as file path
|
|
90
|
+
try:
|
|
91
|
+
with open(session_data, 'r') as f:
|
|
92
|
+
session_data_dict = json.load(f)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
raise ValueError(f"Failed to load session data. Input must be valid JSON string or path to JSON file. Error: {str(e)}")
|
|
95
|
+
print(session_data_dict)
|
|
96
|
+
response = requests.post(
|
|
97
|
+
f"{BASE_URL}/create_session",
|
|
98
|
+
headers={
|
|
99
|
+
'x-api-key': self.api_key
|
|
100
|
+
},
|
|
101
|
+
data={'proxies': proxies, 'session_data': json.dumps(session_data_dict)}
|
|
102
|
+
)
|
|
103
|
+
else:
|
|
104
|
+
response = requests.post(
|
|
105
|
+
f"{BASE_URL}/create_session",
|
|
106
|
+
headers={
|
|
107
|
+
'x-api-key': self.api_key
|
|
108
|
+
},
|
|
109
|
+
data={'proxies': proxies}
|
|
110
|
+
)
|
|
93
111
|
# Check for non-200 status code
|
|
94
112
|
if response.status_code != 200:
|
|
95
113
|
raise ValueError(f"Create session request failed with status code {response.status_code}: {response.text}")
|
|
@@ -293,12 +311,12 @@ class Simplex:
|
|
|
293
311
|
else:
|
|
294
312
|
data['session_id'] = self.session_id
|
|
295
313
|
|
|
296
|
-
response = requests.
|
|
314
|
+
response = requests.post(
|
|
297
315
|
f"{BASE_URL}/extract-text",
|
|
298
316
|
headers={
|
|
299
317
|
'x-api-key': self.api_key
|
|
300
318
|
},
|
|
301
|
-
|
|
319
|
+
data=data
|
|
302
320
|
)
|
|
303
321
|
if 'succeeded' not in response.json():
|
|
304
322
|
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?")
|
|
@@ -382,7 +400,7 @@ class Simplex:
|
|
|
382
400
|
else:
|
|
383
401
|
raise ValueError(f"Failed to wait: {response.json()['error']}")
|
|
384
402
|
|
|
385
|
-
def create_login_session(self, url: str, save_directory: Optional[str] = None
|
|
403
|
+
def create_login_session(self, url: str, save_directory: Optional[str] = None):
|
|
386
404
|
def get_website_name(url: str) -> str:
|
|
387
405
|
"""Extract website name from URL"""
|
|
388
406
|
from urllib.parse import urlparse
|
|
@@ -393,8 +411,7 @@ class Simplex:
|
|
|
393
411
|
return netloc.replace(".", "_")
|
|
394
412
|
|
|
395
413
|
with sync_playwright() as p:
|
|
396
|
-
browser = p.chromium.
|
|
397
|
-
user_data_dir="",
|
|
414
|
+
browser = p.chromium.launch(
|
|
398
415
|
channel="chrome",
|
|
399
416
|
headless=False,
|
|
400
417
|
args=[
|
|
@@ -404,16 +421,13 @@ class Simplex:
|
|
|
404
421
|
ignore_default_args=['--enable-automation']
|
|
405
422
|
)
|
|
406
423
|
|
|
407
|
-
#
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
# Create main page for login
|
|
412
|
-
main_page = browser.new_page()
|
|
424
|
+
# Create context and pages
|
|
425
|
+
context = browser.new_context()
|
|
426
|
+
main_page = context.new_page()
|
|
413
427
|
main_page.goto(url)
|
|
414
428
|
|
|
415
|
-
# Create control page
|
|
416
|
-
control_page =
|
|
429
|
+
# Create control page in same context
|
|
430
|
+
control_page = context.new_page()
|
|
417
431
|
control_page.set_content("""
|
|
418
432
|
<html>
|
|
419
433
|
<body style="display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f5f5f5;">
|
|
@@ -443,7 +457,8 @@ class Simplex:
|
|
|
443
457
|
}
|
|
444
458
|
""")
|
|
445
459
|
|
|
446
|
-
|
|
460
|
+
# Use context.storage_state() instead of browser.storage_state()
|
|
461
|
+
storage = context.storage_state()
|
|
447
462
|
if save_directory:
|
|
448
463
|
filename = os.path.join(save_directory, get_website_name(url) + "_session_data.json")
|
|
449
464
|
else:
|
|
@@ -576,4 +591,4 @@ class Simplex:
|
|
|
576
591
|
if response_json['succeeded']:
|
|
577
592
|
return response_json['exists'], response_json['reasoning']
|
|
578
593
|
else:
|
|
579
|
-
raise ValueError(f"Failed to check if element exists: {response_json['error']}")
|
|
594
|
+
raise ValueError(f"Failed to check if element exists: {response_json['error']}")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
+
simplex/cli.py,sha256=FcnZtxstZQS8bOshgT_RBSbEfCY2UkDU7FGBLZNmwAY,2307
|
|
3
|
+
simplex/simplex.py,sha256=PWBkmTUJheeUSrPiNZN3g84GxQPECOKbB80ST-pWj4c,22621
|
|
4
|
+
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
+
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
+
simplex-1.2.38.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
+
simplex-1.2.38.dist-info/METADATA,sha256=u01fStZJsmwy_LIEn_XVbv0Ywec362PgPO3uhox2aXU,964
|
|
8
|
+
simplex-1.2.38.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
simplex-1.2.38.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
+
simplex-1.2.38.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
+
simplex-1.2.38.dist-info/RECORD,,
|
simplex-1.2.37.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
-
simplex/cli.py,sha256=DxZMiX-mqhy1cWJhf75YQs49GfZediueFuxyEhBFpLk,2324
|
|
3
|
-
simplex/simplex.py,sha256=8JcmId0SQ32GamEAQTWQlafQpa8oswmXM6E3Plfn-9k,21853
|
|
4
|
-
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
-
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
-
simplex-1.2.37.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
-
simplex-1.2.37.dist-info/METADATA,sha256=DTpFDlzDtuQsYAjR-2I4CmGUlObOq3MD814DTqCAQSs,964
|
|
8
|
-
simplex-1.2.37.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
simplex-1.2.37.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
-
simplex-1.2.37.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
-
simplex-1.2.37.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|