Spaces:
Sleeping
Sleeping
Update other_function.py
Browse files- other_function.py +23 -10
other_function.py
CHANGED
@@ -105,13 +105,26 @@ def get_weather(city):
|
|
105 |
return (celcius)
|
106 |
|
107 |
def get_rates():
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
return (celcius)
|
106 |
|
107 |
def get_rates():
|
108 |
+
r = requests.get('https://www.kisandeals.com/mandiprices/ALL/TAMIL-NADU/ALL')
|
109 |
+
soup = BeautifulSoup(r.text, 'html.parser')
|
110 |
+
|
111 |
+
# Assuming the table you want is the first one
|
112 |
+
table = soup.find('table')
|
113 |
+
|
114 |
+
# Check if a table was found
|
115 |
+
if table:
|
116 |
+
# Convert the HTML table to a DataFrame
|
117 |
+
df = pd.read_html(str(table))[0]
|
118 |
+
|
119 |
+
# Dropping the 'Quintal Price' column
|
120 |
+
if 'Quintal Price' in df.columns:
|
121 |
+
df.drop(columns=['Quintal Price'], inplace=True)
|
122 |
+
|
123 |
+
# Creating a dictionary from the DataFrame
|
124 |
+
d = {}
|
125 |
+
for i in range(len(df)):
|
126 |
+
d[df.iloc[i, 0]] = df.iloc[i, 1]
|
127 |
+
|
128 |
+
return str(d) + ' These prices are for 1 kg'
|
129 |
+
else:
|
130 |
+
return "No table found on the page"
|