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

problem with get_income_data #102

Open
warren67210 opened this issue Feb 19, 2023 · 2 comments
Open

problem with get_income_data #102

warren67210 opened this issue Feb 19, 2023 · 2 comments

Comments

@warren67210
Copy link

I try to correct the code :

def get_income_statement(ticker, yearly = True):

'''Scrape income statement from Yahoo Finance for a given ticker

   @param: ticker
'''

income_site = "https://finance.yahoo.com/quote/" + ticker + "/financials?p=" + ticker
response = requests.get(income_site)
html = response.text
print(f"html: {html}")
# Parse the list of scripts using a regular expression pattern
pattern = r'root\.App\.main = (.*?);\n}(this));'

script_data = re.search(pattern, html, flags=re.DOTALL).group(1)

json_info = json.loads(script_data)

if yearly:
    temp = json_info["context"]["dispatcher"]["stores"]["QuoteSummaryStore"]["incomeStatementHistory"]["incomeStatementHistory"]
else:
    temp = json_info["context"]["dispatcher"]["stores"]["QuoteSummaryStore"]["incomeStatementHistoryQuarterly"]["incomeStatementHistory"]

return _parse_table(temp) 

But i got always the TypeError: string indices must be integers
@drhdev
Copy link

drhdev commented May 12, 2023

same here. looks broken.

@yaz231
Copy link

yaz231 commented Dec 31, 2023

Same for me. Not sure if anyone has found a workaround?

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

3 participants