小编Jus*_*tin的帖子

雅虎财经 V7 API 现在需要 cookie?(Python)

url = 'https://query2.finance.yahoo.com/v7/finance/quote?symbols=TSLA&fields=regularMarketPreviousClose&region=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 吗?

python cookies yahoo-finance python-requests

7
推荐指数
1
解决办法
6793
查看次数

用按钮隐藏/取消隐藏div?

    <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 应该处于隐藏状态,干杯!

html javascript css

1
推荐指数
1
解决办法
2万
查看次数