mgokg commited on
Commit
a28a8aa
·
verified ·
1 Parent(s): f81e9c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -21
app.py CHANGED
@@ -66,31 +66,13 @@ def scrape_links(links):
66
  )
67
  print(result)
68
  return result
69
- results = []
70
- for link in links:
71
- try:
72
- # Senden der Anfrage an die URL
73
- response = requests.get(link)
74
- response.raise_for_status() # Überprüfen, ob die Anfrage erfolgreich war
75
-
76
- # Parse the HTML content using BeautifulSoup
77
- soup = BeautifulSoup(response.content, 'html.parser')
78
-
79
- # Extrahiere den gewünschten Inhalt (hier als Beispiel der Titel der Seite)
80
- content = soup.title.string if soup.title else "No title found"
81
-
82
- results.append((link, content))
83
- except Exception as e:
84
- results.append((link, str(e)))
85
-
86
- return results
87
 
88
  # Erstelle die Gradio-Schnittstelle
89
  with gr.Blocks() as demo:
90
- gr.Markdown("# Vereine in Bayern")
91
 
92
  ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
93
- links_output = gr.JSON(label="Gefundene Vereine")
94
  #content_output = gr.JSON(label="Inhalt der Links")
95
 
96
  def process_ort(ort):
@@ -99,7 +81,7 @@ with gr.Blocks() as demo:
99
  return links
100
 
101
  # Button zum Starten der Parsung
102
- button = gr.Button("Parse und Scrape")
103
 
104
  # Verbinde den Button mit der Funktion
105
  button.click(fn=process_ort, inputs=ort_input, outputs=links_output)
 
66
  )
67
  print(result)
68
  return result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  # Erstelle die Gradio-Schnittstelle
71
  with gr.Blocks() as demo:
72
+ gr.Markdown("# ")
73
 
74
  ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
75
+ links_output = gr.JSON(label="Ergebnisse")
76
  #content_output = gr.JSON(label="Inhalt der Links")
77
 
78
  def process_ort(ort):
 
81
  return links
82
 
83
  # Button zum Starten der Parsung
84
+ button = gr.Button("senden")
85
 
86
  # Verbinde den Button mit der Funktion
87
  button.click(fn=process_ort, inputs=ort_input, outputs=links_output)