Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -100,11 +100,11 @@ def scrape_links(links):
|
|
100 |
# Extract the name of the Verein from the URL
|
101 |
vereinsname = parts[-1] if parts[-1] else parts[-2] # Fallback to the second-to-last part if the last part is empty
|
102 |
texte = target_nav.text.strip()
|
103 |
-
texte=texte.replace("Amtsgericht: Schweinfurt", "")
|
104 |
-
texte=texte.replace("Adresse folgt", "")
|
105 |
-
texte=texte.replace("Adresse", "Adresse:")
|
106 |
-
texte=texte.replace("Kontakt", "Email:")
|
107 |
-
texte=texte.replace("Noch keine Daten vorhanden", "")
|
108 |
|
109 |
if target_nav:
|
110 |
details.append(f"Verein: {vereinsname} {texte}")
|
@@ -113,9 +113,7 @@ def scrape_links(links):
|
|
113 |
except Exception as e:
|
114 |
details.append(f"Error: {str(e)}")
|
115 |
|
116 |
-
#details= gr.Markdown()
|
117 |
return details
|
118 |
-
|
119 |
|
120 |
def save_to_csv(data, filename):
|
121 |
keys = data[0].keys() if data else []
|
@@ -134,15 +132,23 @@ with gr.Blocks() as demo:
|
|
134 |
with gr.Row():
|
135 |
ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
|
136 |
with gr.Row():
|
137 |
-
|
138 |
-
details_output= gr.JSON(label="Vereinsliste")
|
139 |
|
140 |
def process_ort(ort):
|
141 |
links_text, links = parse_links_and_content(ort)
|
142 |
contact_details = scrape_links(links)
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
with gr.Row():
|
148 |
clearbutton = gr.Button("Clear")
|
|
|
100 |
# Extract the name of the Verein from the URL
|
101 |
vereinsname = parts[-1] if parts[-1] else parts[-2] # Fallback to the second-to-last part if the last part is empty
|
102 |
texte = target_nav.text.strip()
|
103 |
+
texte = texte.replace("Amtsgericht: Schweinfurt", "")
|
104 |
+
texte = texte.replace("Adresse folgt", "")
|
105 |
+
texte = texte.replace("Adresse", "Adresse:")
|
106 |
+
texte = texte.replace("Kontakt", "Email:")
|
107 |
+
texte = texte.replace("Noch keine Daten vorhanden", "")
|
108 |
|
109 |
if target_nav:
|
110 |
details.append(f"Verein: {vereinsname} {texte}")
|
|
|
113 |
except Exception as e:
|
114 |
details.append(f"Error: {str(e)}")
|
115 |
|
|
|
116 |
return details
|
|
|
117 |
|
118 |
def save_to_csv(data, filename):
|
119 |
keys = data[0].keys() if data else []
|
|
|
132 |
with gr.Row():
|
133 |
ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
|
134 |
with gr.Row():
|
135 |
+
details_output = gr.JSON(label="Vereinsliste")
|
|
|
136 |
|
137 |
def process_ort(ort):
|
138 |
links_text, links = parse_links_and_content(ort)
|
139 |
contact_details = scrape_links(links)
|
140 |
+
|
141 |
+
from gradio_client import Client
|
142 |
+
|
143 |
+
qwen_client = Client("Qwen/Qwen2.5-72B-Instruct")
|
144 |
+
result = qwen_client.predict(
|
145 |
+
query=f"return a valid json objects with contact details foreach verein \n {contact_details}",
|
146 |
+
history=[],
|
147 |
+
system="you are a expert for json data and your job is to extract information from text and return a valid json object only. no text no explanations",
|
148 |
+
api_name="/model_chat"
|
149 |
+
)
|
150 |
+
return result
|
151 |
+
# return contact_details
|
152 |
|
153 |
with gr.Row():
|
154 |
clearbutton = gr.Button("Clear")
|