I am Using kite web scraping for get option data But there some issue

I am Using kite web scraping for get option data But  there some issue 



isssue :


  1. when i use while loop for  requests.get  that time  my data not update every time. send same json every time Please check below code 
def get_stock_historical_data(token, start_date, end_date, auth_token, timeframe='5minute'):
    userid = 'NY4565'
    timeframe= timeframe
    ciqrandom = '161746886774'
    headers = {'Referer' : 'https://kite.zerodha.com/chart/web/', 'Authorization': auth_token}
    columns = ['Date','Open','High','Low','Close','V','OI']
    final_df = pd.DataFrame(columns=columns)
    url = f'https://kite.zerodha.com/oms/instruments/historical/{token}/{timeframe}?user_id={userid}&oi=1&from={start_date}&to={end_date}'
    resJson = requests.get(url, headers=headers).json()
    candelinfo = resJson['data']['candles']
    df= pd.DataFrame(candelinfo, columns=columns)    
    final_df = final_df.append(df)
    final_df = final_df.set_index('Date')
    return final_df

 


while True:
    t.sleep(1)
    if datetime.now().minute % 1 == 0 and datetime.now().second == 10:  
             option_price = get_stock_historical_data(stock_token, start_date, end_date, auth_token, interval)


but i run the on streamlit_autorefresh then every time data update...

Hi Shirish,



It appears that you are attempting to retrieve data through the Kite API. In this case, you can directly reach out to the Kite team for assistance as they will be better equipped to help you with any specific issues or questions related to their API. You can find their contact details here.



Thanks

Rushda

i am not using Kite API…  just use url from zerodh kite 



https://kite.zerodha.com/oms/instruments/historical/260105/5minute?user_id=NY4565&oi=1&from=2023-11-02&to=2023-11-03



this is working on streamlit_autorefresh not in while loop

Hi Shirish



Its possible that Kite may not support web scraping. If you want to retrieve data from Kite, you can reach out to them directly here.