mgokg's picture
Update app.py
a5a313c verified
raw
history blame
955 Bytes
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')
#options.add_argument('--no-sandbox')
#options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome(options=options)
wd.get(url)
wd.implicitly_wait(3)
#element=wd.find_element(By.TAG_NAME, "body")
#button_send = driver.find_element(By.ID, "L2AGLb").click()
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()