simplex 1.2.38__tar.gz → 1.2.42__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.38 → simplex-1.2.42}/PKG-INFO +1 -1
- {simplex-1.2.38 → simplex-1.2.42}/setup.py +1 -1
- {simplex-1.2.38 → simplex-1.2.42}/simplex/cli.py +2 -3
- {simplex-1.2.38 → simplex-1.2.42}/simplex/simplex.py +24 -13
- {simplex-1.2.38 → simplex-1.2.42}/simplex.egg-info/PKG-INFO +1 -1
- simplex-1.2.42/tests/test.py +23 -0
- simplex-1.2.38/tests/test.py +0 -75
- {simplex-1.2.38 → simplex-1.2.42}/LICENSE +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/README.md +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/pyproject.toml +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/setup.cfg +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex/__init__.py +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex/deploy/__init__.py +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex/deploy/push.py +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex.egg-info/SOURCES.txt +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex.egg-info/dependency_links.txt +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex.egg-info/entry_points.txt +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex.egg-info/requires.txt +0 -0
- {simplex-1.2.38 → simplex-1.2.42}/simplex.egg-info/top_level.txt +0 -0
|
@@ -47,9 +47,8 @@ def run(directory):
|
|
|
47
47
|
|
|
48
48
|
@cli.command()
|
|
49
49
|
@click.argument('website')
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"""Capture login session for a website"""
|
|
50
|
+
def login(website):
|
|
51
|
+
"""Capture login session for a website. See https://simplex.sh/docs/getting-started for more information."""
|
|
53
52
|
try:
|
|
54
53
|
# Initialize Simplex with API key from environment
|
|
55
54
|
api_key = os.getenv("SIMPLEX_API_KEY")
|
|
@@ -59,10 +59,15 @@ class Simplex:
|
|
|
59
59
|
self.api_key = api_key
|
|
60
60
|
self.session_id = None
|
|
61
61
|
atexit.register(self.close_session)
|
|
62
|
-
|
|
63
62
|
self.playwright = Playwright(self)
|
|
64
|
-
|
|
63
|
+
self.pw_browser = None
|
|
64
|
+
self.pw = None
|
|
65
|
+
|
|
65
66
|
def close_session(self):
|
|
67
|
+
if self.pw_browser:
|
|
68
|
+
self.pw_browser.close()
|
|
69
|
+
if self.pw:
|
|
70
|
+
self.pw.stop()
|
|
66
71
|
if not self.session_id:
|
|
67
72
|
return
|
|
68
73
|
response = requests.post(
|
|
@@ -80,19 +85,21 @@ class Simplex:
|
|
|
80
85
|
else:
|
|
81
86
|
raise ValueError(f"Failed to close session: {response.json()['error']}")
|
|
82
87
|
|
|
83
|
-
def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[str] = None):
|
|
88
|
+
def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[dict | str] = None):
|
|
84
89
|
if session_data:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
except json.JSONDecodeError:
|
|
89
|
-
# If parsing fails, treat as file path
|
|
90
|
+
if isinstance(session_data, dict):
|
|
91
|
+
session_data_dict = session_data
|
|
92
|
+
else:
|
|
90
93
|
try:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
except
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
# Try to parse as JSON string first
|
|
95
|
+
session_data_dict = json.loads(session_data)
|
|
96
|
+
except json.JSONDecodeError:
|
|
97
|
+
# If parsing fails, treat as file path
|
|
98
|
+
try:
|
|
99
|
+
with open(session_data, 'r') as f:
|
|
100
|
+
session_data_dict = json.load(f)
|
|
101
|
+
except Exception as e:
|
|
102
|
+
raise ValueError(f"Failed to load session data. Input must be valid JSON string, dictionary, or path to JSON file. Error: {str(e)}")
|
|
96
103
|
response = requests.post(
|
|
97
104
|
f"{BASE_URL}/create_session",
|
|
98
105
|
headers={
|
|
@@ -117,6 +124,10 @@ class Simplex:
|
|
|
117
124
|
raise ValueError(f"It looks like the session wasn't created successfully. Did you set your api_key when creating the Simplex class?")
|
|
118
125
|
self.session_id = response_json['session_id']
|
|
119
126
|
livestream_url = response_json['livestream_url']
|
|
127
|
+
|
|
128
|
+
# Start Playwright without using context manager
|
|
129
|
+
self.pw = sync_playwright().start()
|
|
130
|
+
self.pw_browser = self.pw.chromium.connect_over_cdp(response_json['connect_url'])
|
|
120
131
|
|
|
121
132
|
if show_in_console:
|
|
122
133
|
print(f"Livestream URL: {livestream_url}")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from simplex import Simplex
|
|
2
|
+
import os
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
import time
|
|
5
|
+
from playwright.async_api import Page
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import os
|
|
9
|
+
import dotenv
|
|
10
|
+
|
|
11
|
+
dotenv.load_dotenv()
|
|
12
|
+
|
|
13
|
+
async def main():
|
|
14
|
+
simplex = Simplex(os.getenv("SIMPLEX_API_KEY"))
|
|
15
|
+
|
|
16
|
+
simplex.create_session()
|
|
17
|
+
simplex.goto("https://gmail.com")
|
|
18
|
+
simplex.type("test@gmail.com")
|
|
19
|
+
simplex.press_enter()
|
|
20
|
+
simplex.wait(1000000)
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
asyncio.run(main())
|
|
23
|
+
|
simplex-1.2.38/tests/test.py
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
from simplex import Simplex
|
|
2
|
-
import os
|
|
3
|
-
from dotenv import load_dotenv
|
|
4
|
-
import time
|
|
5
|
-
from playwright.async_api import Page
|
|
6
|
-
|
|
7
|
-
load_dotenv()
|
|
8
|
-
|
|
9
|
-
def login():
|
|
10
|
-
simplex = Simplex(api_key=os.getenv("SIMPLEX_API_KEY"))
|
|
11
|
-
simplex.create_session(proxies=True)
|
|
12
|
-
simplex.goto("https://bill.com")
|
|
13
|
-
|
|
14
|
-
simplex.wait(100000)
|
|
15
|
-
|
|
16
|
-
import asyncio
|
|
17
|
-
from playwright.async_api import async_playwright
|
|
18
|
-
from hyperbrowser import AsyncHyperbrowser
|
|
19
|
-
from hyperbrowser.models.session import CreateSessionParams, ScreenConfig
|
|
20
|
-
import os
|
|
21
|
-
import dotenv
|
|
22
|
-
|
|
23
|
-
dotenv.load_dotenv()
|
|
24
|
-
|
|
25
|
-
async def main():
|
|
26
|
-
client = AsyncHyperbrowser(api_key=os.getenv("HYPERBROWSER_API_KEY"))
|
|
27
|
-
# Create a session and connect to it using Pyppeteer
|
|
28
|
-
session = await client.sessions.create(
|
|
29
|
-
params=CreateSessionParams(
|
|
30
|
-
use_stealth=True,
|
|
31
|
-
use_proxy=True,
|
|
32
|
-
operating_systems=["macos"],
|
|
33
|
-
device=["desktop"],
|
|
34
|
-
locales=["en"],
|
|
35
|
-
)
|
|
36
|
-
)
|
|
37
|
-
print(session.live_url)
|
|
38
|
-
async with async_playwright() as p:
|
|
39
|
-
|
|
40
|
-
browser = await p.chromium.connect_over_cdp(session.ws_endpoint)
|
|
41
|
-
|
|
42
|
-
# Create context with permissions
|
|
43
|
-
context = await browser.new_context(
|
|
44
|
-
)
|
|
45
|
-
import json
|
|
46
|
-
page = await context.new_page()
|
|
47
|
-
|
|
48
|
-
session_data = json.load(open("bill_session.json"))
|
|
49
|
-
await page.goto("https://bill.com")
|
|
50
|
-
await restore_session_data(page, session_data)
|
|
51
|
-
await page.wait_for_timeout(10000000)
|
|
52
|
-
|
|
53
|
-
async def restore_session_data(page: Page, session_data: dict):
|
|
54
|
-
# First set cookies
|
|
55
|
-
if 'cookies' in session_data:
|
|
56
|
-
await page.context.add_cookies(session_data['cookies'])
|
|
57
|
-
|
|
58
|
-
# Now set localStorage
|
|
59
|
-
if 'localStorage' in session_data:
|
|
60
|
-
for key, value in session_data['localStorage'].items():
|
|
61
|
-
await page.evaluate("""({ key, value }) => {
|
|
62
|
-
localStorage.setItem(key, value);
|
|
63
|
-
}""", {"key": key, "value": value})
|
|
64
|
-
|
|
65
|
-
# Set sessionStorage
|
|
66
|
-
if 'sessionStorage' in session_data:
|
|
67
|
-
for key, value in session_data['sessionStorage'].items():
|
|
68
|
-
await page.evaluate("""({ key, value }) => {
|
|
69
|
-
sessionStorage.setItem(key, value);
|
|
70
|
-
}""", {"key": key, "value": value})
|
|
71
|
-
print("restored")
|
|
72
|
-
|
|
73
|
-
if __name__ == "__main__":
|
|
74
|
-
asyncio.run(main())
|
|
75
|
-
|
|
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
|