mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
Now the program checks if the user is already logged in (#203)
Co-authored-by: Sebastian Thomschke <sebthom@users.noreply.github.com>
This commit is contained in:
@@ -350,6 +350,10 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
LOG.info("Logging in as [%s]...", self.config["login"]["username"])
|
LOG.info("Logging in as [%s]...", self.config["login"]["username"])
|
||||||
self.web_open(f"{self.root_url}/m-einloggen.html?targetUrl=/")
|
self.web_open(f"{self.root_url}/m-einloggen.html?targetUrl=/")
|
||||||
|
|
||||||
|
if self.is_logged_in():
|
||||||
|
LOG.info("Already logged in as [%s]. Skipping login.", self.config["login"]["username"])
|
||||||
|
return
|
||||||
|
|
||||||
# close redesign banner
|
# close redesign banner
|
||||||
try:
|
try:
|
||||||
self.web_click(By.XPATH, '//*[@id="pre-launch-comms-interstitial-frontend"]//button[.//*[text()[contains(.,"nicht mehr anzeigen")]]]')
|
self.web_click(By.XPATH, '//*[@id="pre-launch-comms-interstitial-frontend"]//button[.//*[text()[contains(.,"nicht mehr anzeigen")]]]')
|
||||||
@@ -378,6 +382,16 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
except NoSuchElementException:
|
except NoSuchElementException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def is_logged_in(self) -> bool:
|
||||||
|
try:
|
||||||
|
user_email_elem = self.web_find(By.ID, "user-email")
|
||||||
|
email_text = user_email_elem.text
|
||||||
|
if f"angemeldet als: {self.config['login']['username']}" == email_text:
|
||||||
|
return True
|
||||||
|
except NoSuchElementException:
|
||||||
|
return False
|
||||||
|
return False
|
||||||
|
|
||||||
def handle_captcha_if_present(self, captcha_element_id:str, msg:str) -> None:
|
def handle_captcha_if_present(self, captcha_element_id:str, msg:str) -> None:
|
||||||
try:
|
try:
|
||||||
self.web_click(By.XPATH, f"//*[@id='{captcha_element_id}']")
|
self.web_click(By.XPATH, f"//*[@id='{captcha_element_id}']")
|
||||||
|
|||||||
Reference in New Issue
Block a user