Engineer786 commited on
Commit
974a0ae
·
verified ·
1 Parent(s): 0b42826

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -1,10 +1,33 @@
 
1
  from tariff_scraper import scrape_tariff_data
2
 
3
- url = "https://iesco.com.pk/index.php/customer-services/tariff-guide"
4
- data = scrape_tariff_data(url)
5
- if isinstance(data, list):
6
- print("Scraped Data:")
7
- for row in data[:10]: # Print the first 10 rows
8
- print(row)
9
- else:
10
- print(data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()