Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,23 +38,27 @@ import platform
|
|
38 |
import requests
|
39 |
import zipfile
|
40 |
|
41 |
-
# Define the ChromeDriver version (
|
42 |
-
driver_version = "115.0.5790.102" #
|
43 |
|
44 |
# Download ChromeDriver
|
45 |
url = f"https://chromedriver.storage.googleapis.com/{driver_version}/chromedriver_{platform.system().lower()}64.zip"
|
46 |
response = requests.get(url)
|
47 |
|
48 |
-
#
|
49 |
-
|
50 |
-
file
|
|
|
|
|
51 |
|
52 |
-
# Unzip the downloaded file
|
53 |
-
with zipfile.ZipFile("chromedriver.zip", 'r') as zip_ref:
|
54 |
-
|
55 |
|
56 |
-
# Clean up the zip file
|
57 |
-
os.remove("chromedriver.zip")
|
|
|
|
|
58 |
#Settings for using the driver without a UI
|
59 |
# Set up Chrome options
|
60 |
options = webdriver.ChromeOptions()
|
|
|
38 |
import requests
|
39 |
import zipfile
|
40 |
|
41 |
+
# Define the ChromeDriver version (make sure this matches your Chrome version)
|
42 |
+
driver_version = "115.0.5790.102" # Update to the correct version
|
43 |
|
44 |
# Download ChromeDriver
|
45 |
url = f"https://chromedriver.storage.googleapis.com/{driver_version}/chromedriver_{platform.system().lower()}64.zip"
|
46 |
response = requests.get(url)
|
47 |
|
48 |
+
# Check if the download was successful
|
49 |
+
if response.status_code == 200:
|
50 |
+
# Save the zip file
|
51 |
+
with open("chromedriver.zip", "wb") as file:
|
52 |
+
file.write(response.content)
|
53 |
|
54 |
+
# Unzip the downloaded file
|
55 |
+
with zipfile.ZipFile("chromedriver.zip", 'r') as zip_ref:
|
56 |
+
zip_ref.extractall("drivers") # Extract to a folder named 'drivers'
|
57 |
|
58 |
+
# Clean up the zip file
|
59 |
+
os.remove("chromedriver.zip")
|
60 |
+
else:
|
61 |
+
raise Exception(f"Failed to download ChromeDriver: {response.status_code} - {response.text}")
|
62 |
#Settings for using the driver without a UI
|
63 |
# Set up Chrome options
|
64 |
options = webdriver.ChromeOptions()
|