File size: 1,573 Bytes
825e978 |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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")
|