Don't update yet

This commit is contained in:
piair 2023-03-29 23:09:16 +02:00
parent c5beafe036
commit 0cb0521da6
1 changed files with 23 additions and 5 deletions

28
V5.py
View File

@ -62,7 +62,10 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
print(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n") print(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
if DISCORD_ENABLED_ERROR: if DISCORD_ENABLED_ERROR:
with open("page.html", "w") as f: with open("page.html", "w") as f:
f.write(ldriver.page_source) try :
f.write(ldriver.page_source)
except :
f.write("the driver has closed or crashed. Can't access page content")
try : try :
img = display.waitgrab() img = display.waitgrab()
img.save("screenshot.png") img.save("screenshot.png")
@ -468,18 +471,33 @@ def login(ldriver):
ldriver.refresh() ldriver.refresh()
rgpd_popup(ldriver) rgpd_popup(ldriver)
ldriver.get("https://www.bing.com/rewardsapp/flyout") ldriver.get("https://www.bing.com/rewardsapp/flyout")
if ("Rejoindre maintenant" in ldriver.page_source): if not('class="b_subtitle bt_join"' in ldriver.page_source):
log_error("Not Connected 1", ldriver, True) log_error(f"Not Connected 1. autre tag : {'>Tableau de bord' in ldriver.page_source}", ldriver, True)
ldriver.refresh() ldriver.refresh()
log_error("Not Connected 2", ldriver, True) log_error("Not Connected 2", ldriver, True)
return(True) if not('class="b_subtitle bt_join"' in ldriver.page_source):
log_error("Not connected 3", ldriver, True)
try :
driver.find_element(By.CSS_SELECTOR, "[h='ID=RewardsFlyout,2.1']").click()
log_error("not connected 5", ldriver, True)
except Exception as e:
log_error(f"not connected 5 - error {e}", ldriver)
if not('class="b_subtitle bt_join"' in ldriver.page_source):
try :
driver.find_element(By.XPATH, "/html/body/div/div/div/div/div[2]/a").click()
except Exception as e:
log_error(f"erreur not connected 6{e}", ldriver)
log_error("not connected 6", ldriver, True)
return(True)
print("cookies plus valides ?") print("cookies plus valides ?")
return(False) return(False)
try : try :
if cookie_login(): if cookie_login():
return (ldriver.current_window_handle) return (ldriver.current_window_handle)
pwd_login() pwd_login() #mobile login in never called. TODO : check if it's bad.
return(ldriver.current_window_handle) return(ldriver.current_window_handle)
except Banned: except Banned:
raise Banned() raise Banned()