title: Python requests 401 error but url opens in browser
body: <p>I am trying to pull the json from this location -
  <a href="https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY" rel="nofollow noreferrer">https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY</a></p>
  <p>This opens fine in my browser, but using requests in python throws a 401 permission error. I have tried adding headers with different arguments, but to no avail.
  Interestingly, the json on this page does not open in the browser as well until <a href="https://www.nseindia.com" rel="nofollow noreferrer">https://www.nseindia.com</a> is opened separately. I believe it requires some kind of authentication, but surprised it works in the browser without any.</p>
  <p>Is there a way to extract the information from this url? Any help is much appreciated.</p>
  <p>Here is my implementation -</p>
  <pre><code>import requests
  
  url = 'https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY'
  
  # This throws a 401 response error
  page = requests.get(url, headers={&quot;User-Agent&quot;: &quot;Mozilla/5.0&quot;})
  
  # This throws a 'Connection aborted' error
  page = requests.get(url, headers={&quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 GTB7.1 (.NET CLR 3.5.30729)&quot;})
  </code></pre>