Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,15 +32,37 @@ from selenium.webdriver.support.ui import WebDriverWait
|
|
32 |
from selenium.webdriver.support import expected_conditions as EC
|
33 |
from selenium.webdriver.chrome.service import Service
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
#Settings for using the driver without a UI
|
36 |
# Set up Chrome options
|
37 |
options = webdriver.ChromeOptions()
|
38 |
options.add_argument('--headless') # Run in headless mode
|
39 |
options.add_argument('--no-sandbox')
|
40 |
options.add_argument('--disable-dev-shm-usage')
|
41 |
-
|
42 |
# Initialize the ChromeDriver
|
43 |
-
service = Service('/
|
44 |
driver = webdriver.Chrome(service=service, options=options)
|
45 |
|
46 |
from wuzzuf_scraper import Wuzzuf_scrapping
|
|
|
32 |
from selenium.webdriver.support import expected_conditions as EC
|
33 |
from selenium.webdriver.chrome.service import Service
|
34 |
|
35 |
+
|
36 |
+
import os
|
37 |
+
import platform
|
38 |
+
import requests
|
39 |
+
import zipfile
|
40 |
+
|
41 |
+
# Define the ChromeDriver version (replace with the latest compatible version)
|
42 |
+
driver_version = "115.0.5790.102" # Example version, update as needed
|
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 |
+
# Save the zip file
|
49 |
+
with open("chromedriver.zip", "wb") as file:
|
50 |
+
file.write(response.content)
|
51 |
+
|
52 |
+
# Unzip the downloaded file
|
53 |
+
with zipfile.ZipFile("chromedriver.zip", 'r') as zip_ref:
|
54 |
+
zip_ref.extractall("drivers") # Extract to a folder named 'drivers'
|
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()
|
61 |
options.add_argument('--headless') # Run in headless mode
|
62 |
options.add_argument('--no-sandbox')
|
63 |
options.add_argument('--disable-dev-shm-usage')
|
|
|
64 |
# Initialize the ChromeDriver
|
65 |
+
service = Service('drivers/chromedriver')
|
66 |
driver = webdriver.Chrome(service=service, options=options)
|
67 |
|
68 |
from wuzzuf_scraper import Wuzzuf_scrapping
|