Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,7 @@ import requests
|
|
3 |
from bs4 import BeautifulSoup
|
4 |
from urllib.parse import urljoin
|
5 |
|
6 |
-
def parse_links(ort):
|
7 |
-
|
8 |
# Konstruiere die vollständige URL
|
9 |
initial_url = f"http://specialist-it.de:3000?q={ort}"
|
10 |
# Senden der Anfrage an die initiale URL
|
@@ -13,32 +12,14 @@ def parse_links(ort):
|
|
13 |
print(response)
|
14 |
# Parse the HTML content using BeautifulSoup
|
15 |
soup = BeautifulSoup(response.content, 'html.parser')
|
16 |
-
|
17 |
-
|
18 |
-
def scrape_links(links):
|
19 |
-
results = []
|
20 |
-
for link in links:
|
21 |
-
try:
|
22 |
-
# Senden der Anfrage an die URL
|
23 |
-
response = requests.get(link)
|
24 |
-
response.raise_for_status() # Überprüfen, ob die Anfrage erfolgreich war
|
25 |
-
|
26 |
-
# Parse the HTML content using BeautifulSoup
|
27 |
-
soup = BeautifulSoup(response.content, 'html.parser')
|
28 |
-
|
29 |
-
|
30 |
-
return response
|
31 |
|
32 |
# Erstelle die Gradio-Schnittstelle
|
33 |
with gr.Blocks() as demo:
|
34 |
-
gr.Markdown("# Vereine in Bayern")
|
35 |
-
|
36 |
ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
|
37 |
links_output = gr.JSON(label="Gefundene Vereine")
|
38 |
-
|
39 |
# Button zum Starten der Parsung
|
40 |
-
button = gr.Button("Parse und Scrape")
|
41 |
-
|
42 |
# Verbinde den Button mit der Funktion
|
43 |
button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
|
44 |
|
|
|
3 |
from bs4 import BeautifulSoup
|
4 |
from urllib.parse import urljoin
|
5 |
|
6 |
+
def parse_links(ort):
|
|
|
7 |
# Konstruiere die vollständige URL
|
8 |
initial_url = f"http://specialist-it.de:3000?q={ort}"
|
9 |
# Senden der Anfrage an die initiale URL
|
|
|
12 |
print(response)
|
13 |
# Parse the HTML content using BeautifulSoup
|
14 |
soup = BeautifulSoup(response.content, 'html.parser')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Erstelle die Gradio-Schnittstelle
|
17 |
with gr.Blocks() as demo:
|
18 |
+
gr.Markdown("# Vereine in Bayern")
|
|
|
19 |
ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
|
20 |
links_output = gr.JSON(label="Gefundene Vereine")
|
|
|
21 |
# Button zum Starten der Parsung
|
22 |
+
button = gr.Button("Parse und Scrape")
|
|
|
23 |
# Verbinde den Button mit der Funktion
|
24 |
button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
|
25 |
|