fidélité : handle bad link or not present link

This commit is contained in:
piair 2022-05-15 10:36:26 +02:00
parent c6b1f4c04a
commit 77c606e2eb

73
V4.py
View File

@ -425,13 +425,9 @@ def login():
try: try:
driver.get("https://www.bing.com/rewardsapp/flyout") driver.get("https://www.bing.com/rewardsapp/flyout")
try: try:
driver.find_element( driver.find_element(By.CSS_SELECTOR, f'[title="Rejoindre"]').click() # depend of the language of the page
By.CSS_SELECTOR, f'[title="Rejoindre"]'
).click() # depend of the language of the page
except: except:
driver.find_element( driver.find_element(By.CSS_SELECTOR, f'[title="Join now"]').click() # depend of the language of the page
By.CSS_SELECTOR, f'[title="Join now"]'
).click() # depend of the language of the page
mail = driver.find_element(By.ID, "i0116") mail = driver.find_element(By.ID, "i0116")
send_keys_wait(mail, _mail) send_keys_wait(mail, _mail)
@ -446,16 +442,12 @@ def login():
try: try:
driver.find_element(By.ID, "KmsiCheckboxField").click() driver.find_element(By.ID, "KmsiCheckboxField").click()
except Exception as e: except Exception as e:
printf( printf(f"login - 1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}")
f"login - 1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}"
)
try: try:
driver.find_element(By.ID, "idSIButton9").click() driver.find_element(By.ID, "idSIButton9").click()
except Exception as e: except Exception as e:
printf( printf(f"login - 2 - erreur validation bouton idSIButton9. pas forcement grave {e}")
f"login - 2 - erreur validation bouton idSIButton9. pas forcement grave {e}"
)
printf("login completed") printf("login completed")
RGPD() RGPD()
@ -743,41 +735,40 @@ def LogPoint(account="unknown"): # log des points sur discord
def Fidelite(lien): def Fidelite(lien):
try: try:
while 1: while 1: #close all tabs
try: try:
Close(1) Close(1)
except: except:
break break
driver.get(lien) if (lien.split(":")[0] == "https") or (lien.split(":")[0] == "http") :
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(
'<span class="pull-left margin-right-15">([^<^>]+)</span>',
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é") 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('<span class="pull-left margin-right-15">([^<^>]+)</span>',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é")
else :
printf("lien invalide")
except Exception as e: except Exception as e:
LogError("Fidélité" + str(e)) LogError("Fidélité" + str(e))