From 52a404663100d8b31bc28cf3fba34b0d891b34a2 Mon Sep 17 00:00:00 2001 From: Samirgorai Date: Sun, 31 Dec 2023 22:16:22 +0530 Subject: [PATCH 1/3] "Yahoo Finance Premium instituting recaptcha #254" Cause of the error might be that in username page contains multiple names with 'id=login-username' because of it was not able to login and resulting in error and providing us message:"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." i changed the method of finding the element to By.XPATH Signed-off-by: Samir Gorai --- yahooquery/headless.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yahooquery/headless.py b/yahooquery/headless.py index 4fd2db2..aac2b8f 100644 --- a/yahooquery/headless.py +++ b/yahooquery/headless.py @@ -39,7 +39,8 @@ def login(self): try: self.driver.execute_script("window.open('{}');".format(self.LOGIN_URL)) self.driver.switch_to.window(self.driver.window_handles[-1]) - self.driver.find_element(By.ID, "login-username").send_keys(self.username) + #self.driver.find_element(By.ID, "login-username").send_keys(self.username) + self.driver.find_element(By.XPATH, "//input[@id='login-username']").send_keys(self.username) self.driver.find_element(By.XPATH, "//input[@id='login-signin']").click() password_element = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.ID, "login-passwd")) From af4f39dfdf7f57e77c66f7cf44badfa5cc2eae64 Mon Sep 17 00:00:00 2001 From: Samirgorai Date: Tue, 2 Jan 2024 13:57:25 +0530 Subject: [PATCH 2/3] line 50 cookies = self.driver.get_cookies() self. was mising Signed-off-by: Samir Gorai --- yahooquery/headless.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yahooquery/headless.py b/yahooquery/headless.py index aac2b8f..698293b 100644 --- a/yahooquery/headless.py +++ b/yahooquery/headless.py @@ -47,7 +47,7 @@ def login(self): ) password_element.send_keys(self.password) self.driver.find_element(By.XPATH, "//button[@id='login-signin']").click() - cookies = self.driver.get_cookies() + self.cookies = self.driver.get_cookies() self.driver.quit() self._add_cookies_to_jar(cookies) From 57a406eeae9b2b0ece5d9c11d3a1d068b7e1973d Mon Sep 17 00:00:00 2001 From: Samirgorai Date: Tue, 2 Jan 2024 14:23:27 +0530 Subject: [PATCH 3/3] modified 1 file Signed-off-by: Samir Gorai --- yahooquery/headless.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yahooquery/headless.py b/yahooquery/headless.py index 698293b..a6f6f49 100644 --- a/yahooquery/headless.py +++ b/yahooquery/headless.py @@ -49,7 +49,7 @@ def login(self): self.driver.find_element(By.XPATH, "//button[@id='login-signin']").click() self.cookies = self.driver.get_cookies() self.driver.quit() - self._add_cookies_to_jar(cookies) + self._add_cookies_to_jar(self.cookies) except TimeoutException: return (