import os from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service import requests import time count=4 def openDataset(user_prompt): chrome_options = Options() chrome_options.add_argument("--headless") # Uncomment to run headless (no UI) driver = webdriver.Chrome(options=chrome_options) try: driver.get('https://www.openml.org/search?type=data&status=active') time.sleep(5) search = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.CSS_SELECTOR, "input.MuiInputBase-input.css-mnn31"))) search.send_keys(user_prompt) search.send_keys(Keys.RETURN) time.sleep(4) divs = driver.find_elements(By.CSS_SELECTOR, "div.MuiPaper-root.MuiPaper-elevation.MuiPaper-elevation1.MuiCard-root.sc-gFAWRd.gJoEXx.css-1xol7fw") a=0 urls=[] for div in divs: a+=1 if a>count: break div.click() urls.append(driver.current_url) # print(driver.current_url) driver.back() time.sleep(2) driver.quit() return urls except: print("Internet Issue driver crashed") return [] # openDataset("stock price prediction")