-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_playwright.py
More file actions
48 lines (39 loc) · 1.67 KB
/
setup_playwright.py
File metadata and controls
48 lines (39 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
"""
Setup script for Playwright browser automation.
Run this after installing requirements.txt to set up browser binaries.
"""
import subprocess
import sys
def install_playwright_browsers():
"""Install Playwright browser binaries."""
try:
print("Installing Playwright browser binaries...")
result = subprocess.run([
sys.executable, "-m", "playwright", "install", "firefox", "chromium"
], check=True, capture_output=True, text=True)
print("✅ Playwright Firefox and Chromium browsers installed successfully!")
print(result.stdout)
# Also install system dependencies if needed
print("Installing system dependencies...")
result = subprocess.run([
sys.executable, "-m", "playwright", "install-deps", "firefox", "chromium"
], check=True, capture_output=True, text=True)
print("✅ System dependencies installed successfully!")
except subprocess.CalledProcessError as e:
print(f"❌ Error installing Playwright browsers: {e}")
print(f"stdout: {e.stdout}")
print(f"stderr: {e.stderr}")
return False
except Exception as e:
print(f"❌ Unexpected error: {e}")
return False
return True
if __name__ == "__main__":
print("🚀 Setting up Playwright for ShopLyft...")
if install_playwright_browsers():
print("\n✅ Playwright setup complete!")
print("You can now use the browser-based Woolworths search functionality.")
else:
print("\n❌ Playwright setup failed!")
print("The system will fall back to HTTP-based search methods.")