Python 3.10 whouhou

This commit is contained in:
piair 2021-12-23 16:34:32 +01:00
parent b2beda0cfe
commit ec881143cd

83
V4.py
View File

@ -4,11 +4,9 @@ from time import sleep
from random import uniform, choice, randint,shuffle from random import uniform, choice, randint,shuffle
from re import search,findall from re import search,findall
from os import path, sys, system from os import path, sys, system
from requests import get
import discord import discord
import asyncio import asyncio
from sys import platform, exc_info from sys import platform
from socket import gethostbyname
from csv import reader from csv import reader
from selenium import webdriver from selenium import webdriver
@ -55,9 +53,9 @@ def FirefoxMobile(Headless = Headless):
MobileProfile = webdriver.FirefoxProfile() MobileProfile = webdriver.FirefoxProfile()
MobileProfile.set_preference("general.useragent.override", MOBILE_USER_AGENT) MobileProfile.set_preference("general.useragent.override", MOBILE_USER_AGENT)
options.profile = MobileProfile
return(webdriver.Firefox(options=options, firefox_profile=MobileProfile, service_log_path=os.devnull)) return(webdriver.Firefox(options=options, service_log_path=os.devnull))
def FirefoxPC(Headless = Headless): def FirefoxPC(Headless = Headless):
@ -73,14 +71,15 @@ def FirefoxPC(Headless = Headless):
PcProfile = webdriver.FirefoxProfile() PcProfile = webdriver.FirefoxProfile()
PcProfile.set_preference("general.useragent.override", PC_USER_AGENT) PcProfile.set_preference("general.useragent.override", PC_USER_AGENT)
options.profile= PcProfile
return(webdriver.Firefox(options=options, firefox_profile=PcProfile,service_log_path=os.devnull)) return(webdriver.Firefox(options=options,service_log_path=os.devnull))
if IsLinux : if IsLinux :
MotPath = "/home/pi/MsReward/liste.txt" MotPath = "./liste.txt"
LogPath= "/home/pi/MsReward/login.csv" LogPath= "./login.csv"
TokenPath = "/home/pi/MsReward/token.txt" TokenPath = "./token.txt"
else : else :
MotPath = resource_path('D:\Documents\Dev\MsReward\liste/liste.txt') MotPath = resource_path('D:\Documents\Dev\MsReward\liste/liste.txt')
LogPath = resource_path('D:\Documents\Dev\MsReward\login/login.csv') LogPath = resource_path('D:\Documents\Dev\MsReward\login/login.csv')
@ -352,7 +351,7 @@ def AllCard(): #fonction qui repere le type de contenue et redireige sur la bonn
if c ==20 : if c ==20 :
break break
try : try :
link = findall('href="([^<]+)" title=""',driver.page_source)[3] link = findall('href="([^<]+)" title=""',driver.page_source)[3] #verifie si on a toujours des cartes
except : except :
break break
except Exception as e: except Exception as e:
@ -548,40 +547,39 @@ def BingMobileSearch(override = randint(20,25)):
def TryPlay(nom ="inconnu"): def TryPlay(nom ="inconnu"):
RGPD() RGPD()
def play(number, override = -1) :
match number :
case 9 :
try :
print(f'Quiz 8 détécté sur la page {nom}')
RGPD()
PlayQuiz8()
except Exception as e :
printf(f'echec de PlayQuiz 8. Aborted {e}')
case 5 :
try :
print(f'Quiz 4 détécté sur la page {nom}')
RGPD()
PlayQuiz4()
print('Quiz 4 reussit')
except Exception as e :
printf(f'echec de PlayQuiz 4. Aborted {e}')
case 3 :
try :
RGPD()
print(f'Quiz 2 détécté sur la page {nom}')
PlayQuiz2()
except Exception as e :
printf(f'echec de PlayQuiz 2. Aborted {e}')
case _ :
LogError('probleme dans la carte : il y a un bouton play et aucun quiz')
try : try :
driver.find_element_by_id('rqStartQuiz').click() #start the quiz driver.find_element_by_id('rqStartQuiz').click() #start the quiz
number = driver.page_source.count('rqAnswerOption') number = driver.page_source.count('rqAnswerOption')
play(number)
if number == 9:
try :
print(f'Quiz 8 détécté sur la page {nom}')
RGPD()
PlayQuiz8()
except Exception as e :
printf(f'echec de PlayQuiz 8. Aborted {e}')
elif number == 5 :
try :
print(f'Quiz 4 détécté sur la page {nom}')
RGPD()
PlayQuiz4()
print('Quiz 4 reussit')
except Exception as e :
printf(f'echec de PlayQuiz 4. Aborted {e}')
elif number == 3 :
try :
RGPD()
print(f'Quiz 2 détécté sur la page {nom}')
PlayQuiz2()
except Exception as e :
printf(f'echec de PlayQuiz 2. Aborted {e}')
else :
LogError('probleme dans la carte : il y a un bouton play et aucun quiz')
except : except :
if "bt_PollRadio" in driver.page_source : if "bt_PollRadio" in driver.page_source :
try : try :
print('Poll détected', end ="\r") print('Poll détected', end ="\r")
@ -590,6 +588,9 @@ 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 :
printf("recover détécté")
number = driver.page_source.count('rqAnswerOption')
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é')
@ -738,7 +739,7 @@ for i in Credentials :
driver.quit() driver.quit()
timer = uniform(120,360) timer = uniform(120,360)
print(f"finis. attente de {timer}s") print(f"finis. attente de {timer}s")
CustomSleep() CustomSleep(timer)
except KeyboardInterrupt : except KeyboardInterrupt :
print('canceled') print('canceled')