|
import gradio as gr |
|
from selenium import webdriver |
|
from selenium.common.exceptions import WebDriverException |
|
from selenium.webdriver.common.by import By |
|
|
|
|
|
resp="" |
|
def take_screenshot(url): |
|
options = webdriver.ChromeOptions() |
|
options.add_argument('--headless') |
|
|
|
|
|
wd = webdriver.Chrome(options=options) |
|
wd.get(url) |
|
|
|
wd.implicitly_wait(3) |
|
|
|
|
|
element = wd.find_element(By.TAG_NAME, "body") |
|
body_html = element.get_attribute("outerHTML") |
|
return body_html |
|
|
|
return element |
|
|
|
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() |
|
|