import requests
import json
url_oc = "https://tradeguide.in/future_live"
url = f"https://tradeguide.in/future_live/get_data?symbol=NIFTY&expiry=2021-05-27&interval=5"
headers = {'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
'accept-language: en-GB,en-US;q=0.9,en;q=0.8', 'accept-encoding: gzip, deflate, br'}
session = requests.Session()
request = session.get(url_oc, headers=headers, timeout=5)
cookies = dict(request.cookies)
response = session.get(url, headers=headers, timeout=5, cookies=cookies)
r=response.json()
I am unfamiliar with scraping websites using Python. I tried running this code, but I am getting the following error:
AttributeError: 'set' object has no attribute 'items'.
I am trying to retrieve data futures open interest using this of all the stocks.