simplex 1.2.32__tar.gz → 1.2.34__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.32 → simplex-1.2.34}/PKG-INFO +2 -11
- {simplex-1.2.32 → simplex-1.2.34}/setup.py +1 -1
- {simplex-1.2.32 → simplex-1.2.34}/simplex/simplex.py +69 -6
- {simplex-1.2.32 → simplex-1.2.34}/simplex.egg-info/PKG-INFO +2 -11
- simplex-1.2.34/tests/test.py +22 -0
- simplex-1.2.32/tests/test.py +0 -41
- {simplex-1.2.32 → simplex-1.2.34}/LICENSE +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/README.md +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/pyproject.toml +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/setup.cfg +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex/__init__.py +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex/cli.py +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex/deploy/__init__.py +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex/deploy/push.py +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex.egg-info/SOURCES.txt +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex.egg-info/dependency_links.txt +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex.egg-info/entry_points.txt +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex.egg-info/requires.txt +0 -0
- {simplex-1.2.32 → simplex-1.2.34}/simplex.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: simplex
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.34
|
|
4
4
|
Summary: Official Python SDK for Simplex API
|
|
5
5
|
Home-page: https://simplex.sh
|
|
6
6
|
Author: Simplex Labs, Inc.
|
|
@@ -17,15 +17,6 @@ Requires-Dist: colorama
|
|
|
17
17
|
Requires-Dist: requests
|
|
18
18
|
Requires-Dist: python-dotenv
|
|
19
19
|
Requires-Dist: click
|
|
20
|
-
Dynamic: author
|
|
21
|
-
Dynamic: author-email
|
|
22
|
-
Dynamic: classifier
|
|
23
|
-
Dynamic: description
|
|
24
|
-
Dynamic: description-content-type
|
|
25
|
-
Dynamic: home-page
|
|
26
|
-
Dynamic: requires-dist
|
|
27
|
-
Dynamic: requires-python
|
|
28
|
-
Dynamic: summary
|
|
29
20
|
|
|
30
21
|
# Simplex AI Python SDK
|
|
31
22
|
|
|
@@ -5,12 +5,63 @@ BASE_URL = "https://api.simplex.sh"
|
|
|
5
5
|
|
|
6
6
|
import json
|
|
7
7
|
|
|
8
|
+
class Playwright:
|
|
9
|
+
def __init__(self, simplex_instance):
|
|
10
|
+
self.simplex = simplex_instance
|
|
11
|
+
|
|
12
|
+
def click(self, locator: str, locator_type: str, exact: Optional[bool] = False,
|
|
13
|
+
element_index: Optional[str] = None, nth_index: Optional[int] = None,
|
|
14
|
+
locator_options: Optional[dict] = None):
|
|
15
|
+
|
|
16
|
+
if element_index and element_index not in ["first", "last", "nth"]:
|
|
17
|
+
raise ValueError("element_index must be 'first', 'last', or 'nth'")
|
|
18
|
+
|
|
19
|
+
if element_index=="nth" and not nth_index:
|
|
20
|
+
raise ValueError("nth_index is required when element_index is 'nth'")
|
|
21
|
+
|
|
22
|
+
data = {
|
|
23
|
+
'session_id': self.simplex.session_id,
|
|
24
|
+
'locator': locator,
|
|
25
|
+
'locator_type': locator_type,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if element_index:
|
|
29
|
+
data['element_index'] = element_index
|
|
30
|
+
data['nth_index'] = nth_index
|
|
31
|
+
|
|
32
|
+
if exact:
|
|
33
|
+
data['exact'] = exact
|
|
34
|
+
|
|
35
|
+
if locator_options:
|
|
36
|
+
data['locator_options'] = json.dumps(locator_options)
|
|
37
|
+
|
|
38
|
+
response = requests.post(
|
|
39
|
+
f"{BASE_URL}/playwright/click",
|
|
40
|
+
headers={
|
|
41
|
+
'x-api-key': self.simplex.api_key
|
|
42
|
+
},
|
|
43
|
+
data=data
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if 'succeeded' not in response.json():
|
|
47
|
+
print(response.json())
|
|
48
|
+
raise ValueError(f"It looks like the click action with playwright failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
49
|
+
|
|
50
|
+
if response.json()["succeeded"]:
|
|
51
|
+
return
|
|
52
|
+
else:
|
|
53
|
+
raise ValueError(f"Failed to click element: {response.json()['error']}")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
8
57
|
class Simplex:
|
|
9
58
|
def __init__(self, api_key: str):
|
|
10
59
|
self.api_key = api_key
|
|
11
60
|
self.session_id = None
|
|
12
61
|
atexit.register(self.close_session)
|
|
13
62
|
|
|
63
|
+
self.playwright = Playwright(self)
|
|
64
|
+
|
|
14
65
|
def close_session(self):
|
|
15
66
|
if not self.session_id:
|
|
16
67
|
return
|
|
@@ -344,15 +395,27 @@ class Simplex:
|
|
|
344
395
|
else:
|
|
345
396
|
raise ValueError(f"Failed to create login session: {response.json()['error']}")
|
|
346
397
|
|
|
347
|
-
def restore_login_session(self,
|
|
348
|
-
|
|
398
|
+
def restore_login_session(self, session_data: str, cdp_url: str = None):
|
|
399
|
+
"""
|
|
400
|
+
Restore a login session from either a file path or a JSON string.
|
|
349
401
|
|
|
350
|
-
|
|
351
|
-
session_data
|
|
402
|
+
Args:
|
|
403
|
+
session_data: Either a file path to JSON file or a JSON string
|
|
404
|
+
cdp_url: Optional CDP URL for remote debugging
|
|
405
|
+
"""
|
|
406
|
+
try:
|
|
407
|
+
# Try to parse as JSON string first
|
|
408
|
+
session_data_dict = json.loads(session_data)
|
|
409
|
+
except json.JSONDecodeError:
|
|
410
|
+
# If parsing fails, treat as file path
|
|
411
|
+
try:
|
|
412
|
+
with open(session_data, 'r') as f:
|
|
413
|
+
session_data_dict = json.load(f)
|
|
414
|
+
except Exception as e:
|
|
415
|
+
raise ValueError(f"Failed to load session data. Input must be valid JSON string or path to JSON file. Error: {str(e)}")
|
|
352
416
|
|
|
353
|
-
# Serialize the data to JSON string
|
|
354
417
|
data = {
|
|
355
|
-
'session_data': json.dumps(
|
|
418
|
+
'session_data': json.dumps(session_data_dict)
|
|
356
419
|
}
|
|
357
420
|
if cdp_url:
|
|
358
421
|
data['cdp_url'] = cdp_url
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: simplex
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.34
|
|
4
4
|
Summary: Official Python SDK for Simplex API
|
|
5
5
|
Home-page: https://simplex.sh
|
|
6
6
|
Author: Simplex Labs, Inc.
|
|
@@ -17,15 +17,6 @@ Requires-Dist: colorama
|
|
|
17
17
|
Requires-Dist: requests
|
|
18
18
|
Requires-Dist: python-dotenv
|
|
19
19
|
Requires-Dist: click
|
|
20
|
-
Dynamic: author
|
|
21
|
-
Dynamic: author-email
|
|
22
|
-
Dynamic: classifier
|
|
23
|
-
Dynamic: description
|
|
24
|
-
Dynamic: description-content-type
|
|
25
|
-
Dynamic: home-page
|
|
26
|
-
Dynamic: requires-dist
|
|
27
|
-
Dynamic: requires-python
|
|
28
|
-
Dynamic: summary
|
|
29
20
|
|
|
30
21
|
# Simplex AI Python SDK
|
|
31
22
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from simplex import Simplex
|
|
2
|
+
import os
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
load_dotenv()
|
|
7
|
+
|
|
8
|
+
def login():
|
|
9
|
+
simplex = Simplex(api_key=os.getenv("SIMPLEX_API_KEY"))
|
|
10
|
+
simplex.create_session(proxies=False)
|
|
11
|
+
simplex.goto("https://dropbox.com")
|
|
12
|
+
|
|
13
|
+
with open("dropbox_com_session_data.json", "r") as f:
|
|
14
|
+
session_data = f.read()
|
|
15
|
+
simplex.restore_login_session(session_data=session_data)
|
|
16
|
+
|
|
17
|
+
simplex.wait(1000)
|
|
18
|
+
print(simplex.extract_text("footer texts"))
|
|
19
|
+
print(simplex.wait(5000))
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
login()
|
simplex-1.2.32/tests/test.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from simplex import Simplex
|
|
2
|
-
import os
|
|
3
|
-
from dotenv import load_dotenv
|
|
4
|
-
import time
|
|
5
|
-
|
|
6
|
-
load_dotenv()
|
|
7
|
-
|
|
8
|
-
def login():
|
|
9
|
-
simplex = Simplex(api_key=os.getenv("SIMPLEX_API_KEY"))
|
|
10
|
-
simplex.create_session(proxies=False)
|
|
11
|
-
simplex.goto("https://github.com/login")
|
|
12
|
-
simplex.wait(1000)
|
|
13
|
-
# simplex.goto("https://browser-tests-alpha.vercel.app/api/upload-test")
|
|
14
|
-
# simplex.wait(10)
|
|
15
|
-
# print(simplex.create_login_session("https://auth.leboncoin.fr/login/"))
|
|
16
|
-
print(simplex.extract_text("footer texts"))
|
|
17
|
-
print(simplex.wait(5000))
|
|
18
|
-
|
|
19
|
-
# simplex.goto("https://dropbox.com/")
|
|
20
|
-
# simplex.click("Upload or drop")
|
|
21
|
-
# simplex.click_and_upload("File", "ycombinator.svg")
|
|
22
|
-
# print(simplex.exists("Download button"))
|
|
23
|
-
# files = simplex.click_and_download("Download File")
|
|
24
|
-
# import base64
|
|
25
|
-
# print(files)
|
|
26
|
-
# # Decode base64 string to bytes
|
|
27
|
-
# file_bytes = base64.b64decode(files['b64'])
|
|
28
|
-
|
|
29
|
-
# # Create downloads directory if it doesn't exist
|
|
30
|
-
# os.makedirs('downloads', exist_ok=True)
|
|
31
|
-
|
|
32
|
-
# # Write bytes to file
|
|
33
|
-
# with open(os.path.join('downloads', files['filename']), 'wb') as f:
|
|
34
|
-
# f.write(file_bytes)
|
|
35
|
-
|
|
36
|
-
# simplex.goto("https://file-examples.com/wp-content/storage/2018/04/file_example_AVI_480_750kB.avi")
|
|
37
|
-
# print(simplex.restore_login_session("zillow_com_session_data.json"))
|
|
38
|
-
# simplex.goto("https://zillow.com")
|
|
39
|
-
|
|
40
|
-
if __name__ == "__main__":
|
|
41
|
-
login()
|
|
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
|
|
File without changes
|