Update app.py
Browse files
app.py
CHANGED
@@ -12,21 +12,20 @@ def selenium(message):
|
|
12 |
options = webdriver.ChromeOptions()
|
13 |
options.add_argument('--headless')
|
14 |
wd = webdriver.Chrome(options=options)
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
|
29 |
-
|
30 |
iface = gr.Interface(
|
31 |
fn=selenium,
|
32 |
inputs="text",
|
@@ -35,4 +34,4 @@ iface = gr.Interface(
|
|
35 |
description="get answer from perplexity"
|
36 |
)
|
37 |
|
38 |
-
iface.launch()
|
|
|
12 |
options = webdriver.ChromeOptions()
|
13 |
options.add_argument('--headless')
|
14 |
wd = webdriver.Chrome(options=options)
|
15 |
+
try:
|
16 |
+
url = 'https://www.spiegel.de'
|
17 |
+
wd.get(url)
|
18 |
+
wd.implicitly_wait(10)
|
19 |
+
element = wd.find_element(By.TAG_NAME, "body")
|
20 |
+
print(element.text)
|
21 |
|
22 |
+
except WebDriverException as e:
|
23 |
+
return element.text
|
24 |
+
finally:
|
25 |
+
if wd:
|
26 |
+
wd.quit()
|
27 |
|
28 |
|
|
|
29 |
iface = gr.Interface(
|
30 |
fn=selenium,
|
31 |
inputs="text",
|
|
|
34 |
description="get answer from perplexity"
|
35 |
)
|
36 |
|
37 |
+
iface.launch()
|