Skip to content

Commit

Permalink
Add logic to setup a session when logging in is unsuccessful
Browse files Browse the repository at this point in the history
  • Loading branch information
dpguthrie committed Dec 16, 2023
1 parent 3a06edb commit 2047ddc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions yahooquery/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,23 @@ def login(self) -> None:
if _has_selenium:
instance = YahooFinanceHeadless(self.username, self.password)
instance.login()
self.session.cookies = instance.cookies
if instance.cookies:
self.session.cookies = instance.cookies
return

else:
logger.warning(
"Unable to login and/or retrieve the appropriate cookies. This is "
"most likely due to Yahoo Finance instituting recaptcha, which "
"this package does not support."
)

else:
logger.warning(
"You do not have the required libraries to use this feature. Install "
"with the following: `pip install yahooquery[premium]`"
)
self.session = setup_session(self.session, self._setup_url)
self.session = setup_session(self.session, self._setup_url)

def _chunk_symbols(self, key, params={}, chunk=None, **kwargs):
current_symbols = self.symbols
Expand Down

0 comments on commit 2047ddc

Please sign in to comment.