Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| from bs4 import BeautifulSoup | |
| import requests | |
| import gradio as gr | |
| def scrape_data(): | |
| url = "https://web.hosp.ncku.edu.tw/nckm/Bedstatus/BedStatus.aspx" | |
| response = requests.get(url) | |
| soup = BeautifulSoup(response.text, "html.parser") | |
| table = soup.find("table", {"id": "GV_EmgInsure"}) | |
| rows = table.find_all("tr") | |
| columns = [th.text.strip() for th in rows[0].find_all("th")] | |
| data = [] | |
| for row in rows[1:]: | |
| row_data = [td.text.strip() for td in row.find_all("td")] | |
| data.append(row_data) | |
| df = pd.DataFrame(data, columns=columns) | |
| return df | |
| def gradio_interface(): | |
| return gr.Interface(fn=scrape_data, inputs=[], outputs="dataframe").launch() | |
| if __name__ == "__main__": | |
| gradio_interface() |