2021-12-22 14:01:58 +01:00
#!/usr/bin/python3
2021-12-22 17:09:18 +01:00
import os
2021-12-22 14:01:58 +01:00
from time import sleep
from random import uniform , choice , randint , shuffle
from re import search , findall
from os import path , sys , system
import discord
import asyncio
2021-12-23 16:34:32 +01:00
from sys import platform
2021-12-23 16:45:57 +01:00
from csv import reader
2021-12-22 14:01:58 +01:00
from selenium import webdriver
from selenium . webdriver . firefox . options import Options
from selenium . webdriver . common . keys import Keys
from selenium . webdriver . common . by import By
from selenium . webdriver . support . ui import WebDriverWait
from selenium . webdriver . support import expected_conditions as EC
from selenium . common import exceptions
2021-12-22 17:01:00 +01:00
main = True
2021-12-22 17:09:18 +01:00
Headless = True
2021-12-24 12:17:10 +01:00
Log = False
2021-12-23 13:05:16 +01:00
def printf ( txt ) :
2021-12-23 13:28:14 +01:00
if not Log :
2021-12-23 13:05:16 +01:00
print ( txt )
else :
2021-12-23 14:06:00 +01:00
CustomSleep ( 5 )
2021-12-23 13:05:16 +01:00
LogError ( txt )
2021-12-22 14:01:58 +01:00
IsLinux = platform == " linux "
print ( " Linux : " + str ( IsLinux ) )
def resource_path ( relative_path ) : #permet de recuperer l'emplacement de chaque fichier, su linux et windows
try :
base_path = sys . _MEIPASS
except Exception :
base_path = path . dirname ( __file__ )
return path . join ( base_path , relative_path )
def FirefoxMobile ( Headless = Headless ) :
MOBILE_USER_AGENT = ( ' Mozilla/5.0 (iPhone; CPU iPhone OS 14_1_2 like Mac OS X) '
' AppleWebKit/603.1.30 (KHTML, like Gecko) '
' Version/14.1 Mobile/14E304 Safari/602.1 ' )
options = Options ( )
options . set_preference ( " browser.link.open_newwindow " , 3 )
if Headless :
2021-12-23 17:13:17 +01:00
options . add_argument ( " -headless " )
2021-12-23 16:45:57 +01:00
options . set_preference ( " general.useragent.override " , MOBILE_USER_AGENT )
2021-12-23 17:13:17 +01:00
return ( webdriver . Firefox ( options = options ) )
2021-12-22 14:01:58 +01:00
def FirefoxPC ( Headless = Headless ) :
PC_USER_AGENT = ( ' Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
' AppleWebKit/537.36 (KHTML, like Gecko) '
' Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134 ' )
options = Options ( )
options . set_preference ( " browser.link.open_newwindow " , 3 )
if Headless :
options . add_argument ( " -headless " )
2021-12-23 16:45:57 +01:00
options . set_preference ( " general.useragent.override " , PC_USER_AGENT )
2021-12-23 17:13:17 +01:00
return ( webdriver . Firefox ( options = options ) )
2021-12-22 14:01:58 +01:00
if IsLinux :
2021-12-24 12:22:28 +01:00
MotPath = " /home/pi/MsReward/liste.txt "
2021-12-24 12:22:43 +01:00
LogPath = " /home/pi/MsReward/login.csv "
TokenPath = " /home/pi/MsReward/token.txt "
2021-12-22 14:01:58 +01:00
else :
2021-12-22 17:01:00 +01:00
MotPath = resource_path ( ' D: \ Documents \ Dev \ MsReward \ liste/liste.txt ' )
LogPath = resource_path ( ' D: \ Documents \ Dev \ MsReward \ login/login.csv ' )
TokenPath = resource_path ( ' D: \ Documents \ Dev \ MsReward/token/token.txt ' )
2021-12-22 14:01:58 +01:00
system ( " " )
g = open ( MotPath , " r " , encoding = " utf-8 " )
Liste_de_mot = ( list ( g . readline ( ) . split ( ' , ' ) ) )
g . close ( )
2021-12-22 14:39:20 +01:00
g = open ( TokenPath , " r " )
Token = g . readline ( )
g . close
2021-12-22 14:01:58 +01:00
def CustomSleep ( temps ) :
2021-12-27 18:04:58 +01:00
if Log or not IsLinux :
c = False
points = [ " . " , " . " , " . " , " . " , " . " , " . " , " . " , " . " ]
for i in range ( int ( temps ) ) :
c = True
for i in range ( 8 ) :
sleep ( 0.125 )
print ( points [ i ] , end = ' \r ' )
if c :
print ( ' ' , end = " \r " )
sleep ( temps - int ( temps ) )
print ( " \n " )
else :
sleep ( temps )
2021-12-22 14:01:58 +01:00
2021-12-29 11:51:08 +01:00
2021-12-28 11:31:35 +01:00
def ListTabs ( Mdriver = None ) :
2021-12-22 14:01:58 +01:00
tabs = [ ]
2021-12-28 11:31:35 +01:00
if Mdriver :
2021-12-29 11:08:15 +01:00
ldriver = Mdriver
else :
ldriver = driver
for i in ldriver . window_handles :
ldriver . switch_to . window ( i )
tabs . append ( ldriver . current_url )
2021-12-22 14:01:58 +01:00
return ( tabs )
2021-12-29 10:54:25 +01:00
def LogError ( message , log = Log , Mobdriver = None ) :
if Mobdriver :
gdriver = Mobdriver
else :
gdriver = driver
2021-12-28 11:31:35 +01:00
2021-12-22 14:01:58 +01:00
if not IsLinux :
asyncio . set_event_loop_policy ( asyncio . WindowsSelectorEventLoopPolicy ( ) )
print ( f ' \033 [93m Erreur : { str ( message ) } \033 [0m ' )
else :
with open ( ' page.html ' , ' w ' ) as f :
2021-12-29 10:54:25 +01:00
f . write ( gdriver . page_source )
2021-12-22 14:01:58 +01:00
2021-12-29 10:54:25 +01:00
gdriver . save_screenshot ( " screenshot.png " )
2021-12-22 14:01:58 +01:00
asyncio . set_event_loop ( asyncio . new_event_loop ( ) )
client = discord . Client ( )
@client.event
async def on_ready ( ) :
channel = client . get_channel ( 861181899987484692 )
if log :
channel = client . get_channel ( 833275838837030912 ) #channel de log
2021-12-23 13:51:07 +01:00
await channel . send ( " ------------------------------------ \n " + _mail )
2021-12-22 14:01:58 +01:00
2021-12-29 10:54:25 +01:00
await channel . send ( ListTabs ( Mdriver = Mobdriver ) )
2021-12-22 14:01:58 +01:00
await channel . send ( str ( message ) )
CustomSleep ( 1 )
await channel . send ( file = discord . File ( ' screenshot.png ' ) )
await channel . send ( file = discord . File ( ' page.html ' ) )
2021-12-23 13:51:07 +01:00
await channel . send ( " ------------------------------------ " )
2021-12-22 14:01:58 +01:00
await client . close ( )
2021-12-22 14:39:20 +01:00
client . run ( Token )
2021-12-22 14:01:58 +01:00
def progressBar ( current , total = 30 , barLength = 20 , name = " Progress " ) :
percent = float ( current + 1 ) * 100 / total
arrow = ' - ' * int ( percent / 100 * barLength - 1 ) + ' > '
spaces = ' ' * ( barLength - len ( arrow ) )
print ( name + ' : [ %s %s ] %d %% ' % ( arrow , spaces , percent ) , end = ' \r ' )
def Close ( fenetre , SwitchTo = 0 ) :
driver . switch_to . window ( fenetre )
driver . close ( )
driver . switch_to . window ( driver . window_handles [ SwitchTo ] )
def RGPD ( ) :
driver . implicitly_wait ( 3 )
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' bnp_btn_accept ' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
pass
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' bnp_hfly_cta2 ' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
pass
driver . implicitly_wait ( 5 )
2021-12-23 17:36:53 +01:00
def PlayQuiz2 ( override = None ) :
if not override :
override = 10
for j in range ( override ) :
2021-12-22 14:01:58 +01:00
try :
CustomSleep ( uniform ( 3 , 5 ) )
txt = driver . page_source
IG = search ( ' IG: \" ([^ \" ]+) \" ' , txt ) [ 1 ] #variable dans la page, pour calculer le offset
reponse1 = search ( " data-option= \" ([^ \" ]+) \" " , txt ) [ 1 ]
offset = int ( IG [ - 2 : ] , 16 ) # la conversion ec decimal des deux dernier caracteres de IG
reponse = search ( " correctAnswer \" : \" ([0-9]+) " , txt ) [ 1 ]
somme = 0
for i in reponse1 :
somme + = ord ( i )
RGPD ( )
if somme + offset == int ( reponse ) :
2021-12-24 10:56:40 +01:00
elem = driver . find_element ( By . ID , ' rqAnswerOption0 ' )
2021-12-22 14:01:58 +01:00
elem . click ( )
progressBar ( j , 10 , name = " quiz 2 " )
else :
2021-12-24 10:56:40 +01:00
elem = driver . find_element ( By . ID , ' rqAnswerOption1 ' )
2021-12-22 14:01:58 +01:00
elem . click ( )
progressBar ( j , 10 , name = " quiz 2 " )
except exceptions . ElementNotInteractableException as e :
driver . execute_script ( " arguments[0].click(); " , elem )
except Exception as e :
LogError ( " PlayQuiz2 " + str ( e ) )
break
2021-12-23 17:36:53 +01:00
def PlayQuiz8 ( override = None ) :
2021-12-24 21:00:25 +01:00
2021-12-23 17:36:53 +01:00
if not override :
override = 3
2021-12-24 21:00:25 +01:00
print ( f " override : { override } " )
2021-12-22 14:01:58 +01:00
try :
#RGPD()
c = 0
2021-12-23 17:36:53 +01:00
for i in range ( override ) :
2021-12-22 14:01:58 +01:00
sleep ( uniform ( 3 , 5 ) )
ListeOfGood = [ ]
for i in range ( 1 , 9 ) :
2021-12-23 17:55:04 +01:00
try :
2021-12-24 10:56:40 +01:00
Card = driver . find_element ( By . ID , f ' rqAnswerOption { i - 1 } ' )
2021-12-23 17:55:04 +01:00
if ' iscorrectoption= " True " ' in Card . get_attribute ( ' outerHTML ' ) :
ListeOfGood . append ( f ' rqAnswerOption { i - 1 } ' ) #premier div = 3 ?
except Exception as e :
if override :
2021-12-24 21:00:25 +01:00
LogError ( e )
2021-12-23 17:55:04 +01:00
else :
LogError ( e )
2021-12-22 14:01:58 +01:00
shuffle ( ListeOfGood )
for i in ListeOfGood :
sleep ( uniform ( 3 , 5 ) )
c + = 1
progressBar ( c , 16 , name = " Quiz 8 " )
try :
2021-12-24 10:56:40 +01:00
elem = driver . find_element ( By . ID , i )
2021-12-22 14:01:58 +01:00
elem . click ( )
except exceptions . ElementNotInteractableException as e :
2021-12-25 10:54:47 +01:00
try :
driver . execute_script ( " arguments[0].click(); " , elem )
except Exception as e :
LogError ( e )
2021-12-25 10:52:20 +01:00
except Exception as e :
if override :
printf ( e )
else :
LogError ( e )
2021-12-22 14:01:58 +01:00
except Exception as e :
LogError ( " PlayQuiz8 " + str ( e ) + str ( ListeOfGood ) )
2021-12-23 17:36:53 +01:00
def PlayQuiz4 ( override = None ) :
if not override :
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 :
override = 3
2021-12-22 14:01:58 +01:00
try :
2021-12-23 17:36:53 +01:00
for i in range ( override ) :
2021-12-22 14:01:58 +01:00
#RGPD()
2021-12-23 14:06:00 +01:00
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-22 14:01:58 +01:00
txt = driver . page_source
reponse = search ( " correctAnswer \" : \" ([^ \" ]+) " , txt ) [ 1 ] #je suis pas sur qu'il y ait un espace
reponse = reponse . replace ( ' \\ u0027 ' , " ' " ) #il faut cancel l'unicode avec un double \ (on replacer les caracteres en unicode en caracteres utf-8)
print ( f " validation de la reponse " , end = " \r " )
2021-12-23 17:36:53 +01:00
print ( f " validation de la reponse { i + 1 } / { override } { reponse } " , end = " \r " )
2021-12-22 14:01:58 +01:00
try :
2021-12-24 10:56:40 +01:00
elem = driver . find_element ( By . CSS_SELECTOR , f ' [data-option= " { reponse } " ] ' )
2021-12-22 14:01:58 +01:00
elem . click ( )
except exceptions . ElementNotInteractableException :
driver . execute_script ( " arguments[0].click(); " , elem )
2021-12-23 14:06:00 +01:00
2021-12-22 14:01:58 +01:00
except Exception as e :
LogError ( " PlayQuiz4 " + str ( e ) )
raise ValueError ( e )
def PlayPoll ( ) :
try :
try :
2021-12-24 10:56:40 +01:00
elem = driver . find_element ( By . ID , f ' btoption { choice ( [ 0 , 1 ] ) } ' )
2021-12-22 14:01:58 +01:00
elem . click ( )
except exceptions . ElementNotInteractableException as e :
driver . execute_script ( " arguments[0].click(); " , elem )
CustomSleep ( uniform ( 2 , 2.5 ) )
except Exception as e :
LogError ( " PlayPoll " + str ( e ) )
raise ValueError ( e )
2021-12-23 17:36:53 +01:00
def AllCard ( ) : #fonction qui clique sur les cartes
2021-12-22 14:01:58 +01:00
2021-12-23 13:51:07 +01:00
def reset ( Partie2 = False ) : #retourne sur la page de depart apres avoir finis
2021-12-22 14:01:58 +01:00
if len ( driver . window_handles ) == 1 :
driver . get ( ' https://www.bing.com/rewardsapp/flyout ' )
2021-12-23 13:51:07 +01:00
if Partie2 :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . XPATH , ' /html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1] ' ) . click ( )
2021-12-22 14:01:58 +01:00
else :
driver . switch_to . window ( driver . window_handles [ 1 ] )
print ( f " on ferme la fenetre { driver . current_url } " )
driver . close ( )
driver . switch_to . window ( driver . window_handles [ 0 ] )
2021-12-23 13:51:07 +01:00
reset ( Partie2 )
2021-12-22 14:01:58 +01:00
def dailyCards ( ) :
try :
for i in range ( 3 ) :
sleep ( 1 )
2021-12-24 10:56:40 +01:00
driver . find_element ( By . XPATH , f ' /html/body/div/div/div[3]/div[2]/div[1]/div[2]/div/div[ { i + 1 } ]/a/div/div[2] ' ) . click ( )
2021-12-22 14:01:58 +01:00
sleep ( 1 )
2021-12-23 13:05:16 +01:00
TryPlay ( driver . title )
2021-12-22 14:01:58 +01:00
sleep ( 1 )
reset ( )
2021-12-23 14:06:00 +01:00
printf ( f " carte { i } ok " )
2021-12-22 14:01:58 +01:00
except Exception as e :
2021-12-23 14:06:00 +01:00
LogError ( f ' erreur dans la premiere partie de AllCard (les daily card). cela arrive si on relance le proramme une deuxieme fois sur le meme compte \n { e } ' )
2021-12-22 14:01:58 +01:00
dailyCards ( )
try :
2021-12-23 13:51:07 +01:00
2021-12-22 14:01:58 +01:00
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . XPATH , ' /html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1] ' ) . click ( ) #declenche la premiere partie ?
2021-12-22 14:01:58 +01:00
except :
reset ( )
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . XPATH , ' /html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1] ' ) . click ( ) #declenche la deuxieme partie ?
2021-12-22 14:01:58 +01:00
except :
pass
c = 0
while True :
2021-12-23 13:51:07 +01:00
printf ( " debut de l ' une des cartes " )
2021-12-24 10:56:40 +01:00
driver . find_element ( By . XPATH , ' /html/body/div/div/div[3]/div[2]/div[2]/div[3]/div/div[1]/a/div/div[2] ' ) . click ( )
2021-12-23 13:51:07 +01:00
printf ( " carte cliqué " )
2021-12-22 14:01:58 +01:00
driver . switch_to . window ( driver . window_handles [ len ( driver . window_handles ) - 1 ] )
sleep ( 1 )
2021-12-23 13:51:07 +01:00
try :
titre = driver . title
except Exception as e :
titre = " inconnu "
LogError ( f " impossible de recuperer le titre. { e } " )
TryPlay ( titre )
2021-12-22 14:01:58 +01:00
reset ( True )
sleep ( 1 )
c + = 1
if c == 20 :
break
try :
2021-12-23 16:34:32 +01:00
link = findall ( ' href= " ([^<]+) " title= " " ' , driver . page_source ) [ 3 ] #verifie si on a toujours des cartes
2021-12-22 14:01:58 +01:00
except :
break
except Exception as e :
LogError ( f ' 2eme partie de AllCard (weekly card) \n { e } ' )
def send_keys_wait ( element , keys ) :
for i in keys :
element . send_keys ( i )
CustomSleep ( uniform ( 0 , 0.5 ) )
def login ( ) :
try :
driver . get ( ' https://www.bing.com/rewardsapp/flyout ' )
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . CSS_SELECTOR , f ' [title= " Rejoindre " ] ' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . CSS_SELECTOR , f ' [title= " Join now " ] ' ) . click ( )
2021-12-22 14:01:58 +01:00
2021-12-24 10:56:40 +01:00
mail = driver . find_element ( By . ID , ' i0116 ' )
2021-12-22 14:01:58 +01:00
send_keys_wait ( mail , _mail )
mail . send_keys ( Keys . ENTER )
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' idChkBx_PWD_KMSI0Pwd ' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . CSS_SELECTOR , ''' [data-bind= " text: str[ ' CT_PWD_STR_KeepMeSignedInCB_Text ' ] " ] ''' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
pass
2021-12-22 17:01:00 +01:00
CustomSleep ( 3 )
2021-12-24 10:56:40 +01:00
pwd = driver . find_element ( By . ID , ' i0118 ' )
2021-12-22 14:01:58 +01:00
send_keys_wait ( pwd , _password )
pwd . send_keys ( Keys . ENTER )
2021-12-23 13:05:16 +01:00
CustomSleep ( 5 )
2021-12-22 14:01:58 +01:00
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' KmsiCheckboxField ' ) . click ( )
2021-12-22 17:01:00 +01:00
except Exception as e :
2021-12-23 13:30:30 +01:00
printf ( f " erreur validation bouton KmsiCheckboxField. pas forcement grave { e } " )
2021-12-23 13:05:16 +01:00
CustomSleep ( 5 )
2021-12-22 17:01:00 +01:00
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' idSIButton9 ' ) . click ( )
2021-12-23 13:30:30 +01:00
except Exception as e :
printf ( f " erreur validation bouton idSIButton9. pas forcement grave { e } " )
2021-12-23 13:28:14 +01:00
2021-12-23 13:05:16 +01:00
printf ( " login completed " )
2021-12-23 14:06:00 +01:00
2021-12-22 14:01:58 +01:00
RGPD ( )
driver . get ( ' https://www.bing.com/rewardsapp/flyout ' )
MainWindows = driver . current_window_handle
return ( MainWindows )
except Exception as e :
LogError ( e )
2022-01-07 17:56:01 +01:00
def BingPcSearch ( override = randint ( 35 , 40 ) ) :
2021-12-22 14:01:58 +01:00
driver . get ( f ' https://www.bing.com/search?q= { choice ( [ x for x in range ( 999999 ) ] ) } &form=QBLH&sp=-1&pq=test&sc=8-4&qs=n&sk=&cvid=1DB80744B71E40B8896F5C1AD2DE95E9 ' )
CustomSleep ( uniform ( 1 , 2 ) )
RGPD ( )
CustomSleep ( uniform ( 1 , 1.5 ) )
2021-12-24 10:56:40 +01:00
send_keys_wait ( driver . find_element ( By . ID , ' sb_form_q ' ) , Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE )
2021-12-22 14:01:58 +01:00
for i in range ( override ) :
mot = str ( Liste_de_mot [ randint ( 0 , 9999 ) ] )
try :
2021-12-24 10:56:40 +01:00
send_keys_wait ( driver . find_element ( By . ID , ' sb_form_q ' ) , mot )
driver . find_element ( By . ID , ' sb_form_q ' ) . send_keys ( Keys . ENTER )
2021-12-22 14:01:58 +01:00
except :
sleep ( 10 )
driver . refresh ( )
sleep ( 10 )
2021-12-24 10:56:40 +01:00
send_keys_wait ( driver . find_element ( By . ID , ' sb_form_q ' ) , mot )
driver . find_element ( By . ID , ' sb_form_q ' ) . send_keys ( Keys . ENTER )
2021-12-22 14:01:58 +01:00
progressBar ( i , override , name = " PC " )
sleep ( uniform ( 5 , 20 ) )
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' sb_form_q ' ) . clear ( )
2021-12-22 14:01:58 +01:00
except :
2021-12-23 13:05:16 +01:00
try :
driver . refresh ( )
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' sb_form_q ' ) . clear ( )
2021-12-23 13:05:16 +01:00
except Exception as e :
LogError ( f " BingPcSearch - clear la barre de recherche - { e } " )
2021-12-22 14:01:58 +01:00
print ( ' \n \n ' )
2022-01-07 17:56:01 +01:00
def BingMobileSearch ( override = randint ( 22 , 25 ) ) :
2021-12-29 13:37:33 +01:00
MobileDriver = " si il y a ca dans les logs, c ' est que Mobiledriver n ' a pas demarrer "
2021-12-22 14:01:58 +01:00
try :
2021-12-29 13:32:16 +01:00
try :
MobileDriver = FirefoxMobile ( )
except Exception as e :
sleep ( 30 )
LogError ( ' echec de la creation du driver mobile ' )
MobileDriver = FirefoxMobile ( )
2021-12-22 14:01:58 +01:00
echec = 0
def Mlogin ( echec ) :
try :
MobileDriver . get ( f ' https://www.bing.com/search?q= { choice ( [ x for x in range ( 999999 ) ] ) } &form=QBLH&sp=-1&pq=test&sc=8-4&qs=n&sk=&cvid=1DB80744B71E40B8896F5C1AD2DE95E9 ' )
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-24 10:56:40 +01:00
MobileDriver . find_element ( By . ID , ' mHamburger ' ) . click ( )
2021-12-22 14:01:58 +01:00
CustomSleep ( uniform ( 1 , 2 ) )
2021-12-24 10:56:40 +01:00
MobileDriver . find_element ( By . ID , ' hb_s ' ) . click ( )
2021-12-22 14:01:58 +01:00
CustomSleep ( uniform ( 1 , 2 ) )
2021-12-24 10:56:40 +01:00
mail = MobileDriver . find_element ( By . ID , ' i0116 ' )
2021-12-22 14:01:58 +01:00
send_keys_wait ( mail , _mail )
mail . send_keys ( Keys . ENTER )
CustomSleep ( uniform ( 1 , 2 ) )
2021-12-24 10:56:40 +01:00
#MobileDriver.find_element(By.ID, 'idLbl_PWD_KMSI_Cb').click()
pwd = MobileDriver . find_element ( By . ID , ' i0118 ' )
2021-12-22 14:01:58 +01:00
send_keys_wait ( pwd , _password )
pwd . send_keys ( Keys . ENTER )
2021-12-22 17:01:00 +01:00
except Exception as e :
2021-12-22 14:01:58 +01:00
echec + = 1
if echec < = 3 :
2021-12-23 13:05:16 +01:00
printf ( f ' echec du login sur la version mobile. on reesaye ( { echec } /3), { e } ' )
2021-12-22 14:01:58 +01:00
CustomSleep ( uniform ( 5 , 10 ) )
Mlogin ( echec )
else :
2021-12-29 11:51:08 +01:00
LogError ( ' recherche sur mobile impossible. On skip \n \n \n \n \n \n \n \n ' , Mobdriver = MobileDriver )
LogError ( f " login impossible 3 fois de suite. { e } " , Mobdriver = MobileDriver )
2021-12-22 14:01:58 +01:00
MobileDriver . quit ( )
2021-12-22 17:01:00 +01:00
return ( True )
2021-12-22 14:01:58 +01:00
def MRGPD ( ) :
try :
2021-12-24 10:56:40 +01:00
MobileDriver . find_element ( By . ID , ' bnp_btn_accept ' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
pass
try :
2021-12-24 10:56:40 +01:00
MobileDriver . find_element ( By . ID , ' bnp_hfly_cta2 ' ) . click ( )
2021-12-22 14:01:58 +01:00
except :
pass
def Alerte ( ) :
try :
alert = MobileDriver . switch_to . alert
alert . dismiss ( )
except exceptions . NoAlertPresentException as e :
pass
2021-12-23 13:05:16 +01:00
except Exception as e :
2021-12-29 11:51:08 +01:00
LogError ( f " error sur une alerte dans le driver mobile. { e } " , Mobdriver = MobileDriver )
2021-12-22 14:01:58 +01:00
if not Mlogin ( echec ) :
CustomSleep ( uniform ( 1 , 2 ) )
MRGPD ( )
CustomSleep ( uniform ( 1 , 1.5 ) )
2021-12-24 10:56:40 +01:00
send_keys_wait ( MobileDriver . find_element ( By . ID , ' sb_form_q ' ) , Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE + Keys . BACKSPACE )
2021-12-22 14:01:58 +01:00
for i in range ( override ) : #20
mot = str ( Liste_de_mot [ randint ( 0 , 9999 ) ] )
2021-12-24 10:56:40 +01:00
send_keys_wait ( MobileDriver . find_element ( By . ID , ' sb_form_q ' ) , mot )
MobileDriver . find_element ( By . ID , ' sb_form_q ' ) . send_keys ( Keys . ENTER )
2021-12-22 14:01:58 +01:00
progressBar ( i , override , name = " Mobile " )
sleep ( uniform ( 5 , 20 ) )
2021-12-23 13:05:16 +01:00
Alerte ( ) # verifie si il y a des alertes (demande de positions ....)
2021-12-22 14:01:58 +01:00
for i in range ( len ( mot ) ) :
2021-12-24 10:56:40 +01:00
MobileDriver . find_element ( By . ID , ' sb_form_q ' ) . clear ( )
2021-12-23 13:05:16 +01:00
2021-12-22 14:01:58 +01:00
MobileDriver . quit ( )
except Exception as e :
2021-12-29 11:51:08 +01:00
LogError ( " BingMobileSearch " + str ( e ) , Mobdriver = MobileDriver )
2021-12-23 10:53:53 +01:00
try :
MobileDriver . quit ( )
2021-12-23 13:05:16 +01:00
except Exception as e :
LogError ( f " can ' t close mobile driveerr . { e } " )
2021-12-22 14:01:58 +01:00
2021-12-23 13:51:07 +01:00
2021-12-22 14:01:58 +01:00
def TryPlay ( nom = " inconnu " ) :
RGPD ( )
2021-12-23 17:36:53 +01:00
def play ( number , override = None ) :
2021-12-23 16:34:32 +01:00
match number :
2021-12-23 17:55:04 +01:00
case 9 | 8 :
2021-12-23 16:34:32 +01:00
try :
print ( f ' Quiz 8 détécté sur la page { nom } ' )
RGPD ( )
2021-12-23 17:36:53 +01:00
PlayQuiz8 ( override )
2021-12-23 16:34:32 +01:00
except Exception as e :
printf ( f ' echec de PlayQuiz 8. Aborted { e } ' )
2021-12-23 17:55:04 +01:00
case 5 | 4 :
2021-12-23 16:34:32 +01:00
try :
print ( f ' Quiz 4 détécté sur la page { nom } ' )
RGPD ( )
2021-12-23 17:36:53 +01:00
PlayQuiz4 ( override )
2021-12-23 16:34:32 +01:00
print ( ' Quiz 4 reussit ' )
except Exception as e :
printf ( f ' echec de PlayQuiz 4. Aborted { e } ' )
2021-12-23 17:55:04 +01:00
case 3 | 2 :
2021-12-23 16:34:32 +01:00
try :
RGPD ( )
print ( f ' Quiz 2 détécté sur la page { nom } ' )
2021-12-23 17:36:53 +01:00
PlayQuiz2 ( override )
2021-12-23 16:34:32 +01:00
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 ' )
2021-12-22 14:01:58 +01:00
try :
2021-12-24 10:56:40 +01:00
driver . find_element ( By . ID , ' rqStartQuiz ' ) . click ( ) #start the quiz
2021-12-22 14:01:58 +01:00
number = driver . page_source . count ( ' rqAnswerOption ' )
2021-12-23 16:34:32 +01:00
play ( number )
2021-12-22 14:01:58 +01:00
except :
2021-12-23 16:34:32 +01:00
2021-12-22 14:01:58 +01:00
if " bt_PollRadio " in driver . page_source :
try :
print ( ' Poll détected ' , end = " \r " )
RGPD ( )
PlayPoll ( )
print ( ' Poll reussit ' )
2021-12-23 13:05:16 +01:00
except Exception as e :
printf ( f ' Poll aborted { e } ' )
2021-12-23 17:36:53 +01:00
2021-12-23 16:34:32 +01:00
elif " rqQuestionState " in driver . page_source :
2021-12-23 17:55:04 +01:00
try :
number = driver . page_source . count ( ' rqAnswerOption ' )
restant = len ( findall ( " \" rqQuestionState.?. \" class= " , driver . page_source ) ) - len ( findall ( " \" rqQuestionState.?. \" class= \" filledCircle \" " , driver . page_source ) )
printf ( f " recovery détécté. quiz : { number } , restant : { restant + 1 } " )
play ( number , override = restant + 1 )
except Exception as e :
printf ( e )
2021-12-22 14:01:58 +01:00
elif search ( " ([0-9]) de ([0-9]) finalisée " , driver . page_source ) :
print ( ' fidélité ' )
RGPD ( )
Fidelité ( )
else :
print ( f ' rien a faire sur la page { nom } ' )
RGPD ( )
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-23 13:51:07 +01:00
def LogPoint ( account = " unknown " ) : #log des points sur discord
2021-12-23 13:28:14 +01:00
driver . get ( ' https://www.bing.com/rewardsapp/flyout ' )
2021-12-22 14:01:58 +01:00
if not IsLinux :
asyncio . set_event_loop_policy ( asyncio . WindowsSelectorEventLoopPolicy ( ) )
else :
asyncio . set_event_loop ( asyncio . new_event_loop ( ) )
2021-12-24 10:56:40 +01:00
elem = driver . find_element ( By . CSS_SELECTOR , ' [title= " Microsoft Rewards " ] ' )
2021-12-22 17:01:00 +01:00
elem . click ( )
2021-12-29 13:32:16 +01:00
CustomSleep ( 5 )
2021-12-24 21:10:45 +01:00
driver . switch_to . window ( driver . window_handles [ len ( driver . window_handles ) - 1 ] )
2021-12-22 17:01:00 +01:00
CustomSleep ( uniform ( 10 , 20 ) )
2021-12-22 14:01:58 +01:00
try :
2021-12-22 17:01:00 +01:00
point = search ( " availablePoints \" :([ \ d]+) " , driver . page_source ) [ 1 ]
2021-12-27 14:22:44 +01:00
except Exception as e :
LogError ( e )
2021-12-22 17:01:00 +01:00
point = " erreur "
2021-12-22 14:01:58 +01:00
CustomSleep ( uniform ( 3 , 20 ) )
account = account . split ( ' @ ' ) [ 0 ]
client = discord . Client ( )
@client.event
async def on_ready ( ) :
channel = client . get_channel ( 841338253625917450 )
await channel . send ( f ' { account } actuellement à { str ( point ) } points ' )
CustomSleep ( 1 )
await client . close ( )
2021-12-22 14:39:20 +01:00
client . run ( Token )
2021-12-22 14:01:58 +01:00
def Fidelité ( ) :
try :
driver . switch_to . window ( driver . window_handles [ 1 ] )
2021-12-24 10:56:40 +01:00
choix = driver . find_element ( By . CLASS_NAME , ' spacer-48-bottom ' )
2021-12-22 14:01:58 +01:00
nb = search ( " ([0-9]) de ([0-9]) finalisée " , driver . page_source )
for i in range ( int ( nb [ 2 ] ) - int ( nb [ 1 ] ) ) :
2021-12-24 10:56:40 +01:00
choix = driver . find_element ( By . CLASS_NAME , ' spacer-48-bottom ' )
2021-12-22 14:01:58 +01:00
ButtonText = search ( ' <span class= \" pull-left margin-right-15 \" >([^<^>]+)</span> ' , choix . get_attribute ( " innerHTML " ) ) [ 1 ]
2021-12-24 10:56:40 +01:00
bouton = driver . find_element ( By . XPATH , f ' //span[text()= " { ButtonText } " ] ' )
2021-12-22 14:01:58 +01:00
bouton . click ( )
CustomSleep ( uniform ( 3 , 5 ) )
driver . switch_to . window ( driver . window_handles [ len ( driver . window_handles ) - 1 ] )
2021-12-23 13:05:16 +01:00
TryPlay ( driver . title )
2021-12-22 14:01:58 +01:00
CustomSleep ( uniform ( 3 , 5 ) )
Close ( driver . window_handles [ 2 ] , SwitchTo = 1 )
driver . refresh ( )
CustomSleep ( uniform ( 3 , 5 ) )
Close ( driver . window_handles [ 1 ] )
2021-12-23 13:05:16 +01:00
printf ( ' on a passer la partie fidélité ' )
2021-12-22 14:01:58 +01:00
except Exception as e :
LogError ( " Fidélité " + str ( e ) )
def CheckPoint ( ) : # a fix, ne marche pas dans 80% des cas
driver . get ( " https://rewards.microsoft.com/pointsbreakdown " )
txt = driver . page_source
pc = search ( ' ([0-9][0-9]|[0-9])</b> / 90 ' , txt )
mobile = search ( ' ([0-9][0-9]|[0-9])</b> / 60 ' , txt )
if mobile :
if mobile [ 1 ] != 60 :
BingMobileSearch ( 22 - ( int ( mobile [ 1 ] ) / 3 ) )
if pc :
if pc [ 1 ] != 90 :
BingPcSearch ( 32 - ( int ( pc [ 1 ] ) / 3 ) )
def DailyRoutine ( ) :
MainWindows = login ( )
try :
AllCard ( )
except Exception as e :
LogError ( f ' pas normal sauf si relancer a la main, juste pour les recherches bing (DalyRoutine -> AllCard) \n { e } ' )
try :
BingPcSearch ( )
except Exception as e :
LogError ( f " il y a eu une erreur dans BingPcSearch, { e } " )
CustomSleep ( uniform ( 3 , 20 ) )
try :
BingMobileSearch ( )
2021-12-22 17:01:00 +01:00
except Exception as e :
LogError ( f ' BingMobileSearch - { e } ' )
2021-12-22 14:01:58 +01:00
print ( ' \n ' )
CustomSleep ( uniform ( 3 , 20 ) )
2021-12-22 17:01:00 +01:00
try :
LogPoint ( _mail )
2021-12-23 13:51:07 +01:00
except Exception as e :
LogError ( f ' LogPoint : { e } ' )
2021-12-22 14:01:58 +01:00
2021-12-29 13:32:16 +01:00
2021-12-23 13:05:16 +01:00
def close ( ) :
driver . quit ( )
quit ( )
2021-12-22 14:01:58 +01:00
with open ( LogPath ) as f :
reader = reader ( f )
data = list ( reader )
Credentials = data
CustomSleep ( 2 )
shuffle ( Credentials )
2021-12-29 11:51:08 +01:00
2021-12-22 14:01:58 +01:00
for i in Credentials :
2021-12-22 17:01:00 +01:00
2021-12-22 14:01:58 +01:00
_mail = i [ 0 ]
_password = i [ 1 ]
print ( ' \n \n ' )
print ( _mail )
CustomSleep ( 1 )
2021-12-22 17:01:00 +01:00
if main :
driver = FirefoxPC ( )
driver . implicitly_wait ( 5 )
2021-12-22 14:01:58 +01:00
2021-12-22 17:01:00 +01:00
try :
DailyRoutine ( )
driver . quit ( )
2022-01-07 17:56:01 +01:00
timer = uniform ( 1200 , 3600 )
print ( f " finis. attente de { round ( timer / 60 ) } min " )
2021-12-23 16:34:32 +01:00
CustomSleep ( timer )
2021-12-22 17:01:00 +01:00
except KeyboardInterrupt :
print ( ' canceled ' )
2021-12-23 13:05:16 +01:00
close ( )
2021-12-22 14:01:58 +01:00