Spaces:
Runtime error
Runtime error
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from webdriver_manager.chrome import ChromeDriverManager | |
import gradio as gr | |
def get_youtube_cookies(url): | |
# Set up Selenium with Chrome | |
options = webdriver.ChromeOptions() | |
options.add_argument('--headless') # Run in headless mode | |
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) | |
# Log in to YouTube | |
driver.get("https://www.youtube.com") | |
# You would need to add steps here to log in | |
# Navigate to the URL | |
driver.get(url) | |
# Extract cookies | |
cookies = driver.get_cookies() | |
driver.quit() | |
# Format cookies as a string | |
cookie_str = "\n".join([f"{cookie['name']}={cookie['value']}" for cookie in cookies]) | |
return cookie_str | |
# Create the Gradio interface | |
iface = gr.Interface( | |
fn=get_youtube_cookies, | |
inputs=gr.Textbox(label="YouTube URL"), | |
outputs=gr.Textbox(label="Cookies"), | |
title="YouTube Cookies Extractor", | |
description="Enter a YouTube URL to extract cookies." | |
) | |
# Launch the app | |
iface.launch() | |