Code: Select all
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()
< /code>
Es scheint, dass Yahoo Finance ihre V7 -API so geändert hat, dass sie für jede Anfrage Cookies benötigt. Ausführen des obigen Code{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}
Dieses Problem scheint auch in diesem Github Repo bekannt zu sein: https://github.com/joshuaulrich/quantmo ... /tsues/p.p>
Sie scheinen ein Patch zu haben, das funktioniert: https://github.com/joshuaulrich/quantmo ... 83/commits
Aber der Code ist alles in r ... jemand weiß, wie man das in Python übersetzt?