Spaces:
Runtime error
Runtime error
import requests | |
class MANDI_PRICE: | |
def __init__(self): | |
self.base_url = "https://enam.gov.in/web/Ajax_ctrl/trade_data_list" | |
# "https://enam.gov.in/web/dashboard/trade-data", | |
# "https://enam.gov.in/web/dashboard/trade_data_list", | |
def get_mandi_price(self, | |
state_name, | |
apmc_name, | |
commodity_name, | |
from_date, | |
to_date | |
): | |
# Prepare the payload for POST request | |
payload = f"language=en&stateName={state_name}&apmcName={apmc_name}&commodityName={commodity_name}&fromDate={from_date}&toDate={to_date}" | |
headers = { | |
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"Referer": "https://enam.gov.in/web/dashboard/trade-data", | |
"Accept": "application/json, text/javascript, */*; q=0.01", | |
} | |
response = requests.post( | |
self.base_url, | |
json=payload, | |
headers=headers, | |
) | |
return response.json() | |