| import gradio as gr | |
| from playwright.sync_api import sync_playwright | |
| def get_title(url): | |
| try: | |
| with sync_playwright() as p: | |
| browser = p.chromium.launch(headless=True) | |
| page = browser.new_page() | |
| page.goto(url) | |
| title = page.title() | |
| browser.close() | |
| return title | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| demo = gr.Interface(fn=get_title, inputs="text", outputs="text") | |
| demo.launch() |