Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading