simplex 1.2.37__tar.gz → 1.2.38__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.37
3
+ Version: 1.2.38
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -17,7 +17,7 @@ class PostInstallCommand(install):
17
17
 
18
18
  setup(
19
19
  name="simplex",
20
- version="1.2.37",
20
+ version="1.2.38",
21
21
  packages=find_packages(),
22
22
  package_data={
23
23
  "simplex": ["browser_agent/dom/*.js"], # Include JS files in the dom directory
@@ -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, proxies=proxies)
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}")
@@ -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
- response = requests.post(
87
- f"{BASE_URL}/create_session",
88
- headers={
89
- 'x-api-key': self.api_key
90
- },
91
- data={'proxies': proxies, 'session_data': session_data}
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.get(
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
- params=data
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, proxies: Optional[bool] = True):
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.launch_persistent_context(
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
- # Close the default about:blank page
408
- if len(browser.pages) > 0:
409
- browser.pages[0].close()
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 = browser.new_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
- storage = browser.storage_state()
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']}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.37
3
+ Version: 1.2.38
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes