mgokg commited on
Commit
1e4afd6
·
verified ·
1 Parent(s): 504ec2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -48,7 +48,7 @@ def parse_links_and_content(ort):
48
 
49
  # Determine the last page
50
  link_element = soup.select_one('li.page-item:nth-child(8) > a:nth-child(1)')
51
- last_page = 1
52
  if link_element and 'href' in link_element.attrs:
53
  href = link_element['href']
54
  last_page = int(href.split('/')[-1])
@@ -102,14 +102,20 @@ def save_to_csv(data, filename):
102
  dict_writer.writeheader()
103
  dict_writer.writerows(data)
104
 
 
 
 
 
 
 
105
  # Create the Gradio interface
106
  with gr.Blocks() as demo:
107
  gr.Markdown("[![Download](https://specialist-it.de/downloadbut.png)](https://specialist-it.de/verein.csv)")
108
  with gr.Row():
109
  ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
110
  with gr.Row():
111
- links_output = gr.JSON(label="Links")
112
- details_output = gr.JSON(label="Details")
113
 
114
  def process_ort(ort):
115
  links_text, links = parse_links_and_content(ort)
@@ -118,11 +124,14 @@ with gr.Blocks() as demo:
118
  save_to_csv(json_data, './contact_details.csv')
119
  return links_text, contact_details
120
 
121
- # Button to start the parsing
122
- button = gr.Button("Senden")
 
 
 
123
 
124
  # Connect the button to the function
125
  button.click(fn=process_ort, inputs=ort_input, outputs=[links_output, details_output])
126
-
127
  # Launch the Gradio application
128
  demo.launch()
 
48
 
49
  # Determine the last page
50
  link_element = soup.select_one('li.page-item:nth-child(8) > a:nth-child(1)')
51
+ last_page = 10
52
  if link_element and 'href' in link_element.attrs:
53
  href = link_element['href']
54
  last_page = int(href.split('/')[-1])
 
102
  dict_writer.writeheader()
103
  dict_writer.writerows(data)
104
 
105
+ #clear output
106
+ def clear():
107
+ clear=""
108
+ return clear
109
+
110
+
111
  # Create the Gradio interface
112
  with gr.Blocks() as demo:
113
  gr.Markdown("[![Download](https://specialist-it.de/downloadbut.png)](https://specialist-it.de/verein.csv)")
114
  with gr.Row():
115
  ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
116
  with gr.Row():
117
+ details_output = gr.JSON(label="Kontaktinformation")
118
+ links_output = gr.JSON(label="Vereinsliste")
119
 
120
  def process_ort(ort):
121
  links_text, links = parse_links_and_content(ort)
 
124
  save_to_csv(json_data, './contact_details.csv')
125
  return links_text, contact_details
126
 
127
+ # Button to start the
128
+
129
+ with gr.Row():
130
+ clearbutton = gr.Button("clear")
131
+ button = gr.Button("senden")
132
 
133
  # Connect the button to the function
134
  button.click(fn=process_ort, inputs=ort_input, outputs=[links_output, details_output])
135
+ clearbutton.click(fn=clear, inputs=[], outputs=links_output)
136
  # Launch the Gradio application
137
  demo.launch()