Closed vincenttermaat closed 1 year ago
The response from Yahoo seems to have changed. When calling https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC with postman. It now returns the crumb without the "Crumbstore" attribute, as such:
"bkt":"finance-US-en-US-def","crumb":"pQyoa9t9AWz",
I think the crumble_regex in make_dataset.py needs to be changed from:
crumble_regex = r'CrumbStore":{"crumb":"(.*?)"}'
to something like this:
crumble_regex = r'"crumb":"(.*?)"}'
I did try some stuff but I do not have the tooling to properly debug.
Grabbing the crumb manually from the response in postman and putting it in the code as below did fix the issue, but I guess this is only temporary:
def get_crumb(self):
"""
Original code source: https://stackoverflow.com/questions/44225771/scraping-historical-data-from-yahoo-finance-with-python
"""
self.crumb = "pQyoa9t9AWz"
#https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC
#response = self.session.get(self.crumb_link.format(self.symbol),
# headers=self.headers,
# timeout=self.timeout)
#response.raise_for_status()
#match = re.search(self.crumble_regex, response.text)
#if not match:
# raise ValueError('Could not get crumb from Yahoo Finance')
#else:
# self.crumb = match.group(1)
I am having the same issue. Will there be a fix for this?
Hi - I was out travelling last weekend, will take a look this weekend.
@vtermaat your suggestion worked perfectly, thank you! I've updated make_dataset.py
accordingly, and merged into the master branch.
Worked for me today. Big thanks to both of you!