使用Python或Curl下载一个json文件,但url不起作用:

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)

推荐答案

您当前将params键作为JSON正文发送,请改用params.

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

Python相关问答推荐

通过pandas向每个非空单元格添加子字符串

在Mac上安装ipython

如何使用Python以编程方式判断和检索Angular网站的动态内容?

在Python argparse包中添加formatter_class MetavarTypeHelpFormatter时, - help不再工作""""

索引到 torch 张量,沿轴具有可变长度索引

如何在达到end_time时自动将状态字段从1更改为0

Flash只从html表单中获取一个值

numpy数组和数组标量之间的不同行为

如何训练每一个pandaprame行的线性回归并生成斜率

当输入是字典时,`pandas. concat`如何工作?

如何在Python中实现高效地支持字典和堆操作的缓存?

时间戳上的SOAP头签名无效

Scipy.linprog的可行性有问题吗?(A_ub@x0<;=b_ub).all()为True-但是-linprog(np.zeros_like(X0),A_ub=A_ub,b_ub=b_ub)不可行

Numpy`astype(Int)`给出`np.int64`而不是`int`-怎么办?

Groupby并在组内比较单独行上的两个时间戳

将索引表转换为Numy数组

生产者/消费者-Queue.get by list

搜索结果未显示.我的URL选项卡显示:http://127.0.0.1:8000/search?";,而不是这个:";http://127.0.0.1:8000/search?q=name";

判断字典中是否有多个值对

获取每行NumPy最大出现次数的所有值