fixed PlayQuizz8 (most likely ?)

This commit is contained in:
piair 2023-03-12 11:22:49 +01:00
parent cef0204868
commit 84898cee76
2 changed files with 17 additions and 14 deletions

19
V5.py
View File

@ -36,10 +36,9 @@ def printf(e, f = ""):
print(e+f) print(e+f)
# TODO # TODO
# remove points from database when a reward is claimed
# remove the auto-claim feature as it seams to create huge risk of ban
# handle "panda"'s error: error while logging in preventing some task to be done # handle "panda"'s error: error while logging in preventing some task to be done
# replace driver's screenshot by Display's one # replace driver's screenshot by Display's one
# test PlayQuiz8 fix
custom_sleep = CustomSleep custom_sleep = CustomSleep
# Wait for the presence of the element identifier or [timeout]s # Wait for the presence of the element identifier or [timeout]s
@ -75,7 +74,6 @@ def firefox_driver(mobile=False, Headless=False):
"AppleWebKit/605.1.15 (KHTML, like Gecko)" "AppleWebKit/605.1.15 (KHTML, like Gecko)"
"CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1" "CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1"
) )
options = Options() options = Options()
options.set_preference('intl.accept_languages', 'fr-FR, fr') options.set_preference('intl.accept_languages', 'fr-FR, fr')
if proxy_enabled : if proxy_enabled :
@ -154,10 +152,15 @@ def play_quiz8(task = None):
rgpd_popup() rgpd_popup()
for _ in range(override): for _ in range(override):
custom_sleep(uniform(3, 5)) custom_sleep(uniform(3, 5))
answers_list = [ (driver.find_element(By.ID, f"rqAnswerOption{i-1}"),f'rqAnswerOption{i-1}') for i in range(1,9)] correct_answers = []
correct_answers = [x[1] for x in answers_list if 'iscorrectoption="True" ' in x[0].get_attribute("outerHTML") ] for i in range(1,9):
try :
element = driver.find_element(By.ID, f"rqAnswerOption{i-1}")
if 'iscorrectoption="True"' in element.get_attribute("outerHTML"):
correct_answers.append(f'rqAnswerOption{i-1}')
except Exception as e :
printf(f"can't find rqAnswerOption{i-1}. Probably already clicked" + str(e))
shuffle(correct_answers) shuffle(correct_answers)
for answer_id in correct_answers: for answer_id in correct_answers:
wait_until_visible(By.ID, answer_id, timeout = 20, browser=driver) wait_until_visible(By.ID, answer_id, timeout = 20, browser=driver)
counter += 1 counter += 1
@ -178,7 +181,7 @@ def play_quiz8(task = None):
correct_answers.append(answer_id) correct_answers.append(answer_id)
except Exception as e: except Exception as e:
LogError(f"play_quiz8 - 4 - {e} \n Good answers : {' '.join(answer_id)}", driver, _mail) LogError(f"play_quiz8 - 4 - {e} \n Good answers : {' '.join(correct_answers)}", driver, _mail)
printf("play_quiz8 : fin ") printf("play_quiz8 : fin ")
@ -934,7 +937,7 @@ else:
driver.quit() driver.quit()
display.stop() display.stop()
except Exception as e: except Exception as e:
print(f"error not catched. skipping this account. {e}") print(f"error not catch. skipping this account. {e}")
driver.quit() driver.quit()

View File

@ -1,5 +1,5 @@
from time import sleep from time import sleep
from datetime import timedelta from datetime import timedelta, datetime
from random import uniform from random import uniform
import discord import discord
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
@ -7,6 +7,7 @@ from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAd
Webhook, Webhook,
) )
from selenium.webdriver.common.by import By
from modules.config import * from modules.config import *
""" """
@ -50,10 +51,9 @@ def LogError(message, driver, mail, log=FULL_LOG):
# add the time arround the text given in [text] # add the time arround the text given in [text]&
# [text] : string def Timer(text: str, mail: str) -> str:
def Timer(text, mail): return(f"[{mail} - {datetime.today().strftime('%d-%m-%Y')} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
return(f"[{mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
# replace the function print, with more options # replace the function print, with more options
@ -69,7 +69,7 @@ def printf2(txt, mail, LOG = LOG):
def check_ipv4(driver): def check_ipv4(driver):
driver.get("https://api64.ipify.org") driver.get("https://api64.ipify.org")
elm = driver.find_element(BY.TAG_NAME, "body") elm = driver.find_element(By.TAG_NAME, "body")
if len(elm.text.split('.')) == 4 : if len(elm.text.split('.')) == 4 :
return True return True
return False return False