File size: 955 Bytes
c3b7bd1
 
 
f542379
c3b7bd1
ad80274
d329cdf
c3b7bd1
 
 
ce69b46
 
c5306b6
e0c79de
c34c062
a5a313c
c34c062
14bdc75
a5a313c
 
eb92f75
a5a313c
ac3380c
c3b7bd1
 
 
c5306b6
60bc03e
c3b7bd1
87db630
c3b7bd1
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()