Spaces:
Running
Running
File size: 850 Bytes
188a2fe 1ab0ddc 188a2fe 646a14d 188a2fe 1ab0ddc 188a2fe 3a92801 1ab0ddc 3a92801 1ab0ddc 636189b 3a92801 636189b c7ebd2b 188a2fe 1ab0ddc 188a2fe |
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 |
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
def scrape_website(website):
print("Launching chromium browser...")
chrome_driver_path = "/usr/lib/chromium/chromedriver" # dépend de ton Dockerfile
options = Options()
options.binary_location = "/usr/bin/chromium" # important !
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
# ✅ C’est ici qu’il fallait mettre options
driver = webdriver.Chrome(service=Service(chrome_driver_path), options=options)
try:
driver.get(website)
print("Page Loaded...")
html = driver.page_source
return html
finally:
driver.quit()
|