Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,17 +2,20 @@ import gradio as gr
|
|
2 |
from googlesearch import search
|
3 |
|
4 |
def google_search(query):
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
demo = gr.Interface(
|
11 |
fn=google_search,
|
12 |
inputs=gr.Textbox(lines=2, placeholder="Geben Sie Ihre Suchanfrage ein..."),
|
13 |
outputs="text",
|
14 |
-
title="Google
|
15 |
-
description="Geben Sie eine Suchanfrage ein und erhalten Sie
|
16 |
)
|
17 |
|
18 |
demo.launch()
|
|
|
|
2 |
from googlesearch import search
|
3 |
|
4 |
def google_search(query):
|
5 |
+
try:
|
6 |
+
# Führt die Suche durch und gibt nur das erste Ergebnis zurück
|
7 |
+
top_result = next(search(query, num_results=1))
|
8 |
+
return top_result
|
9 |
+
except StopIteration:
|
10 |
+
return "Keine Ergebnisse gefunden."
|
11 |
|
12 |
demo = gr.Interface(
|
13 |
fn=google_search,
|
14 |
inputs=gr.Textbox(lines=2, placeholder="Geben Sie Ihre Suchanfrage ein..."),
|
15 |
outputs="text",
|
16 |
+
title="Top Google-Suchergebnis",
|
17 |
+
description="Geben Sie eine Suchanfrage ein und erhalten Sie das erste Google-Suchergebnis."
|
18 |
)
|
19 |
|
20 |
demo.launch()
|
21 |
+
|