Artificial-superintelligence commited on
Commit
a4ea8a9
·
verified ·
1 Parent(s): 3010ab6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from selenium import webdriver
3
+ from selenium.webdriver.chrome.service import Service
4
+ from selenium.webdriver.common.by import By
5
+ from webdriver_manager.chrome import ChromeDriverManager
6
+ from selenium.webdriver.chrome.options import Options
7
+
8
+ def setup_chrome():
9
+ chrome_options = Options()
10
+ chrome_options.add_argument("--headless") # Run in headless mode
11
+ chrome_options.add_argument("--no-sandbox") # Required for cloud environments
12
+ chrome_options.add_argument("--disable-dev-shm-usage") # Avoid shared memory issues
13
+ chrome_options.add_argument("--disable-gpu") # Disable GPU acceleration
14
+
15
+ # Initialize WebDriver
16
+ driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
17
+ return driver
18
+
19
+ def main():
20
+ st.title("Selenium in Streamlit Cloud")
21
+
22
+ if st.button("Run Chrome"):
23
+ driver = setup_chrome()
24
+ driver.get("https://www.google.com")
25
+ st.write("Page title:", driver.title)
26
+ driver.quit()
27
+
28
+ if __name__ == "__main__":
29
+ main()