simplex 1.2.34__tar.gz → 1.2.35__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.34 → simplex-1.2.35}/PKG-INFO +1 -1
- {simplex-1.2.34 → simplex-1.2.35}/setup.py +1 -1
- {simplex-1.2.34 → simplex-1.2.35}/simplex/cli.py +7 -6
- {simplex-1.2.34 → simplex-1.2.35}/simplex/simplex.py +79 -16
- {simplex-1.2.34 → simplex-1.2.35}/simplex.egg-info/PKG-INFO +1 -1
- {simplex-1.2.34 → simplex-1.2.35}/LICENSE +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/README.md +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/pyproject.toml +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/setup.cfg +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex/__init__.py +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex/deploy/__init__.py +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex/deploy/push.py +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex.egg-info/SOURCES.txt +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex.egg-info/dependency_links.txt +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex.egg-info/entry_points.txt +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex.egg-info/requires.txt +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/simplex.egg-info/top_level.txt +0 -0
- {simplex-1.2.34 → simplex-1.2.35}/tests/test.py +0 -0
|
@@ -63,13 +63,14 @@ def login(website, proxies):
|
|
|
63
63
|
website = 'https://' + website
|
|
64
64
|
|
|
65
65
|
animated_print(f"[SIMPLEX] Creating login session for {website}")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
|
|
67
|
+
fileName = simplex.create_login_session(website, proxies=proxies)
|
|
68
|
+
|
|
69
|
+
if fileName:
|
|
70
|
+
animated_print(f"[SIMPLEX] Login session created and saved to {fileName}")
|
|
71
71
|
else:
|
|
72
|
-
print(f"{Fore.YELLOW}[SIMPLEX] Warning:
|
|
72
|
+
print(f"{Fore.YELLOW}[SIMPLEX] Warning: Session data could not be saved{Style.RESET_ALL}")
|
|
73
|
+
|
|
73
74
|
except Exception as e:
|
|
74
75
|
raise click.ClickException(str(e))
|
|
75
76
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import requests
|
|
2
2
|
import atexit
|
|
3
3
|
from typing import Optional
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
from playwright.sync_api import sync_playwright
|
|
5
|
+
import os
|
|
6
6
|
import json
|
|
7
7
|
|
|
8
|
+
BASE_URL = "https://api.simplex.sh"
|
|
9
|
+
|
|
8
10
|
class Playwright:
|
|
9
11
|
def __init__(self, simplex_instance):
|
|
10
12
|
self.simplex = simplex_instance
|
|
@@ -380,20 +382,81 @@ class Simplex:
|
|
|
380
382
|
else:
|
|
381
383
|
raise ValueError(f"Failed to wait: {response.json()['error']}")
|
|
382
384
|
|
|
383
|
-
def create_login_session(self, url: str, proxies: Optional[bool] = True):
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
385
|
+
def create_login_session(self, url: str, save_directory: Optional[str] = None, proxies: Optional[bool] = True):
|
|
386
|
+
def get_website_name(url: str) -> str:
|
|
387
|
+
"""Extract website name from URL"""
|
|
388
|
+
from urllib.parse import urlparse
|
|
389
|
+
netloc = urlparse(url).netloc
|
|
390
|
+
# Remove www. if present
|
|
391
|
+
if netloc.startswith('www.'):
|
|
392
|
+
netloc = netloc[4:]
|
|
393
|
+
return netloc.replace(".", "_")
|
|
394
|
+
|
|
395
|
+
with sync_playwright() as p:
|
|
396
|
+
browser = p.chromium.launch_persistent_context(
|
|
397
|
+
user_data_dir="",
|
|
398
|
+
channel="chrome",
|
|
399
|
+
headless=False,
|
|
400
|
+
args=[
|
|
401
|
+
'--disable-blink-features=AutomationControlled',
|
|
402
|
+
'--disable-automation',
|
|
403
|
+
],
|
|
404
|
+
ignore_default_args=['--enable-automation']
|
|
405
|
+
)
|
|
406
|
+
|
|
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()
|
|
413
|
+
main_page.goto(url)
|
|
414
|
+
|
|
415
|
+
# Create control page
|
|
416
|
+
control_page = browser.new_page()
|
|
417
|
+
control_page.set_content("""
|
|
418
|
+
<html>
|
|
419
|
+
<body style="display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f5f5f5;">
|
|
420
|
+
<button id="capture-btn" style="
|
|
421
|
+
padding: 20px 40px;
|
|
422
|
+
font-size: 18px;
|
|
423
|
+
cursor: pointer;
|
|
424
|
+
background-color: #2196F3;
|
|
425
|
+
color: white;
|
|
426
|
+
border: none;
|
|
427
|
+
border-radius: 5px;
|
|
428
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
429
|
+
">Click here when logged in to capture session</button>
|
|
430
|
+
</body>
|
|
431
|
+
</html>
|
|
432
|
+
""")
|
|
433
|
+
|
|
434
|
+
# Wait for button click using Playwright's wait_for_event
|
|
435
|
+
control_page.wait_for_selector('#capture-btn')
|
|
436
|
+
control_page.evaluate("""
|
|
437
|
+
() => {
|
|
438
|
+
return new Promise((resolve) => {
|
|
439
|
+
document.getElementById('capture-btn').onclick = () => {
|
|
440
|
+
resolve(true);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
""")
|
|
445
|
+
|
|
446
|
+
storage = browser.storage_state()
|
|
447
|
+
if save_directory:
|
|
448
|
+
filename = os.path.join(save_directory, get_website_name(url) + "_session_data.json")
|
|
449
|
+
else:
|
|
450
|
+
filename = get_website_name(url) + "_session_data.json"
|
|
451
|
+
|
|
452
|
+
with open(filename, 'w') as f:
|
|
453
|
+
json.dump(storage, f, indent=2)
|
|
454
|
+
|
|
455
|
+
print(f"Session data saved to '{filename}'")
|
|
456
|
+
|
|
457
|
+
browser.close()
|
|
458
|
+
|
|
459
|
+
return filename
|
|
397
460
|
|
|
398
461
|
def restore_login_session(self, session_data: str, cdp_url: str = None):
|
|
399
462
|
"""
|
|
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
|