add a recover fonction for failed quiz
This commit is contained in:
parent
ab99eec6e7
commit
f2e6840d52
42
V4.py
42
V4.py
@ -171,9 +171,11 @@ def RGPD():
|
|||||||
driver.implicitly_wait(5)
|
driver.implicitly_wait(5)
|
||||||
|
|
||||||
|
|
||||||
def PlayQuiz2():
|
def PlayQuiz2(override = None):
|
||||||
|
if not override :
|
||||||
|
override = 10
|
||||||
|
|
||||||
for j in range (10):
|
for j in range (override):
|
||||||
try :
|
try :
|
||||||
CustomSleep(uniform(3,5))
|
CustomSleep(uniform(3,5))
|
||||||
|
|
||||||
@ -208,13 +210,14 @@ def PlayQuiz2():
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def PlayQuiz8():
|
def PlayQuiz8(override = None):
|
||||||
|
if not override :
|
||||||
|
override = 3
|
||||||
try :
|
try :
|
||||||
#RGPD()
|
#RGPD()
|
||||||
|
|
||||||
c = 0
|
c = 0
|
||||||
for i in range(3):
|
for i in range(override):
|
||||||
sleep(uniform(3,5))
|
sleep(uniform(3,5))
|
||||||
ListeOfGood =[]
|
ListeOfGood =[]
|
||||||
for i in range(1,9):
|
for i in range(1,9):
|
||||||
@ -239,15 +242,17 @@ def PlayQuiz8():
|
|||||||
LogError("PlayQuiz8" + str(e) + str(ListeOfGood))
|
LogError("PlayQuiz8" + str(e) + str(ListeOfGood))
|
||||||
|
|
||||||
|
|
||||||
def PlayQuiz4():
|
def PlayQuiz4(override = None):
|
||||||
try : #permet de gerer les truc de fidélité
|
if not override :
|
||||||
max = int(findall("rqQuestionState([\d]{1,2})\"", driver.page_source)[-1])
|
try : #permet de gerer les truc de fidélité, qui sont plus long
|
||||||
|
override = int(findall("rqQuestionState([\d]{1,2})\"", driver.page_source)[-1])
|
||||||
except :
|
except :
|
||||||
max = 3
|
override = 3
|
||||||
|
|
||||||
try :
|
try :
|
||||||
|
|
||||||
|
|
||||||
for i in range(max):
|
for i in range(override):
|
||||||
#RGPD()
|
#RGPD()
|
||||||
CustomSleep(uniform(3,5))
|
CustomSleep(uniform(3,5))
|
||||||
txt = driver.page_source
|
txt = driver.page_source
|
||||||
@ -257,7 +262,7 @@ def PlayQuiz4():
|
|||||||
|
|
||||||
|
|
||||||
print(f"validation de la reponse " , end="\r")
|
print(f"validation de la reponse " , end="\r")
|
||||||
print(f"validation de la reponse {i+1}/{max} {reponse}" , end="\r")
|
print(f"validation de la reponse {i+1}/{override} {reponse}" , end="\r")
|
||||||
try :
|
try :
|
||||||
elem = driver.find_element_by_css_selector(f'[data-option="{reponse}"]')
|
elem = driver.find_element_by_css_selector(f'[data-option="{reponse}"]')
|
||||||
elem.click()
|
elem.click()
|
||||||
@ -284,7 +289,7 @@ def PlayPoll():
|
|||||||
raise ValueError(e)
|
raise ValueError(e)
|
||||||
|
|
||||||
|
|
||||||
def AllCard(): #fonction qui repere le type de contenue et redireige sur la bonne fonction
|
def AllCard(): #fonction qui clique sur les cartes
|
||||||
|
|
||||||
def reset(Partie2=False): #retourne sur la page de depart apres avoir finis
|
def reset(Partie2=False): #retourne sur la page de depart apres avoir finis
|
||||||
if len(driver.window_handles) == 1 :
|
if len(driver.window_handles) == 1 :
|
||||||
@ -539,20 +544,20 @@ def BingMobileSearch(override = randint(20,25)):
|
|||||||
def TryPlay(nom ="inconnu"):
|
def TryPlay(nom ="inconnu"):
|
||||||
|
|
||||||
RGPD()
|
RGPD()
|
||||||
def play(number, override = -1) :
|
def play(number, override = None) :
|
||||||
match number :
|
match number :
|
||||||
case 9 :
|
case 9 :
|
||||||
try :
|
try :
|
||||||
print(f'Quiz 8 détécté sur la page {nom}')
|
print(f'Quiz 8 détécté sur la page {nom}')
|
||||||
RGPD()
|
RGPD()
|
||||||
PlayQuiz8()
|
PlayQuiz8(override)
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
printf(f'echec de PlayQuiz 8. Aborted {e}')
|
printf(f'echec de PlayQuiz 8. Aborted {e}')
|
||||||
case 5 :
|
case 5 :
|
||||||
try :
|
try :
|
||||||
print(f'Quiz 4 détécté sur la page {nom}')
|
print(f'Quiz 4 détécté sur la page {nom}')
|
||||||
RGPD()
|
RGPD()
|
||||||
PlayQuiz4()
|
PlayQuiz4(override)
|
||||||
print('Quiz 4 reussit')
|
print('Quiz 4 reussit')
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
printf(f'echec de PlayQuiz 4. Aborted {e}')
|
printf(f'echec de PlayQuiz 4. Aborted {e}')
|
||||||
@ -560,7 +565,7 @@ def TryPlay(nom ="inconnu"):
|
|||||||
try :
|
try :
|
||||||
RGPD()
|
RGPD()
|
||||||
print(f'Quiz 2 détécté sur la page {nom}')
|
print(f'Quiz 2 détécté sur la page {nom}')
|
||||||
PlayQuiz2()
|
PlayQuiz2(override)
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
printf(f'echec de PlayQuiz 2. Aborted {e}')
|
printf(f'echec de PlayQuiz 2. Aborted {e}')
|
||||||
case _ :
|
case _ :
|
||||||
@ -580,9 +585,12 @@ def TryPlay(nom ="inconnu"):
|
|||||||
print('Poll reussit ')
|
print('Poll reussit ')
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
printf(f'Poll aborted {e}')
|
printf(f'Poll aborted {e}')
|
||||||
|
|
||||||
elif "rqQuestionState" in driver.page_source :
|
elif "rqQuestionState" in driver.page_source :
|
||||||
printf("recover détécté")
|
printf("recovery détécté")
|
||||||
number = driver.page_source.count('rqAnswerOption')
|
number = driver.page_source.count('rqAnswerOption')
|
||||||
|
restant = len(findall("\"rqQuestionState.?.\" class=", driver.page_source)) - len(findall("\"rqQuestionState.?.\" class=\"filledCircle\"", driver.page_source))
|
||||||
|
play(number, override=restant + 1 )
|
||||||
|
|
||||||
elif search("([0-9]) de ([0-9]) finalisée",driver.page_source) :
|
elif search("([0-9]) de ([0-9]) finalisée",driver.page_source) :
|
||||||
print('fidélité')
|
print('fidélité')
|
||||||
|
Loading…
Reference in New Issue
Block a user