CoderHassan commited on
Commit
8b76fae
·
verified ·
1 Parent(s): 3a152cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py CHANGED
@@ -5,6 +5,40 @@ from scraper import fetch_tariff_from_url
5
  import requests
6
  import plotly.graph_objects as go
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  APPLIANCE_OPTIONS = { ... } # Your existing appliance list
9
 
10
  # Tariff and Carbon Footprint related functions
 
5
  import requests
6
  import plotly.graph_objects as go
7
 
8
+ # Define the CITIES dictionary
9
+ CITIES = {
10
+ "Islamabad": "IESCO",
11
+ "Faisalabad": "FESCO",
12
+ "Hyderabad": "HESCO",
13
+ "Karachi": "KE",
14
+ "Lahore": "LESCO",
15
+ "Peshawar": "PESCO",
16
+ "Quetta": "QESCO"
17
+ }
18
+
19
+ # Add a select box for the user to choose the nearest city
20
+ city = st.selectbox("Select the Nearest City", options=list(CITIES.keys()))
21
+
22
+ # Display the selected city and corresponding company
23
+ st.write(f"You selected: {city}, served by: {CITIES[city]}")
24
+
25
+ # Replace the URL with the selected city's company URL
26
+ url_dict = {
27
+ "IESCO": "https://iesco.com.pk/index.php/customer-services/tariff-guide",
28
+ "FESCO": "https://fesco.com.pk/tariff",
29
+ "HESCO": "http://www.hesco.gov.pk/htmls/tariffs.htm",
30
+ "KE": "https://www.ke.com.pk/customer-services/tariff-structure/",
31
+ "LESCO": "https://www.lesco.gov.pk/ElectricityTariffs",
32
+ "PESCO": "https://pesconlinebill.pk/pesco-tariff/",
33
+ "QESCO": "http://qesco.com.pk/Tariffs.aspx"
34
+ }
35
+
36
+ # Use the selected company to fetch data
37
+ selected_url = url_dict[CITIES[city]]
38
+ st.write(f"Fetching data from: {selected_url}")
39
+
40
+ # Continue with your scraping or data fetching logic using `selected_url`
41
+
42
  APPLIANCE_OPTIONS = { ... } # Your existing appliance list
43
 
44
  # Tariff and Carbon Footprint related functions