Neurolingua commited on
Commit
2c66a93
1 Parent(s): cae540a

Update other_function.py

Browse files
Files changed (1) hide show
  1. other_function.py +12 -4
other_function.py CHANGED
@@ -108,10 +108,18 @@ headers = {
108
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
109
  }
110
  def get_rates():
111
- r = requests.get('https://www.kisandeals.com/mandiprices/ALL/TAMIL-NADU/ALL',headers=headers)
 
 
 
 
 
 
 
 
112
  soup = BeautifulSoup(r.text, 'html.parser')
113
 
114
- # Assuming the table you want is the first one
115
  table = soup.find('table')
116
 
117
  # Check if a table was found
@@ -119,7 +127,7 @@ def get_rates():
119
  # Convert the HTML table to a DataFrame
120
  df = pd.read_html(str(table))[0]
121
 
122
- # Dropping the 'Quintal Price' column
123
  if 'Quintal Price' in df.columns:
124
  df.drop(columns=['Quintal Price'], inplace=True)
125
 
@@ -130,4 +138,4 @@ def get_rates():
130
 
131
  return str(d) + ' These prices are for 1 kg'
132
  else:
133
- return "No table found on the page"
 
108
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
109
  }
110
  def get_rates():
111
+ headers = {
112
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
113
+ }
114
+
115
+ # URL for fetching mandi prices for all states in India
116
+ url = 'https://www.kisandeals.com/mandiprices/ALL/ALL/ALL'
117
+
118
+ # Sending the GET request with headers
119
+ r = requests.get(url, headers=headers)
120
  soup = BeautifulSoup(r.text, 'html.parser')
121
 
122
+ # Finding the table in the HTML
123
  table = soup.find('table')
124
 
125
  # Check if a table was found
 
127
  # Convert the HTML table to a DataFrame
128
  df = pd.read_html(str(table))[0]
129
 
130
+ # Dropping the 'Quintal Price' column if it exists
131
  if 'Quintal Price' in df.columns:
132
  df.drop(columns=['Quintal Price'], inplace=True)
133
 
 
138
 
139
  return str(d) + ' These prices are for 1 kg'
140
  else:
141
+ return "No table found on the page"