Krish-Upgrix commited on
Commit
a154445
·
verified ·
1 Parent(s): 35645b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -12,9 +12,10 @@ from selenium.webdriver.support.ui import WebDriverWait
12
  from selenium.webdriver.support import expected_conditions as EC
13
 
14
  def install_chrome():
15
- if not os.path.exists("/usr/bin/google-chrome"):
16
- subprocess.run(["apt-get", "update"])
17
- subprocess.run(["apt-get", "install", "-y", "chromium-browser"])
 
18
 
19
  def scrape_redfin(zipcode):
20
  install_chrome() # Ensure Chrome/Chromium is installed
@@ -30,7 +31,8 @@ def scrape_redfin(zipcode):
30
  options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
31
 
32
  options.binary_location = "/usr/bin/chromium-browser" # Use Chromium
33
- driver = webdriver.Chrome(options=options)
 
34
  url = f"https://www.redfin.com/zipcode/{zipcode}"
35
  driver.get(url)
36
 
@@ -111,6 +113,7 @@ if st.button("Scrape Data"):
111
 
112
 
113
 
 
114
  ## working best code ever
115
 
116
  # import streamlit as st
 
12
  from selenium.webdriver.support import expected_conditions as EC
13
 
14
  def install_chrome():
15
+ if not os.path.exists("/usr/bin/chromium-browser"):
16
+ subprocess.run(["apt-get", "update"], check=True)
17
+ subprocess.run(["apt-get", "install", "-y", "chromium-browser"], check=True)
18
+ os.environ["PATH"] += os.pathsep + "/usr/bin/"
19
 
20
  def scrape_redfin(zipcode):
21
  install_chrome() # Ensure Chrome/Chromium is installed
 
31
  options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
32
 
33
  options.binary_location = "/usr/bin/chromium-browser" # Use Chromium
34
+ service = Service(chromedriver_autoinstaller.install())
35
+ driver = webdriver.Chrome(service=service, options=options)
36
  url = f"https://www.redfin.com/zipcode/{zipcode}"
37
  driver.get(url)
38
 
 
113
 
114
 
115
 
116
+
117
  ## working best code ever
118
 
119
  # import streamlit as st