|
import gradio as gr |
|
from selenium import webdriver |
|
from selenium.common.exceptions import WebDriverException |
|
from selenium.webdriver.common.by import By |
|
from PIL import Image |
|
from io import BytesIO |
|
|
|
resp="" |
|
def take_screenshot(url): |
|
options = webdriver.ChromeOptions() |
|
options.add_argument('--headless') |
|
options.add_argument('--no-sandbox') |
|
options.add_argument('--disable-dev-shm-usage') |
|
wd = webdriver.Chrome(options=options) |
|
wd.get(url) |
|
wd.implicitly_wait(10) |
|
resp=driver.find_element(By.TAG_NAME, "a") |
|
return resp |
|
|
|
|
|
iface = gr.Interface( |
|
fn=take_screenshot, |
|
inputs=gr.Textbox(label="Website URL", value="https://spiegel.de"), |
|
outputs=gr.Textbox(), |
|
title="Website Screenshot", |
|
description="Take a screenshot of a website." |
|
) |
|
|
|
iface.launch() |
|
|