Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calendar_events - fetch historic, not just upcoming #156

Open
ValueRaider opened this issue Feb 27, 2023 · 3 comments
Open

calendar_events - fetch historic, not just upcoming #156

ValueRaider opened this issue Feb 27, 2023 · 3 comments

Comments

@ValueRaider
Copy link

ValueRaider commented Feb 27, 2023

dat.calendar_events currently returns the next earnings event, which I assume is same as shown on the quote page https://finance.yahoo.com/quote/AAPL?p=AAPL&.tsrc=fin-srch

But on the Earnings Calendar page https://finance.yahoo.com/calendar/earnings?symbol=AAPL it shows past dates too - these are useful, can they be fetched?

image

@dpguthrie
Copy link
Owner

You have to have a crumb to do this, which from what I remember since the last time I tried, is not easy to do.

image
image

@dpguthrie
Copy link
Owner

Lots of really cool stuff here though if we can figure out how to get the crumb and add it to the Session.

_VIZ_CONFIG = {

@ValueRaider
Copy link
Author

With a little help from GPT here is code to get the crumb:

import requests, re, json
def get_crumb():
    response = requests.get("https://finance.yahoo.com")
    pat = re.compile(r'window\.YAHOO\.context = ({.*?});', re.DOTALL)
    match = re.search(pat, response.text)
    if match:
        js_dict = json.loads(match.group(1))
        return js_dict.get('crumb')
    return None

print(get_crumb())

I'm hoping you can integrate this in because I find the codebase hard to navigate. Maybe a "Developers Guide" could be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants