File size: 1,195 Bytes
a936419
 
 
04f7cb6
a936419
07a65bf
e410dd0
95fb455
 
 
 
 
 
2c9db66
 
 
 
 
 
 
 
 
a936419
 
 
07a65bf
5535edf
a68c2e8
a936419
07a65bf
a936419
5e3a028
a936419
 
2f3bf94
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
import gradio as gr
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin

def parse_links(ort):   
    # Konstruiere die vollständige URL
    initial_url = f"http://specialist-it.de:3000?q={ort}"  
    # Senden der Anfrage an die initiale URL
    response = requests.get(initial_url)
    response.raise_for_status()  # Überprüfen, ob die Anfrage erfolgreich war
    # Parse the HTML content using BeautifulSoup
    soup = BeautifulSoup(response.content, 'html.parser')
    # Den body-Tag finden
    body_tag = soup.find('body')
    # Den Text des body-Tags zurückgeben
    body_text = body_tag.get_text()
    # Den Text ausgeben
    print(body_text)
    
    return body_text
  

# Erstelle die Gradio-Schnittstelle
with gr.Blocks() as demo:
    gr.Markdown("# Vereine in Bayern")  
    ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
    links_output = gr.JSON(label="Gefundene Vereine")
    # Button zum Starten der Parsung
    button = gr.Button("Parse und Scrape")    
    # Verbinde den Button mit der Funktion
    button.click(fn=parse_links, inputs=ort_input, outputs=links_output)

# Starte die Gradio-Anwendung
demo.launch()