'Download a json file using Python or Curl not working

Download a json file using Python or Curl not working url here:

https://api.nasdaq.com/api/screener/stocks?tableonly=true&limit=25&offset=0&download=true

import requests

json_data = {

'tableonly': 'true',
'limit':'25',
'offset':'0',
'download':'true'
}

headers = {
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0',
            'Accept': '*/*',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'en-US,en;q=0.5',
            'Content-Type': 'application/json',
            'platform': 'web',
            'hl': 'en',
            'os': 'web',
            'osv': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0',
            'app': 'global',
            'lzone': 'dc_core_r001',
            'ph': 'MacOS Firefox',
            'locale': 'eng',
           # 'reqid': req_id,
            'device-type': 'Web'
            }

pos = requests.get('https://api.nasdaq.com/api/screener/stocks', json=json_data,headers=headers)

#print("content-type: application/json\n\n")
print("content-type: text/html\n\n")
print(pos)


Solution 1:[1]

You are currently sending the params key as JSON body, use params instead.

response = requests.get('https://api.nasdaq.com/api/screener/stocks', params=json_data, headers=headers)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1