python script to java coversion

Discussion in 'Mixed Languages' started by amsk98, Mar 25, 2022.

  1. amsk98

    amsk98 MDL Junior Member

    Sep 8, 2013
    81
    5
    0
    how to import json url in google sheet app script

    Code:
    url = https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY 
    
    this url req cookies and headers to fech the data
    
    
    
    in pyhon i use below script
    
    url = "https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY"
    headers ={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, ''like Gecko) Chrome/80.0.3987.149 Safari/537.36',
                'accept-language': 'en,gu;q=0.9,hi;q=0.8',
                'accept-encoding': 'gzip, deflate, br'}
               
    session = requests.Session()
    request = session.get(url,headers=headers)           
    cookies = dict(request.cookies)
    response = session.get(url,headers=headers,cookies=cookies,timeout=10).json()
    how to transform it to google app script