url = 'https://query2.finance.yahoo.com/v7/finance/quote?symbols=TSLA&fields=regularMarketPreviousClose®ion=US&lang=en-US'
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
}
data = requests.get(url,headers=headers)
prepost_data = data.json()
Run Code Online (Sandbox Code Playgroud)
最近,雅虎财经似乎更改了他们的 V7 API,要求每个请求都需要 cookie。运行上面的代码,我收到 Invalid Crumb 错误
{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}
这个问题似乎在这个 Github 存储库中也已知:https://github.com/joshuaulrich/quantmod/issues/382
他们似乎有一个有效的补丁:https ://github.com/joshuaulrich/quantmod/pull/383/commits
但代码都是用 R 编写的...有人知道如何将其翻译成 Python 吗?
<h1>Welcome! Chat now!</h1>
<button id="button">Chat Now</button>
<button id="buttontwo">Chat Categories</button>
<div id="login" style="visibility:hidden">
<button id="closelogin">Close</button>
<input type="text" placeholder="Username"/>
<p id="loginshiz">Pick a username</p>
<button id="go">Go</button>
</div>
Run Code Online (Sandbox Code Playgroud)
当按下聊天按钮时,我想让 div 出现“登录”,当按下 div 内的“关闭登录”按钮时,我想让整个 div 再次隐藏。目前如果没有按下任何按钮,div 应该处于隐藏状态,干杯!