Reputation: 31
import requests
import pandas as pd
url = "https://www.nseindia.com/api/equity-stockIndices?index=NIFTY%2050"
headers = { "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36",
"Accept-Language" : "en-US;q=0.5",
"Accept-Encoding" : "gzip, deflate"}
js = requests.get(url, headers=headers).json()
r = js['data']
print(r)
this code works fine in pycharm but not working in colab ... please help how to get rid of this
i just need to get this json
data in Colab
Upvotes: 3
Views: 3139
Reputation: 21
I believe this is not possible. As Colab uses hosted runtime and this request will be rejected by the NSE to avoid Dos(Denial of service) attack.
Upvotes: 1