|
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 |
|
|
|
|
|
|
|
|
|
def selenium(message): |
|
options = webdriver.ChromeOptions() |
|
options.add_argument('--headless') |
|
|
|
try: |
|
wd = webdriver.Chrome(options=options) |
|
|
|
url = 'https://www.spiegel.de' |
|
|
|
wd.get(url) |
|
wd.implicitly_wait(10) |
|
element = driver.find_element(By.TAG_NAME, "body") |
|
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() |
|
|