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))