Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,24 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
-
from tariff_scraper import TARIFF_URLS, scrape_multiple_sections_to_csv
|
| 4 |
|
| 5 |
def main():
|
| 6 |
-
st.title("
|
| 7 |
-
st.write("This app fetches and displays the latest
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
if st.button("Fetch
|
| 11 |
-
url = TARIFF_URLS["
|
| 12 |
st.write(f"Fetching data from {url}...")
|
| 13 |
|
| 14 |
with st.spinner("Scraping data..."):
|
| 15 |
-
|
| 16 |
-
if
|
| 17 |
-
st.success(
|
| 18 |
-
st.write("###
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
data = pd.read_csv(output_file)
|
| 22 |
-
st.dataframe(data)
|
| 23 |
-
except Exception as e:
|
| 24 |
-
st.error(f"Error reading the CSV file: {e}")
|
| 25 |
else:
|
| 26 |
-
st.error(
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from tariff_scraper import TARIFF_URLS, scrape_tariff_data
|
|
|
|
| 3 |
|
| 4 |
def main():
|
| 5 |
+
st.title("IESCO Tariff Rates Viewer")
|
| 6 |
+
st.write("This app fetches and displays the latest IESCO tariff rates.")
|
| 7 |
|
| 8 |
+
# Display the fetch button
|
| 9 |
+
if st.button("Fetch IESCO Tariff Rates"):
|
| 10 |
+
url = TARIFF_URLS["IESCO"]
|
| 11 |
st.write(f"Fetching data from {url}...")
|
| 12 |
|
| 13 |
with st.spinner("Scraping data..."):
|
| 14 |
+
data = scrape_tariff_data(url)
|
| 15 |
+
if data and isinstance(data, list) and len(data) > 0:
|
| 16 |
+
st.success("Data fetched successfully!")
|
| 17 |
+
st.write("### Tariff Rates:")
|
| 18 |
+
for row in data:
|
| 19 |
+
st.write(row)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
else:
|
| 21 |
+
st.error("Failed to fetch tariff data or no data found.")
|
| 22 |
|
| 23 |
if __name__ == "__main__":
|
| 24 |
main()
|