File size: 1,145 Bytes
c3b7bd1
 
 
f542379
df9dd4d
247bec9
 
 
c3b7bd1
0d04d2e
247bec9
7ef513f
 
247bec9
2f7e2da
247bec9
 
 
d5321f0
2f7e2da
247bec9
 
 
45e6a72
c14520a
 
79ac338
2f7e2da
3b7d2d0
2f7e2da
 
 
79ac338
 
c3b7bd1
0d04d2e
3f8a236
 
5879af1
 
c3b7bd1
 
2f7e2da
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
35
36
37
38
39
40
41
42
43
44
import gradio as gr
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.by import By
from gradio_client import Client
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options


def take_screenshot(url):
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')

    try:
        wd = webdriver.Chrome(options=options)
        url = 'https://www.google.com/search?q=zugverbindung+bad+kissingen+euerdorf'
        #url = 'https://www.spiegel.de'
        #<ol class="AmbQnf">
        wd.get(url)
        wd.implicitly_wait(5)
        element = driver.find_element(By.ID, "exp0")
        time.sleep(2)
        return element.text
        
 

    except WebDriverException as e:
        return "fehler"
    finally:
        if wd:
            wd.quit()
                
   
iface = gr.Interface(
    fn=selenium,
    inputs="text",
    outputs="text",
    title="perplexity.ai",
    description="get answer from perplexity"
)

iface.launch()