From 77c606e2eb7c1b8bbbfe44055bc1a3d25fc1d590 Mon Sep 17 00:00:00 2001 From: piair Date: Sun, 15 May 2022 10:36:26 +0200 Subject: [PATCH] =?UTF-8?q?fid=C3=A9lit=C3=A9=20:=20handle=20bad=20link=20?= =?UTF-8?q?or=20not=20present=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- V4.py | 73 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/V4.py b/V4.py index 93036f0..f532e59 100755 --- a/V4.py +++ b/V4.py @@ -425,13 +425,9 @@ def login(): try: driver.get("https://www.bing.com/rewardsapp/flyout") try: - driver.find_element( - By.CSS_SELECTOR, f'[title="Rejoindre"]' - ).click() # depend of the language of the page + driver.find_element(By.CSS_SELECTOR, f'[title="Rejoindre"]').click() # depend of the language of the page except: - driver.find_element( - By.CSS_SELECTOR, f'[title="Join now"]' - ).click() # depend of the language of the page + driver.find_element(By.CSS_SELECTOR, f'[title="Join now"]').click() # depend of the language of the page mail = driver.find_element(By.ID, "i0116") send_keys_wait(mail, _mail) @@ -446,16 +442,12 @@ def login(): try: driver.find_element(By.ID, "KmsiCheckboxField").click() except Exception as e: - printf( - f"login - 1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}" - ) + printf(f"login - 1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}") try: driver.find_element(By.ID, "idSIButton9").click() except Exception as e: - printf( - f"login - 2 - erreur validation bouton idSIButton9. pas forcement grave {e}" - ) + printf(f"login - 2 - erreur validation bouton idSIButton9. pas forcement grave {e}") printf("login completed") RGPD() @@ -743,41 +735,40 @@ def LogPoint(account="unknown"): # log des points sur discord def Fidelite(lien): try: - while 1: + while 1: #close all tabs try: Close(1) except: break - - driver.get(lien) - sleep(2) - choix = driver.find_element( - By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]' - ) # pull-left spacer-48-bottom punchcard-row - nb = search("([0-9]) of ([0-9]) completed", driver.page_source) - if not nb: - nb = search("([0-9]) de ([0-9]) finalisé", driver.page_source) - for i in range(int(nb[2]) - int(nb[1])): - driver.refresh() - CustomSleep(2) - choix = driver.find_element(By.CLASS_NAME, "spacer-48-bottom") - ButtonText = search( - '([^<^>]+)', - choix.get_attribute("innerHTML"), - )[1] - bouton = driver.find_element(By.XPATH, f'//span[text()="{ButtonText}"]') - bouton.click() - CustomSleep(uniform(3, 5)) - driver.switch_to.window(driver.window_handles[1]) - TryPlay(driver.title) + + if (lien.split(":")[0] == "https") or (lien.split(":")[0] == "http") : + driver.get(lien) - CustomSleep(uniform(3, 5)) - try: - Close(driver.window_handles[1]) - except Exception as e: - printf(e) + sleep(2) + choix = driver.find_element(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]') # pull-left spacer-48-bottom punchcard-row + nb = search("([0-9]) of ([0-9]) completed", driver.page_source) + if not nb: + nb = search("([0-9]) de ([0-9]) finalisé", driver.page_source) + for i in range(int(nb[2]) - int(nb[1])): + driver.refresh() + CustomSleep(2) + choix = driver.find_element(By.CLASS_NAME, "spacer-48-bottom") + ButtonText = search('([^<^>]+)',choix.get_attribute("innerHTML"))[1] + bouton = driver.find_element(By.XPATH, f'//span[text()="{ButtonText}"]') + bouton.click() + CustomSleep(uniform(3, 5)) + driver.switch_to.window(driver.window_handles[1]) + TryPlay(driver.title) + driver.get(lien) + CustomSleep(uniform(3, 5)) + try: + Close(driver.window_handles[1]) + except Exception as e: + printf(e) - printf("on a reussit la partie fidélité") + printf("on a reussit la partie fidélité") + else : + printf("lien invalide") except Exception as e: LogError("Fidélité" + str(e))