纳斯达克网站的帖子请求不正确



所以我试图从纳斯达克获得10年的历史数据。默认时间段为3个月,当将其更改为10年并检查页面源时,发布请求的数据/有效载荷字典为"10y|false|FB">

数据是公开的,可以作为excel表下载

我收到的回复仍然是3个月,而不是10年。有人能告诉我这里出了什么问题吗?非常感谢。

url = "https://www.nasdaq.com"
s = requests.Session()
response = s.get(url)
Scookies = s.cookies.get_dict()
url = "https://www.nasdaq.com/symbol/FB/historical"
data = {'ddlTimeFrame':'10y',
'onchange':'false',
'symbol':'FB'}
data = json.dumps(data)
headers = {'user-agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Mobile Safari/537.36',
'authority':'www.nasdaq.com',
'method':'POST',
'path':'/symbol/fb/historical',
'scheme':'https',
'accept':'*/*',
'accept-encoding':'gzip, deflate, br',
'accept-language':'en-US,en;q=0.9',
'content-length':'12',
'referer': url,
'content-type':'application/json',
'origin': 'https://www.nasdaq.com',
'x-requested-with': 'XMLHttpRequest'}
response = s.post(url, headers = headers , data = payload)

我能够检索十年的原始数据。我拍了几张截图。请注意,它是用HTML模板渲染的,所以你需要去掉它,但我认为我让你朝着正确的方向前进。

https://i.stack.imgur.com/SRxHc.jpg

我的Python示例:

import requests

url = "https://www.nasdaq.com/symbol/fb/historical"

payload = "10y|false|FB" headers = { 'Content-Type': "application/json", 'cache-control': "no-cache", }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

最新更新