testp / app.py
sahanind's picture
Update app.py
ce1f885 verified
raw
history blame
1.06 kB
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# Initialize the Chrome WebDriver
driver = webdriver.Chrome(options=options)
# Go to the provided URL
url = "https://genyoutube.online/url=https://www.youtube.com/watch?v=-2RAq5o5pwc&list=RD-2RAq5o5pwc&start_radio=1"
driver.get(url)
# Print the page title to verify success
print(driver.title)
# Use WebDriverWait to wait for the element to be present
try:
my_tab_content = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myTabContent"))
)
print(my_tab_content.text) # Print the text content
except Exception as e:
print("Error locating the element:", e)
# Close the browser session
driver.quit()