simplex 1.2.62__py3-none-any.whl → 1.2.63__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/simplex.py +74 -45
- {simplex-1.2.62.dist-info → simplex-1.2.63.dist-info}/METADATA +1 -1
- simplex-1.2.63.dist-info/RECORD +11 -0
- simplex-1.2.62.dist-info/RECORD +0 -11
- {simplex-1.2.62.dist-info → simplex-1.2.63.dist-info}/LICENSE +0 -0
- {simplex-1.2.62.dist-info → simplex-1.2.63.dist-info}/WHEEL +0 -0
- {simplex-1.2.62.dist-info → simplex-1.2.63.dist-info}/entry_points.txt +0 -0
- {simplex-1.2.62.dist-info → simplex-1.2.63.dist-info}/top_level.txt +0 -0
simplex/simplex.py
CHANGED
|
@@ -7,7 +7,7 @@ import warnings
|
|
|
7
7
|
import time
|
|
8
8
|
# Try to import playwright, but don't fail if it's not available (lite version)
|
|
9
9
|
try:
|
|
10
|
-
from
|
|
10
|
+
from rebrowser_playwright.sync_api import sync_playwright
|
|
11
11
|
PLAYWRIGHT_AVAILABLE = True
|
|
12
12
|
except ImportError:
|
|
13
13
|
PLAYWRIGHT_AVAILABLE = False
|
|
@@ -17,7 +17,7 @@ except ImportError:
|
|
|
17
17
|
ImportWarning
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
-
#BASE_URL = "https://simplex-dev--api-server-fastapi-app.modal.run"
|
|
20
|
+
# BASE_URL = "https://simplex-dev--api-server-fastapi-app.modal.run"
|
|
21
21
|
BASE_URL = "https://api.simplex.sh"
|
|
22
22
|
class Playwright:
|
|
23
23
|
def __init__(self, simplex_instance):
|
|
@@ -495,52 +495,71 @@ class Simplex:
|
|
|
495
495
|
return netloc.replace(".", "_")
|
|
496
496
|
|
|
497
497
|
with sync_playwright() as p:
|
|
498
|
-
|
|
498
|
+
context = p.chromium.launch_persistent_context(
|
|
499
499
|
channel="chrome",
|
|
500
500
|
headless=False,
|
|
501
501
|
args=[
|
|
502
502
|
'--disable-blink-features=AutomationControlled',
|
|
503
503
|
'--disable-automation',
|
|
504
504
|
],
|
|
505
|
-
ignore_default_args=['--enable-automation']
|
|
505
|
+
ignore_default_args=['--enable-automation'],
|
|
506
|
+
user_data_dir="/home/simplex/.config/google-chrome/Profile 1/",
|
|
507
|
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
508
|
+
viewport={"width": 1243, "height": 681}
|
|
506
509
|
)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
main_page.goto(url)
|
|
512
|
-
|
|
513
|
-
# Create control page in same context
|
|
510
|
+
main_page = context.pages[0]
|
|
511
|
+
main_page.goto(url, wait_until="networkidle")
|
|
512
|
+
|
|
513
|
+
# # Create control page in same context
|
|
514
514
|
control_page = context.new_page()
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
""")
|
|
515
|
+
# Use a simple HTML file instead of set_content
|
|
516
|
+
html_content = """
|
|
517
|
+
<!DOCTYPE html>
|
|
518
|
+
<html>
|
|
519
|
+
<head>
|
|
520
|
+
<title>Capture Session</title>
|
|
521
|
+
</head>
|
|
522
|
+
<body style="display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f5f5f5;">
|
|
523
|
+
<button id="capture-btn" style="
|
|
524
|
+
padding: 20px 40px;
|
|
525
|
+
font-size: 18px;
|
|
526
|
+
cursor: pointer;
|
|
527
|
+
background-color: #2196F3;
|
|
528
|
+
color: white;
|
|
529
|
+
border: none;
|
|
530
|
+
border-radius: 5px;
|
|
531
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
532
|
+
">Click here when logged in to capture session</button>
|
|
533
|
+
</body>
|
|
534
|
+
</html>
|
|
535
|
+
"""
|
|
536
|
+
import tempfile
|
|
537
|
+
# Write to a temporary file
|
|
538
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.html', mode='w') as f:
|
|
539
|
+
f.write(html_content)
|
|
540
|
+
temp_path = f.name
|
|
543
541
|
|
|
542
|
+
try:
|
|
543
|
+
# Load from file instead of set_content
|
|
544
|
+
control_page.goto(f"file://{temp_path}")
|
|
545
|
+
control_page.wait_for_selector('#capture-btn', timeout=30000)
|
|
546
|
+
|
|
547
|
+
# Wait for button click
|
|
548
|
+
control_page.evaluate("""
|
|
549
|
+
() => {
|
|
550
|
+
return new Promise((resolve) => {
|
|
551
|
+
document.getElementById('capture-btn').onclick = () => {
|
|
552
|
+
resolve(true);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
""")
|
|
557
|
+
finally:
|
|
558
|
+
# Clean up temp file
|
|
559
|
+
try:
|
|
560
|
+
os.unlink(temp_path)
|
|
561
|
+
except:
|
|
562
|
+
pass
|
|
544
563
|
# Use context.storage_state() instead of browser.storage_state()
|
|
545
564
|
storage = context.storage_state()
|
|
546
565
|
if save_directory:
|
|
@@ -553,9 +572,8 @@ class Simplex:
|
|
|
553
572
|
|
|
554
573
|
print(f"Session data saved to '{filename}'")
|
|
555
574
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
return filename
|
|
575
|
+
context.close()
|
|
576
|
+
# return filename
|
|
559
577
|
|
|
560
578
|
def restore_login_session(self, session_data: str, cdp_url: str = None):
|
|
561
579
|
"""
|
|
@@ -664,9 +682,20 @@ class Simplex:
|
|
|
664
682
|
# Get filename from Content-Disposition header
|
|
665
683
|
content_disposition = response.headers.get('Content-Disposition')
|
|
666
684
|
if content_disposition:
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
685
|
+
try:
|
|
686
|
+
filename = content_disposition.split('filename=')[1].strip('"')
|
|
687
|
+
except:
|
|
688
|
+
try:
|
|
689
|
+
filename_star = content_disposition.split('filename*=')[1].split(';')[0]
|
|
690
|
+
# Parse the RFC 5987 encoded filename
|
|
691
|
+
encoding, _, fname = filename_star.split("'", 2)
|
|
692
|
+
# URL decode the filename
|
|
693
|
+
from urllib.parse import unquote
|
|
694
|
+
filename = unquote(fname)
|
|
695
|
+
except Exception:
|
|
696
|
+
raise ValueError("File failed to be parsed from Content-Disposition header.")
|
|
697
|
+
else:
|
|
698
|
+
raise ValueError("No Content-Disposition header found. File was not downloaded.")
|
|
670
699
|
|
|
671
700
|
# Check if response content is empty
|
|
672
701
|
if len(response.content) == 0:
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
+
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
+
simplex/simplex.py,sha256=iY_zM02VwS6ru2eHUTz1sNnnZ9pdf4Y7XnT6FQJKKgE,29206
|
|
4
|
+
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
+
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
+
simplex-1.2.63.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
+
simplex-1.2.63.dist-info/METADATA,sha256=gQZ7RVjUwC8Yk6SsxkuvLl4v9ijC3PfuC3Uky8mUmeA,1045
|
|
8
|
+
simplex-1.2.63.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
simplex-1.2.63.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
+
simplex-1.2.63.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
+
simplex-1.2.63.dist-info/RECORD,,
|
simplex-1.2.62.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
-
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
-
simplex/simplex.py,sha256=p1W7e7NNUDHfWn8dq4ioD-fdimlezQWN8pMph5jzX6A,27762
|
|
4
|
-
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
-
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
-
simplex-1.2.62.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
-
simplex-1.2.62.dist-info/METADATA,sha256=4PT1Je_1IFCUTWcZ8DQ-ezQn0j6nOfZXQ3Unkv3h5U0,1045
|
|
8
|
-
simplex-1.2.62.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
simplex-1.2.62.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
-
simplex-1.2.62.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
-
simplex-1.2.62.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|