maybe better, as usual, probaly don't work, wait tomorrow

This commit is contained in:
piair 2023-03-17 22:37:35 +01:00
parent 80f6cbc919
commit ebb1847a51
1 changed files with 28 additions and 4 deletions

30
V5.py
View File

@ -83,15 +83,17 @@ def firefox_driver(mobile=False, Headless=False):
setup_proxy(proxy_address,proxy_port, options) setup_proxy(proxy_address,proxy_port, options)
options.set_preference("browser.link.open_newwindow", 3) options.set_preference("browser.link.open_newwindow", 3)
if FAST : if FAST :
options.set_preference("permissions.default.image", 2) #disable image loading. May add this without the fast option soon options.set_preference("permissions.default.image", 2) #disable image loading. You shouldn't use it except if really nessecary
if Headless: if Headless:
options.add_argument("-headless") options.add_argument("-headless")
if mobile : if mobile :
options.set_preference("general.useragent.override", MOBILE_USER_AGENT) options.set_preference("general.useragent.override", MOBILE_USER_AGENT)
driver.set_window_size(1070 + hash(_mail)%20 , 1900 + hash(_password + "salt")%10) # mobile resolution are crazy high now, right ?
else : else :
options.set_preference("general.useragent.override", PC_USER_AGENT) options.set_preference("general.useragent.override", PC_USER_AGENT)
driver.set_window_size(1900 + hash(_mail)%20 , 1070 + hash(_password + "salt")%10)
driver = webdriver.Firefox(options=options) driver = webdriver.Firefox(options=options)
driver.set_window_size(1900 + hash(_mail)%20 , 1070 + hash(_password + "salt")%10)
return(driver) return(driver)
@ -269,6 +271,13 @@ def all_cards():
printf(f"DailyCard {titre} ok") printf(f"DailyCard {titre} ok")
except Exception as e: except Exception as e:
printf(f"all_cards card {titre} error ({e})") printf(f"all_cards card {titre} error ({e})")
""" Check if everything worked fine TODO
try : # devrait renvoyer vrai si la carte i est faite ou pas, a l'aide su symbole en haut a droite de la carte
elm = driver.get(By.XPATH, f"/html/body/div/div/div[3]/div[2]/div[1]/div[2]/div/div[{i+1}]/a/div/div[2]/div[1]/div[2]/div")
print("complete" in elm.get_attribute("innerHTML"))
except :
pass
"""
except Exception as e: except Exception as e:
log_error(e, driver, _mail) log_error(e, driver, _mail)
@ -443,7 +452,13 @@ def login():
print(f"element {i} not found") print(f"element {i} not found")
rgpd_popup() rgpd_popup()
custom_sleep(uniform(3,5)) custom_sleep(uniform(3,5))
driver.get("https://www.bing.com/rewardsapp/flyout") driver.get("https://www.bing.com/rewardsapp/flyout")
try:
driver.find_element(By.CSS_SELECTOR, '[title="Rejoindre maintenant"]').click() # depend of the language of the page
except:
print(f"unlock test: fail, probably normal")
print('on MsRewards') print('on MsRewards')
for _ in range(3) : for _ in range(3) :
@ -640,10 +655,19 @@ def fidelity():
def mobile_login(error): def mobile_login(error):
try: try:
# TODO
# aller direct sur bin pour ne pas avoir a utiliser le menu hamburger
mobile_driver.get("https://www.bing.com/search?q=test+speed") mobile_driver.get("https://www.bing.com/search?q=test+speed")
mobile_rgpd() mobile_rgpd()
printf("start of Mobile login") printf("start of Mobile login")
mobile_driver.find_element(By.ID, "mHamburger").click() try :
mobile_driver.find_element(By.ID, "mHamburger").click()
except Exception as e :
log_error(f"trying something. 1 {e}", mobile_driver, _mail)
mobile_driver.find_element(By.TAG_NAME, "body").send_keys(Keys.UP) #force apparition of hamurger menu
log_error(f"trying something. 2 {e}", mobile_driver, _mail)
mobile_driver.find_element(By.ID, "mHamburger").click()
wait_until_visible(By.ID, "hb_s", browser=mobile_driver) wait_until_visible(By.ID, "hb_s", browser=mobile_driver)
mobile_driver.find_element(By.ID, "hb_s").click() mobile_driver.find_element(By.ID, "hb_s").click()
wait_until_visible(By.ID, "i0116", browser=mobile_driver) wait_until_visible(By.ID, "i0116", browser=mobile_driver)