Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
|
|
| 1 |
from tariff_scraper import scrape_tariff_data
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from tariff_scraper import scrape_tariff_data
|
| 3 |
|
| 4 |
+
def main():
|
| 5 |
+
"""
|
| 6 |
+
Main application for scraping and previewing tariff data.
|
| 7 |
+
"""
|
| 8 |
+
st.title("Electricity Tariff Data Scraper")
|
| 9 |
+
st.sidebar.write("Enter the URL of the electricity tariff page:")
|
| 10 |
+
|
| 11 |
+
# Input for URL
|
| 12 |
+
url = st.sidebar.text_input(
|
| 13 |
+
"Tariff URL",
|
| 14 |
+
"https://iesco.com.pk/index.php/customer-services/tariff-guide"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
if st.sidebar.button("Scrape Tariff Data"):
|
| 18 |
+
if url:
|
| 19 |
+
with st.spinner("Scraping data..."):
|
| 20 |
+
data = scrape_tariff_data(url)
|
| 21 |
+
if isinstance(data, list):
|
| 22 |
+
st.success("Tariff data fetched successfully!")
|
| 23 |
+
st.write("### Scraped Tariff Data")
|
| 24 |
+
# Display scraped data in a table format
|
| 25 |
+
for row in data:
|
| 26 |
+
st.write(row)
|
| 27 |
+
else:
|
| 28 |
+
st.error(data)
|
| 29 |
+
else:
|
| 30 |
+
st.sidebar.error("Please provide a valid URL.")
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
main()
|