2022-03-28 18:31:55 +02:00
#!/usr/bin/python3.10
2022-02-17 12:19:47 +01:00
import asyncio
2022-11-16 18:11:18 +01:00
import csv
2022-06-23 13:26:31 +02:00
from os import sys , system , path
2022-02-17 12:19:47 +01:00
from random import choice , randint , shuffle , uniform
from re import findall , search
2021-12-23 16:34:32 +01:00
from sys import platform
2022-10-24 20:08:33 +02:00
from time import sleep
2022-04-10 18:43:33 +02:00
from requests import get
2021-12-22 14:01:58 +01:00
from selenium import webdriver
2022-02-17 12:19:47 +01:00
from selenium . common import exceptions
2021-12-22 14:01:58 +01:00
from selenium . webdriver . common . by import By
2022-02-17 12:19:47 +01:00
from selenium . webdriver . common . keys import Keys
from selenium . webdriver . firefox . options import Options
2022-10-23 19:25:04 +02:00
from selenium . webdriver . support . ui import WebDriverWait
from selenium . webdriver . support import expected_conditions as EC
2022-11-07 22:39:15 +01:00
from selenium . webdriver . support . ui import Select
2022-11-12 23:00:45 +01:00
from rich . progress import BarColumn , Progress , TextColumn , Progress , TimeElapsedColumn , TaskProgressColumn , TimeRemainingColumn
2022-06-17 07:05:46 +02:00
2022-10-24 20:08:33 +02:00
from modules . db import add_to_database
from modules . config import *
from modules . tools import *
2022-10-31 15:32:39 +01:00
from modules . error import *
2022-11-12 23:00:45 +01:00
import modules . progress
2022-02-15 22:40:39 +01:00
2023-01-30 07:32:29 +01:00
global driver
driver = None
2022-05-18 18:50:04 +02:00
2022-10-25 19:44:33 +02:00
def printf ( x ) :
printf2 ( x , _mail )
2022-10-23 19:25:04 +02:00
def WaitUntilVisible ( by , id , to = 20 , browser = driver ) :
try :
WebDriverWait ( browser , to ) . until ( EC . visibility_of_element_located ( ( by , id ) ) , " element not found " )
except TimeoutException as e :
print ( f " element not found after { to } s " )
2022-05-24 22:38:23 +02:00
2023-01-14 17:36:28 +01:00
def claim ( auto = True , reward = " amazon " ) :
dic_id = { " amazon " : " 000803000031 " , " RP " : " 000403000103 " , " fnac " : " " }
2023-01-14 18:04:55 +01:00
2023-01-14 17:36:28 +01:00
def number_verification ( ) :
2023-01-14 16:56:33 +01:00
countrycode = driver . find_element ( By . ID , ' redeem-checkout-challenge-countrycode ' )
phone = driver . find_element ( By . ID , " redeem-checkout-challenge-fullnumber " )
sel = Select ( countrycode )
CC = input ( " enter start of number (33, ...) " )
sel . select_by_value ( CC )
ph = input ( " entrez le numero de telephone : +33 " )
send_keys_wait ( phone , ph )
driver . find_element ( By . ID , " redeem-checkout-challenge-validate " ) . click ( )
2023-01-14 17:19:52 +01:00
sleep ( 5 )
code = input ( " entrez le code recu : " )
send_keys_wait ( driver . find_element ( By . ID , " redeem-checkout-challenge-code " ) , code )
driver . find_element ( By . ID , " redeem-checkout-challenge-confirm " ) . click ( )
2023-01-14 16:56:33 +01:00
def start ( ) :
2023-01-14 17:36:28 +01:00
driver . get ( f " https://rewards.bing.com/redeem/ { dic_id [ reward ] } " )
2023-01-14 18:04:55 +01:00
sleep ( 5 )
2022-10-11 13:00:44 +02:00
try :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' ÉCHANGER UNE RÉCOMPENSE ' )] " ) . click ( )
except :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' REDEEM REWARD ' )] " ) . click ( )
2022-10-09 13:33:13 +02:00
sleep ( 5 )
2022-10-11 13:00:44 +02:00
try :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' CONFIRMER LA RÉCOMPENSE ' )] " ) . click ( )
except :
2022-10-11 21:14:53 +02:00
driver . find_element ( By . XPATH , " //span[contains( text( ), ' CONFIRM REWARD ' )] " ) . click ( )
2023-01-14 16:56:33 +01:00
sleep ( 5 )
2022-10-11 13:00:44 +02:00
2023-01-14 17:36:28 +01:00
def amazon ( ) :
2023-01-14 16:56:33 +01:00
driver . get ( " https://rewards.bing.com/redeem/orderhistory " )
try :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' Détails de la commande ' )] " ) . click ( )
except :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' Get code ' )] " ) . click ( )
2022-10-09 13:33:13 +02:00
sleep ( 5 )
2023-01-14 16:56:33 +01:00
code = driver . find_element ( By . CLASS_NAME , " tango-credential-value " ) . get_attribute ( ' innerHTML ' )
lien = driver . find_elements ( By . CLASS_NAME , " tango-credential-key " ) [ 1 ] . get_attribute ( ' innerHTML ' )
lien = search ( ' \" ([^ \" ]+) \" ' , lien ) [ 1 ]
driver . get ( lien )
sleep ( 10 )
box = driver . find_element ( By . ID , " input-45 " )
box . click ( )
box . send_keys ( code )
driver . find_element ( By . XPATH , " //span[contains( text( ), ' Déverrouillez votre récompense ' )] " ) . click ( )
sleep ( 5 )
fcode = driver . find_element ( By . XPATH , " /html/body/div[1]/div[1]/main/div/div/div/div/div[1]/div/div[1]/div[2]/div[2]/div/div/div/div/div/div[2]/span " ) . get_attribute ( " innerHTML " )
if fcode :
2023-02-12 13:44:57 +01:00
webhookFailure . send ( _mail )
webhookFailure . send ( fcode )
2023-01-14 16:56:33 +01:00
return ( 1 )
else :
LogError ( " impossible de localiser le code " , driver , _mail )
return ( 1 )
2023-01-14 17:36:28 +01:00
def fnac ( ) :
pass
def rp ( ) :
2023-01-14 17:53:58 +01:00
driver . get ( " https://rewards.bing.com/redeem/orderhistory " )
try :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' Détails de la commande ' )] " ) . click ( )
except :
driver . find_element ( By . XPATH , " //span[contains( text( ), ' Get code ' )] " ) . click ( )
sleep ( 1 )
elm = driver . find_element ( By . CLASS_NAME , " tango-credential-value " )
code = elm . get_attribute ( ' innerHTML ' )
print ( code )
2023-01-14 18:04:55 +01:00
dic_fun = { " amazon " : amazon , " RP " : rp , ' fnac ' : fnac }
2023-01-14 16:56:33 +01:00
try :
start ( )
2022-10-09 13:33:13 +02:00
if ( " /rewards/redeem/orderhistory " in driver . page_source ) :
2023-01-14 17:53:58 +01:00
dic_fun [ reward ] ( )
2022-10-09 13:33:13 +02:00
else :
2023-01-14 16:56:33 +01:00
if auto :
LogError ( " la recuperation ne peux pas être automatique " , driver , _mail )
return ( 0 )
else :
2023-01-14 17:36:28 +01:00
number_verification ( )
2023-01-14 16:56:33 +01:00
while ( " Il existe un problème avec votre compte ou votre commande " in driver . page_source ) :
print ( " le numero de telephone est ban " )
2023-01-14 17:36:28 +01:00
driver . get ( f " https://rewards.bing.com/redeem/ { dic_id [ reward ] } " )
2023-01-14 17:53:58 +01:00
driver . find_element ( By . XPATH , " //span[contains( text( ), ' ÉCHANGER UNE RÉCOMPENSE ' )] " ) . click ( )
sleep ( 5 )
driver . find_element ( By . XPATH , " //span[contains( text( ), ' CONFIRMER LA RÉCOMPENSE ' )] " ) . click ( )
2023-01-14 17:36:28 +01:00
number_verification ( )
2023-01-14 17:53:58 +01:00
dic_fun [ reward ] ( )
2023-01-14 16:56:33 +01:00
2022-10-09 13:33:13 +02:00
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError ( f ' problème dans la recuperation : { str ( e ) } ' , driver , _mail )
2022-10-09 13:33:13 +02:00
2022-12-11 17:04:40 +01:00
def setup_proxy ( ip , port , options , socks = False ) :
2022-05-18 18:50:04 +02:00
PROXY = f " { ip } : { port } "
2022-11-12 17:40:03 +01:00
if socks :
options . set_preference ( ' network.proxy.type ' , 1 )
options . set_preference ( ' network.proxy.socks ' , ip )
options . set_preference ( ' network.proxy.socks_port ' , int ( port ) )
options . set_preference ( " browser.link.open_newwindow " , 3 )
else :
webdriver . DesiredCapabilities . FIREFOX [ ' proxy ' ] = {
" httpProxy " : PROXY ,
" sslProxy " : PROXY ,
" proxyType " : " MANUAL " ,
}
2022-05-18 18:50:04 +02:00
2022-03-28 16:30:11 +02:00
2022-04-22 12:41:05 +02:00
def FirefoxDriver ( mobile = False , Headless = Headless ) :
2022-04-14 23:03:16 +02:00
PC_USER_AGENT = (
2022-06-28 12:27:22 +02:00
" Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
2022-12-17 17:39:48 +01:00
f " AppleWebKit/ { hash ( _mail ) % 500 } . { hash ( _mail ) % 50 } (KHTML, like Gecko) "
f " Chrome/ { 100 + ( hash ( _mail ) % 8 ) } . { hash ( _mail ) % 10 } . { hash ( _mail ) % 5000 } .102 Safari/537.36 Edg/104.0.1293.70 "
2022-04-14 23:03:16 +02:00
)
2022-04-22 12:41:05 +02:00
MOBILE_USER_AGENT = (
2022-06-28 12:27:22 +02:00
" Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) "
" AppleWebKit/605.1.15 (KHTML, like Gecko) "
" CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1 "
2022-04-22 12:41:05 +02:00
)
2022-08-22 11:03:20 +02:00
2022-04-22 12:41:05 +02:00
options = Options ( )
2022-12-17 17:39:48 +01:00
options . set_preference ( ' intl.accept_languages ' , ' fr-FR, fr ' )
2022-12-11 17:04:40 +01:00
if proxy_enabled :
setup_proxy ( proxy_address , proxy_port , options )
2021-12-22 14:01:58 +01:00
options . set_preference ( " browser.link.open_newwindow " , 3 )
2022-11-09 22:54:55 +01:00
if FAST :
options . set_preference ( " permissions.default.image " , 2 ) #disable image loading. May add this without the fast option soon
2022-04-14 23:03:16 +02:00
if Headless :
2021-12-22 14:01:58 +01:00
options . add_argument ( " -headless " )
2022-04-22 12:41:05 +02:00
if mobile :
options . set_preference ( " general.useragent.override " , MOBILE_USER_AGENT )
else :
options . set_preference ( " general.useragent.override " , PC_USER_AGENT )
2022-08-30 12:00:30 +02:00
driver = webdriver . Firefox ( options = options )
driver . set_window_size ( 1900 + hash ( _mail ) % 20 , 1070 + hash ( _password + " salt " ) % 10 )
return driver
2022-04-14 23:03:16 +02:00
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
def Close ( fenetre , SwitchTo = 0 ) :
2021-12-22 14:01:58 +01:00
driver . switch_to . window ( fenetre )
driver . close ( )
driver . switch_to . window ( driver . window_handles [ SwitchTo ] )
2022-05-27 09:28:31 +02:00
#Deal with RGPD popup as well as some random popup like 'are you satisfied' one
2021-12-22 14:01:58 +01:00
def RGPD ( ) :
2022-10-31 15:32:39 +01:00
for i in [ " bnp_btn_accept " , " bnp_hfly_cta2 " , " bnp_hfly_close " ] :
try :
2022-11-05 15:30:55 +01:00
driver . find_element ( By . ID , i ) . click ( )
2022-10-31 15:32:39 +01:00
except :
pass
2021-12-22 14:01:58 +01:00
2021-12-23 17:36:53 +01:00
2022-05-26 07:47:29 +02:00
"""
2022-06-20 18:16:15 +02:00
PlayQuiz [ N ] ( [ int : override ] ) make the quizz with N choice each time . They usually have between 4 and 10 questions .
override is the number of question , by default , it ' s the number of question in this specific quizz. Can be usefull in some case, where the programm crashes before finishing the quizz
2022-05-26 07:47:29 +02:00
"""
def PlayQuiz2 ( override = 10 ) :
2022-10-25 19:44:33 +02:00
printf ( " début de PlayQuiz2 " )
2022-04-14 23:03:16 +02:00
for j in range ( override ) :
try :
2022-04-11 12:36:03 +02:00
RGPD ( )
2022-04-14 23:03:16 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-22 14:01:58 +01:00
txt = driver . page_source
2022-04-14 23:03:16 +02:00
secret = search ( ' IG: " ([^ " ]+) " ' , txt ) [ 1 ] # variable dans la page, pour calculer le offset
reponse1 = search ( ' data-option= " ([^ " ]+) " ' , txt ) [ 1 ]
offset = int ( secret [ - 2 : ] , 16 ) # la conversion ec decimal des deux dernier caracteres de IG
reponse = search ( ' correctAnswer " : " ([0-9]+) ' , txt ) [ 1 ]
somme = 0
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
for i in reponse1 :
2021-12-22 14:01:58 +01:00
somme + = ord ( i )
2022-04-14 23:03:16 +02:00
if somme + offset == int ( reponse ) :
elem = driver . find_element ( By . ID , " rqAnswerOption0 " )
2021-12-22 14:01:58 +01:00
elem . click ( )
2022-04-14 23:03:16 +02:00
progressBar ( j , 10 , name = " quiz 2 " )
else :
elem = driver . find_element ( By . ID , " rqAnswerOption1 " )
2021-12-22 14:01:58 +01:00
elem . click ( )
2022-04-14 23:03:16 +02:00
progressBar ( j , 10 , name = " quiz 2 " )
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
except exceptions . ElementNotInteractableException as e :
driver . execute_script ( " arguments[0].click(); " , elem )
2021-12-22 14:01:58 +01:00
except Exception as e :
2022-11-18 17:19:40 +01:00
LogError ( f " PlayQuiz2 { e } " , driver , _mail )
2021-12-22 14:01:58 +01:00
break
2022-10-25 19:44:33 +02:00
printf ( " PlayQuiz2 finis " )
2021-12-22 14:01:58 +01:00
2022-03-28 17:00:36 +02:00
2022-11-16 13:42:20 +01:00
def PlayQuiz8 ( task = None ) :
2022-11-05 15:30:55 +01:00
override = len ( findall ( " <span id= \" rqQuestionState. \" class= \" emptyCircle \" ></span> " , driver . page_source ) ) + 1
2022-10-25 19:44:33 +02:00
printf ( f " PlayQuiz8 : start, override : { override } " )
2022-04-14 23:03:16 +02:00
try :
2021-12-22 14:01:58 +01:00
c = 0
2022-11-09 19:36:22 +01:00
RGPD ( )
for i in range ( override ) :
2022-09-30 14:34:50 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2022-11-05 15:30:55 +01:00
AnswerOptions = [ ( driver . find_element ( By . ID , f " rqAnswerOption { i - 1 } " ) , f ' rqAnswerOption { i - 1 } ' ) for i in range ( 1 , 9 ) ]
isCorrect = [ x [ 1 ] for x in AnswerOptions if ' iscorrectoption= " True " ' in x [ 0 ] . get_attribute ( " outerHTML " ) ]
shuffle ( isCorrect )
2022-04-14 23:03:16 +02:00
2022-11-05 15:30:55 +01:00
for i in isCorrect :
2022-11-06 13:29:55 +01:00
WaitUntilVisible ( By . ID , i , to = 20 , browser = driver )
2022-04-14 23:03:16 +02:00
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 ( )
2022-11-16 13:42:20 +01:00
if not task is None :
AdvanceTask ( task , 1 / override / len ( isCorrect ) * 100 )
2022-11-05 15:30:55 +01:00
except exceptions . NoSuchElementException :
driver . refresh ( )
CustomSleep ( 10 )
elem = driver . find_element ( By . ID , i )
elem . click ( )
except ElementClickInterceptedException :
RGPD ( )
isCorrect . append ( i )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-11-05 15:30:55 +01:00
LogError ( f " PlayQuiz8 - 4 - { e } \n ListOfGood : { str ( isCorrect ) } " , driver , _mail )
2022-06-09 14:19:34 +02:00
2022-10-25 19:44:33 +02:00
printf ( " PlayQuiz8 : fin " )
2021-12-22 14:01:58 +01:00
2022-03-28 17:00:36 +02:00
2022-04-14 23:03:16 +02:00
def PlayQuiz4 ( override = None ) :
2022-10-25 19:44:33 +02:00
printf ( " PlayQuiz4 : start " )
2022-04-14 23:03:16 +02:00
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 ] )
2022-10-25 19:44:33 +02:00
printf ( f " Override : { override } " )
2022-04-14 23:03:16 +02:00
except :
override = 3
try :
2021-12-23 17:36:53 +01:00
for i in range ( override ) :
2022-04-14 23:03:16 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-22 14:01:58 +01:00
txt = driver . page_source
2022-04-11 12:36:03 +02:00
RGPD ( )
2022-04-14 23:03:16 +02:00
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)
2022-10-25 19:44:33 +02:00
printf ( f " validation de la reponse " )
printf ( f " validation de la reponse { i + 1 } / { override } { reponse } " )
2022-04-14 23:03:16 +02:00
try :
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 )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError ( f " PlayQuiz4 { str ( e ) } " , driver , _mail )
2021-12-22 14:01:58 +01:00
raise ValueError ( e )
2022-10-25 19:44:33 +02:00
printf ( " PlayQuiz4 : end " )
2021-12-22 14:01:58 +01:00
2022-08-29 10:44:57 +02:00
2022-06-21 17:22:44 +02:00
"""
2022-08-29 10:44:57 +02:00
PlayPoll ( ) reply a random thing to poll , on of daily activities
2022-06-21 17:22:44 +02:00
"""
2021-12-22 14:01:58 +01:00
def PlayPoll ( ) :
2022-10-25 19:44:33 +02:00
printf ( " PlayPoll : start " )
2022-04-14 23:03:16 +02:00
try :
try :
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 )
2022-04-14 23:03:16 +02:00
CustomSleep ( uniform ( 2 , 2.5 ) )
except Exception as e :
2022-11-18 17:19:40 +01:00
LogError ( f " PlayPoll { e } " , driver , _mail )
2021-12-22 14:01:58 +01:00
raise ValueError ( e )
2022-10-25 19:44:33 +02:00
printf ( " PlayPoll : end " )
2021-12-22 14:01:58 +01:00
2022-03-28 17:00:36 +02:00
2022-04-14 23:03:16 +02:00
def AllCard ( ) : # fonction qui clique sur les cartes
def reset ( Partie2 = False ) : # retourne sur la page de depart apres avoir finis
if len ( driver . window_handles ) == 1 :
driver . get ( " https://www.bing.com/rewardsapp/flyout " )
if Partie2 :
driver . find_element (
By . XPATH , " /html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1] "
) . click ( )
else :
2021-12-22 14:01:58 +01:00
driver . switch_to . window ( driver . window_handles [ 1 ] )
2022-10-25 19:44:33 +02:00
printf ( f " fermeture : { driver . current_url } " )
2021-12-22 14:01:58 +01:00
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 ( ) :
2022-04-14 23:03:16 +02:00
try :
2022-11-16 13:42:20 +01:00
StartTask ( task [ " daily " ] [ f " all " ] )
2021-12-22 14:01:58 +01:00
for i in range ( 3 ) :
2022-11-16 13:42:20 +01:00
StartTask ( task [ " daily " ] [ f " carte { i } " ] )
2022-09-30 14:34:50 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2022-04-14 23:03:16 +02:00
try :
2022-03-28 16:30:11 +02:00
titre = " erreur "
2022-04-14 23:03:16 +02: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 ( )
2022-02-18 18:33:32 +01:00
sleep ( 1 )
titre = driver . title
2022-11-16 13:42:20 +01:00
TryPlay ( titre , task = task [ " daily " ] [ f " carte { i } " ] )
AdvanceTask ( task [ " daily " ] [ f " carte { i } " ] , 100 )
ChangeColor ( task [ " daily " ] [ f " carte { i } " ] , " green " )
2022-02-18 18:33:32 +01:00
sleep ( 1 )
reset ( )
2022-10-25 19:44:33 +02:00
printf ( f " DailyCard { titre } ok " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( f " Allcard card { titre } error ( { e } ) " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError ( f " Dailycards { e } " , driver , _mail )
2022-04-14 23:03:16 +02:00
try :
2022-04-07 13:43:39 +02:00
dailyCards ( )
2022-06-21 17:36:18 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( f " erreur dans les quetes de la semaine { e } " )
2022-05-18 19:07:25 +02:00
2022-05-26 07:47:29 +02:00
def weekly_cards ( ) :
2022-04-14 23:03:16 +02:00
try :
driver . find_element (
By . XPATH , " /html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1] "
) . click ( ) # declenche la premiere partie ?
except :
2021-12-22 14:01:58 +01:00
reset ( )
2022-04-14 23:03:16 +02:00
try :
driver . find_element (
By . XPATH , " /html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1] "
) . click ( ) # declenche la deuxieme partie ?
except :
2021-12-22 14:01:58 +01:00
pass
2022-04-14 23:03:16 +02:00
2022-02-18 13:10:46 +01:00
for i in range ( 20 ) :
2022-10-25 19:44:33 +02:00
printf ( " début de l ' une des cartes " )
2022-04-14 23:03:16 +02: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 ( )
2022-10-25 19:44:33 +02:00
printf ( " carte cliquée " )
2021-12-22 14:01:58 +01:00
driver . switch_to . window ( driver . window_handles [ len ( driver . window_handles ) - 1 ] )
2022-04-14 23:03:16 +02:00
sleep ( 1 )
2022-02-18 13:10:46 +01:00
titre = driver . title
print ( f " carte { titre } en cours " )
2021-12-23 13:51:07 +01:00
TryPlay ( titre )
2021-12-22 14:01:58 +01:00
reset ( True )
sleep ( 1 )
2022-04-14 23:03:16 +02:00
try :
link = findall ( ' href= " ([^<]+) " title= " " ' , driver . page_source ) [
3
] # verifie si on a toujours des cartes
except :
2021-12-22 14:01:58 +01:00
break
2022-12-20 12:42:00 +01:00
try :
weekly_cards ( )
except Exception as e :
LogError ( f " weekly_cards { e } " , driver , _mail )
2021-12-22 14:01:58 +01:00
2022-06-21 17:22:44 +02:00
"""
login ( ) tries to login to your micrososft account .
it uses global variable _mail and _password to login
"""
2022-04-14 23:03:16 +02:00
def login ( ) :
2022-06-09 14:19:34 +02:00
global driver
2022-10-31 15:32:39 +01:00
def sub_login ( ) :
2022-10-25 19:44:33 +02:00
printf ( " sublogin : start " )
2022-04-14 23:03:16 +02:00
driver . get ( " https://www.bing.com/rewardsapp/flyout " )
2022-10-31 15:32:39 +01:00
for i in [ f ' [title= " Rejoindre " ] ' , f ' [title= " Join now " ] ' , f ' [title= " Rejoindre maintenant " ] ' ] :
try :
driver . find_element ( By . CSS_SELECTOR , i ) . click ( ) # depend of the language of the page
break
except :
pass
2022-12-11 17:15:57 +01:00
try :
driver . find_element ( By . XPATH , " /html/body/div/div/div/div/div[2]/a " ) . click ( ) # may need to be clicked if the language is english
except :
pass
2022-06-09 14:19:34 +02:00
2022-10-24 10:38:11 +02:00
WaitUntilVisible ( By . ID , " i0116 " , browser = driver )
2022-04-14 23:03:16 +02: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 )
2022-10-24 10:38:11 +02:00
WaitUntilVisible ( By . ID , " i0118 " , browser = driver )
2022-04-14 23:03:16 +02: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 )
2022-10-31 15:32:39 +01:00
if ( ' Abuse ' in driver . current_url ) :
LogError ( " account suspended " , driver , _mail )
raise Banned ( )
2022-10-24 20:08:33 +02:00
for i in [ " KmsiCheckboxField " , " iLooksGood " , " idSIButton9 " , " iCancel " ] :
try :
driver . find_element ( By . ID , i ) . click ( )
except Exception as e :
pass
2022-08-22 11:03:20 +02:00
try :
elm = driver . find_element ( By . TAG_NAME , " body " )
elm . send_keys ( Keys . ENTER )
except :
pass
2022-10-25 19:44:33 +02:00
printf ( " login completed " )
2021-12-22 14:01:58 +01:00
RGPD ( )
2022-08-30 11:28:02 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2022-04-14 23:03:16 +02:00
driver . get ( " https://www.bing.com/rewardsapp/flyout " )
2022-08-30 11:28:02 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-22 14:01:58 +01:00
2022-06-09 14:19:34 +02:00
for i in range ( 3 ) :
try :
sub_login ( )
2022-06-22 12:26:50 +02:00
return ( driver . current_window_handle )
2022-10-31 15:32:39 +01:00
except Banned :
raise Banned ( )
2022-06-09 14:19:34 +02:00
except Exception as e :
2022-11-18 17:19:40 +01:00
LogError ( f " login - 3 - { e } " , driver , _mail )
2023-01-14 16:56:33 +01:00
driver . quit ( )
2022-06-09 14:19:34 +02:00
CustomSleep ( 1200 )
driver = FirefoxDriver ( )
2022-06-09 14:34:02 +02:00
return ( " STOP " )
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
def BingPcSearch ( override = randint ( 35 , 40 ) ) :
2022-11-12 23:31:58 +01:00
StartTask ( task [ " PC " ] )
2022-04-14 23:03:16 +02:00
driver . get ( f " https://www.bing.com/search?q=test " ) # {choice(Liste_de_mot)}')
CustomSleep ( uniform ( 1 , 2 ) )
2021-12-22 14:01:58 +01:00
RGPD ( )
2022-04-14 23:03:16 +02: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 ) :
2022-02-18 20:29:13 +01:00
mot = choice ( Liste_de_mot )
2022-04-14 23:03:16 +02:00
try :
send_keys_wait ( driver . find_element ( By . ID , " sb_form_q " ) , mot )
driver . find_element ( By . ID , " sb_form_q " ) . send_keys ( Keys . ENTER )
2022-04-22 12:41:05 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( e )
2021-12-22 14:01:58 +01:00
sleep ( 10 )
2022-08-29 10:44:57 +02:00
driver . get ( ' https://www.bing.com/search?q=pls ' )
2022-04-22 12:41:05 +02:00
sleep ( 3 )
2022-04-14 23:03:16 +02: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
2022-11-12 23:46:12 +01:00
AdvanceTask ( task [ " PC " ] , 1 / override * 100 )
2022-09-30 14:34:50 +02:00
CustomSleep ( uniform ( 5 , 20 ) )
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
try :
driver . find_element ( By . ID , " sb_form_q " ) . clear ( )
2022-04-22 12:41:05 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( e )
2022-04-14 23:03:16 +02:00
try :
2022-08-29 10:44:57 +02:00
driver . get ( ' https://www.bing.com/search?q=pls ' )
2022-04-14 23:03:16 +02:00
driver . find_element ( By . ID , " sb_form_q " ) . clear ( )
2021-12-23 13:05:16 +01:00
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError ( f " BingPcSearch - clear la barre de recherche - { e } " , driver , _mail )
2022-12-17 18:04:49 +01:00
AdvanceTask ( task [ " PC " ] , 100 )
2022-11-12 23:00:45 +01:00
ChangeColor ( task [ " PC " ] , " green " )
2021-12-22 14:01:58 +01:00
2022-10-31 15:32:39 +01:00
def unban ( ) :
2023-02-08 15:14:13 +01:00
driver . get ( " https://login.live.com " )
CustomSleep ( 5 )
LogError ( " test " , driver , _mail )
mail = driver . find_element ( By . ID , " i0116 " )
send_keys_wait ( mail , _mail )
mail . send_keys ( Keys . ENTER )
WaitUntilVisible ( By . ID , " i0118 " , browser = driver )
pwd = driver . find_element ( By . ID , " i0118 " )
send_keys_wait ( pwd , _password )
pwd . send_keys ( Keys . ENTER )
CustomSleep ( 5 )
2022-10-31 15:32:39 +01:00
driver . find_element ( By . ID , " StartAction " ) . click ( )
2022-12-17 18:04:49 +01:00
CustomSleep ( 2 )
2022-10-31 15:32:39 +01:00
txt = driver . page_source
2022-11-07 22:39:15 +01:00
uuid0 = findall ( ' wlspispHIPCountrySelect([a-z0-9]+) ' , txt ) [ 0 ]
2022-10-31 15:32:39 +01:00
uuid1 = findall ( ' wlspispHIPPhoneInput([a-z0-9]+) ' , txt ) [ 0 ]
uuid2 = findall ( ' wlspispHipSendCode([a-z0-9]+) ' , txt ) [ 0 ]
uuid3 = findall ( ' wlspispSolutionElement([a-z0-9]+) ' , txt ) [ 0 ]
2022-11-07 22:39:15 +01:00
sel = Select ( driver . find_element ( By . ID , " wlspispHIPCountrySelect " + uuid0 ) )
CC = input ( " enter Contry code (FR, ...) " )
sel . select_by_value ( CC )
WaitUntilVisible ( By . ID , " wlspispHIPPhoneInput " + uuid1 , browser = driver )
2022-10-31 15:32:39 +01:00
phone = input ( " entrez le numero de téléphone : +33 " )
phone_box = driver . find_element ( By . ID , " wlspispHIPPhoneInput " + uuid1 )
phone_box . send_keys ( phone )
2022-11-07 22:39:15 +01:00
WaitUntilVisible ( By . ID , " wlspispHipSendCode " + uuid2 , browser = driver )
2022-10-31 15:32:39 +01:00
send_link = driver . find_element ( By . ID , " wlspispHipSendCode " + uuid2 )
send_link . click ( )
2022-11-07 22:39:15 +01:00
WaitUntilVisible ( By . ID , " wlspispSolutionElement " + uuid3 , browser = driver )
2022-11-12 17:40:03 +01:00
LogError ( " test " , driver , " phone test " )
2022-10-31 15:32:39 +01:00
answer_box = driver . find_element ( By . ID , " wlspispSolutionElement " + uuid3 )
answer = input ( " entrez le contenu du msg : " )
answer_box . send_keys ( answer )
send_box = driver . find_element ( By . ID , " ProofAction " )
send_box . click ( )
2022-11-07 22:39:15 +01:00
WaitUntilVisible ( By . ID , " FinishAction " , browser = driver )
2022-10-31 15:32:39 +01:00
continue_box = driver . find_element ( By . ID , " FinishAction " )
continue_box . click ( )
2021-12-23 13:51:07 +01:00
2022-11-16 13:42:20 +01:00
def TryPlay ( nom = " inconnu " , task = None ) :
2021-12-22 14:01:58 +01:00
RGPD ( )
2022-10-25 19:44:33 +02:00
printf ( " TryPlay en cours " )
2022-04-14 23:03:16 +02:00
2022-11-06 13:29:55 +01:00
def play ( number ) :
2022-04-14 23:03:16 +02:00
if number == 8 or number == 9 :
try :
2022-10-25 19:44:33 +02:00
printf ( f " \033 [96m Quiz 8 détecté sur la page { nom } \033 [0m " )
2022-11-16 13:42:20 +01:00
PlayQuiz8 ( task = task )
2022-10-25 19:44:33 +02:00
printf ( f " \033 [92m Quiz 8 reussit sur { nom } \033 [0m " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( f " echec de PlayQuiz 8. Aborted { e } \033 [0m " )
2022-02-18 13:15:48 +01:00
2022-04-14 23:03:16 +02:00
elif number == 5 or number == 4 :
try :
2022-10-25 19:44:33 +02:00
printf ( f " \033 [96m Quiz 4 détecté sur la page { nom } \033 [0m " )
2022-03-28 19:20:06 +02:00
PlayQuiz4 ( )
2022-10-25 19:44:33 +02:00
printf ( f " \033 [92m Quiz 4 reussit sur { nom } \033 [0m " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( f " echec de PlayQuiz 4. Aborted { e } \033 [0m " )
2022-02-18 13:15:48 +01:00
2022-04-14 23:03:16 +02:00
elif number == 3 or number == 2 :
try :
2022-10-25 19:44:33 +02:00
printf ( f " \033 [96m Quiz 2 détecté sur la page { nom } \033 [0m " )
2022-03-28 19:20:06 +02:00
PlayQuiz2 ( )
2022-10-25 19:44:33 +02:00
printf ( f " \033 [92m Quiz 2 reussit sur la page { nom } \033 [0m " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( f " echec de PlayQuiz 2. Aborted { e } " )
2022-04-14 23:03:16 +02:00
else :
2022-10-25 10:03:24 +02:00
LogError ( " probleme dans la carte : il y a un bouton play et aucun quiz detecté " , driver , _mail )
2022-04-14 23:03:16 +02:00
try :
driver . find_element ( By . ID , " rqStartQuiz " ) . click ( ) # start the quiz
number = driver . page_source . count ( " rqAnswerOption " )
2021-12-23 16:34:32 +01:00
play ( number )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
# printf(e) normal error here
2022-04-14 23:03:16 +02:00
if " bt_PollRadio " in driver . page_source :
try :
2022-10-25 19:44:33 +02:00
printf ( " Poll détected " )
2021-12-22 14:01:58 +01:00
RGPD ( )
PlayPoll ( )
2022-10-25 19:44:33 +02:00
printf ( " Poll reussit " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( f " TryPlay - 1 - Poll aborted { e } " )
2022-04-14 23:03:16 +02:00
elif " rqQuestionState " in driver . page_source :
try :
number = driver . page_source . count ( " rqAnswerOption " )
2022-11-06 13:29:55 +01:00
printf ( f " recovery détecté. quiz : { number } " )
2022-11-20 16:21:45 +01:00
play ( number - 1 )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-11-18 17:19:40 +01:00
printf ( f " TryPlay - 2 - { e } " )
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
elif search ( " ([0-9]) de ([0-9]) finalisée " , driver . page_source ) :
print ( " fidélité " )
2021-12-22 14:01:58 +01:00
RGPD ( )
2022-04-10 18:43:33 +02:00
Fidelite ( )
2022-04-14 23:03:16 +02:00
else :
2022-10-25 19:44:33 +02:00
printf ( f " rien à faire sur la page { nom } " )
2021-12-22 14:01:58 +01:00
RGPD ( )
2022-04-14 23:03:16 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
def LogPoint ( account = " unknown " ) : # log des points sur discord
2022-05-24 18:24:16 +02:00
def get_points ( ) :
driver . get ( " https://www.bing.com/rewardsapp/flyout " )
2022-09-23 15:13:14 +02:00
if not LINUX_HOST :
2022-05-24 18:24:16 +02:00
asyncio . set_event_loop_policy ( asyncio . WindowsSelectorEventLoopPolicy ( ) )
else :
asyncio . set_event_loop ( asyncio . new_event_loop ( ) )
2022-04-14 23:03:16 +02:00
2022-05-24 18:24:16 +02:00
regex1 = ' <a href= " https://rewards \ .bing \ .com/ " title= " ((. { 1,3}),(. { 1,3})) points " target= " _blank " '
2022-04-14 23:03:16 +02:00
try :
2022-05-24 18:24:16 +02:00
point = search ( regex1 , driver . page_source ) [ 1 ] . replace ( " , " , " " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-05-24 18:24:16 +02:00
elem = driver . find_element ( By . CSS_SELECTOR , ' [title= " Microsoft Rewards " ] ' )
elem . click ( )
CustomSleep ( 5 )
driver . switch_to . window ( driver . window_handles [ len ( driver . window_handles ) - 1 ] )
2022-10-13 07:18:08 +02:00
CustomSleep ( uniform ( 5 , 7 ) )
2022-06-09 14:34:02 +02:00
2022-04-14 23:03:16 +02:00
point = search ( ' availablePoints " :([ \ d]+) ' , driver . page_source ) [ 1 ]
2022-05-24 22:32:38 +02:00
return ( point )
2022-06-09 14:34:02 +02:00
for i in range ( 3 ) :
try :
points = get_points ( )
break
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-06-09 14:34:02 +02:00
CustomSleep ( 300 )
2022-10-25 19:44:33 +02:00
printf ( f " LogPoints : { e } " )
2022-10-18 12:51:55 +02:00
points = None
2022-06-09 14:34:02 +02:00
if not points :
2022-12-15 19:16:25 +01:00
LogError ( f " impossible d ' avoir les points : " , driver , _mail )
2022-04-14 23:03:16 +02:00
CustomSleep ( uniform ( 3 , 20 ) )
account = account . split ( " @ " ) [ 0 ]
2022-02-17 13:40:37 +01:00
2022-10-11 21:40:41 +02:00
if DISCORD_ENABLED_SUCCESS :
2022-05-24 22:32:38 +02:00
2022-10-11 21:40:41 +02:00
if DISCORD_EMBED :
2022-05-24 22:32:38 +02:00
embed = discord . Embed (
2022-05-24 22:43:01 +02:00
title = f " { account } actuellement à { str ( points ) } points " , colour = Colour . green ( )
2022-05-24 22:32:38 +02:00
)
embed . set_footer ( text = account )
webhookSuccess . send ( embed = embed )
else :
2022-05-24 22:43:01 +02:00
webhookSuccess . send ( f " { account } actuellement à { str ( points ) } points " )
2022-10-20 22:15:08 +02:00
if CLAIM_AMAZON and int ( points ) > = 7500 :
2023-01-14 17:36:28 +01:00
if ( claim ( reward = " amazon " ) == 1 ) :
2022-11-09 22:59:12 +01:00
points = str ( int ( points ) - 7500 )
2021-12-22 14:01:58 +01:00
2022-05-24 22:32:38 +02:00
if sql_enabled :
2022-09-30 14:59:54 +02:00
add_to_database ( account , points , sql_host , sql_usr , sql_pwd , sql_database )
2021-12-22 14:01:58 +01:00
2022-10-09 13:33:13 +02:00
2022-05-15 10:56:29 +02:00
def Fidelite ( ) :
2022-04-14 23:03:16 +02:00
try :
2022-05-15 10:36:26 +02:00
while 1 : #close all tabs
2022-04-14 23:03:16 +02:00
try :
2022-04-11 12:27:58 +02:00
Close ( 1 )
2022-04-14 23:03:16 +02:00
except :
2022-04-11 12:27:58 +02:00
break
2022-05-27 14:07:52 +02:00
try :
result = get ( FidelityLink ) #get the url of fidelity page
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( e )
2022-05-28 08:18:21 +02:00
result = False
2022-05-15 10:56:29 +02:00
2022-05-27 14:07:52 +02:00
if result :
lien = result . content . decode ( " UTF-8 " )
2022-05-15 10:56:29 +02:00
2022-05-27 14:07:52 +02:00
if ( lien . split ( " : " ) [ 0 ] == " https " ) or ( lien . split ( " : " ) [ 0 ] == " http " ) :
2022-05-15 10:36:26 +02:00
driver . get ( lien )
2022-11-06 13:29:55 +01:00
WaitUntilVisible ( By . CSS_SELECTOR , ' div[class= " pull-left spacer-48-bottom punchcard-row " ] ' , browser = driver )
choix = driver . find_element ( By . CSS_SELECTOR , ' div[class= " pull-left spacer-48-bottom punchcard-row " ] ' ) # pull-left spacer-48-bottom punchcard-row? USELESS ?
2022-05-27 14:07:52 +02:00
nb = search ( " ([0-9]) of ([0-9]) completed " , driver . page_source )
2022-12-03 06:33:27 +01:00
if nb is None :
2022-05-27 14:07:52 +02:00
nb = search ( " ([0-9]) de ([0-9]) finalisé " , driver . page_source )
2022-12-03 06:33:27 +01:00
if nb is None :
nb = search ( " ([0-9]) licence \ (s \ ) sur ([0-9]) disponible \ (s \ ) " , driver . page_source )
if nb is None :
nb = [ 0 , 0 , 0 ]
2022-05-27 14:07:52 +02:00
for i in range ( int ( nb [ 2 ] ) - int ( nb [ 1 ] ) ) :
driver . refresh ( )
CustomSleep ( 2 )
choix = driver . find_element ( By . CLASS_NAME , " spacer-48-bottom " )
2022-06-06 12:32:37 +02:00
try :
ButtonText = search ( ' <span class= " pull-left margin-right-15 " >([^<^>]+)</span> ' , choix . get_attribute ( " innerHTML " ) ) [ 1 ]
bouton = driver . find_element ( By . XPATH , f ' //span[text()= " { ButtonText } " ] ' )
bouton . click ( )
except Exception as e1 :
try :
2022-11-26 15:07:32 +01:00
t = driver . find_element ( By . XPATH , ' /html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a ' )
2022-06-06 12:32:37 +02:00
t . click ( )
except Exception as e2 :
2022-10-25 10:03:24 +02:00
LogError ( f " fidélité - double erreur - e1 : { e1 } - e2 { e2 } " , driver , _mail )
2022-06-06 12:32:37 +02:00
break
2022-05-27 14:07:52 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
driver . switch_to . window ( driver . window_handles [ 1 ] )
TryPlay ( driver . title )
2022-06-06 12:32:37 +02:00
driver . get ( lien ) # USELESS ?
2022-05-27 14:07:52 +02:00
CustomSleep ( uniform ( 3 , 5 ) )
try :
Close ( driver . window_handles [ 1 ] )
except Exception as e :
2022-10-25 19:44:33 +02:00
printf ( e )
printf ( " fidelité - done " )
2022-05-27 14:07:52 +02:00
else :
2022-10-25 19:44:33 +02:00
printf ( " lien invalide " )
2022-04-14 23:03:16 +02:00
except Exception as e :
2022-11-18 17:19:40 +01:00
LogError ( f " Fidélité { e } " , driver , _mail )
2022-10-24 20:08:33 +02:00
def Mlogin ( echec ) :
try :
MobileDriver . get ( " https://www.bing.com/search?q=test+speed " )
MRGPD ( )
2022-11-06 13:29:55 +01:00
printf ( " start of Mobile login " )
2022-10-24 20:08:33 +02:00
MobileDriver . find_element ( By . ID , " mHamburger " ) . click ( )
2022-11-06 13:09:02 +01:00
WaitUntilVisible ( By . ID , " hb_s " , browser = MobileDriver )
2022-10-24 20:08:33 +02:00
MobileDriver . find_element ( By . ID , " hb_s " ) . click ( )
2022-11-06 13:09:02 +01:00
WaitUntilVisible ( By . ID , " i0116 " , browser = MobileDriver )
2022-10-24 20:08:33 +02:00
mail = MobileDriver . find_element ( By . ID , " i0116 " )
send_keys_wait ( mail , _mail )
mail . send_keys ( Keys . ENTER )
2022-11-06 13:09:02 +01:00
WaitUntilVisible ( By . ID , " i0118 " , browser = MobileDriver )
2022-10-24 20:08:33 +02:00
pwd = MobileDriver . find_element ( By . ID , " i0118 " )
send_keys_wait ( pwd , _password )
pwd . send_keys ( Keys . ENTER )
CustomSleep ( uniform ( 1 , 2 ) )
2022-11-06 13:09:02 +01:00
for i in [ " KmsiCheckboxField " , " iLooksGood " , " idSIButton9 " ] :
try :
MobileDriver . find_element ( By . ID , i ) . click ( )
except Exception as e :
pass
2022-11-06 13:29:55 +01:00
printf ( " end of Mobile login " )
2022-10-24 20:08:33 +02:00
except Exception as e :
echec + = 1
if echec < = 3 :
2022-10-25 19:44:33 +02:00
printf ( f " echec du login sur la version mobile. on reesaye ( { echec } /3), { e } " )
2022-10-24 20:08:33 +02:00
CustomSleep ( uniform ( 5 , 10 ) )
Mlogin ( echec )
else :
LogError (
2022-10-25 10:03:24 +02:00
f " login impossible 3 fois de suite. { e } " , MobileDriver , _mail
2022-10-24 20:08:33 +02:00
)
MobileDriver . quit ( )
return True
2022-10-31 15:32:39 +01:00
2022-10-24 20:08:33 +02:00
def MRGPD ( ) :
try :
MobileDriver . find_element ( By . ID , " bnp_btn_accept " ) . click ( )
except Exception as e :
pass
try :
MobileDriver . find_element ( By . ID , " bnp_hfly_cta2 " ) . click ( )
except Exception as e :
pass
2022-10-31 15:32:39 +01:00
2022-10-24 20:08:33 +02:00
def Alerte ( ) :
try :
alert = MobileDriver . switch_to . alert
alert . dismiss ( )
except exceptions . NoAlertPresentException as e :
pass
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError ( f " mobile.py -> Alerte : { e } " , MobileDriver , _mail )
2022-10-24 20:08:33 +02:00
def BingMobileSearch ( override = randint ( 22 , 25 ) ) :
2022-10-24 21:35:31 +02:00
global MobileDriver
2022-10-24 20:08:33 +02:00
MobileDriver = " unable to start "
try :
try :
MobileDriver = FirefoxDriver ( mobile = True )
MobileDriver . implicitly_wait ( 15 )
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError ( " BingMobileSearch - 1 - echec de la creation du driver mobile " , MobileDriver , _mail )
2022-11-12 23:00:45 +01:00
ChangeColor ( task [ " Mobile " ] , " red " )
2022-10-24 20:08:33 +02:00
echec = 0
if not Mlogin ( echec ) :
2022-11-12 23:48:54 +01:00
StartTask ( task [ " Mobile " ] )
2022-10-24 20:08:33 +02:00
CustomSleep ( uniform ( 1 , 2 ) )
MRGPD ( )
CustomSleep ( uniform ( 1 , 1.5 ) )
for i in range ( override ) : # 20
try :
mot = choice ( Liste_de_mot )
send_keys_wait ( MobileDriver . find_element ( By . ID , " sb_form_q " ) , mot )
MobileDriver . find_element ( By . ID , " sb_form_q " ) . send_keys ( Keys . ENTER )
2022-11-12 23:00:45 +01:00
AdvanceTask ( task [ " Mobile " ] , 1 / override * 100 )
2022-11-12 17:40:03 +01:00
#printf(MobileDriver.current_url)
2022-10-24 20:08:33 +02:00
CustomSleep ( uniform ( 5 , 20 ) )
Alerte ( ) # verifie si il y a des alertes (demande de positions ....)
MobileDriver . find_element ( By . ID , " sb_form_q " ) . clear ( )
except :
driver . refresh ( )
CustomSleep ( 30 )
i - = 1
MobileDriver . quit ( )
2022-11-12 23:00:45 +01:00
ChangeColor ( task [ " Mobile " ] , " green " )
2022-10-24 20:08:33 +02:00
except Exception as e :
2022-11-18 17:19:40 +01:00
LogError ( f " BingMobileSearch - 4 - { e } " , MobileDriver , _mail )
2022-10-24 20:08:33 +02:00
MobileDriver . quit ( )
2021-12-22 14:01:58 +01:00
2022-08-29 11:44:35 +02:00
def DailyRoutine ( custom = False ) :
2022-11-12 23:00:45 +01:00
2022-11-16 13:42:20 +01:00
ShowDefaultTask ( )
2022-10-31 15:32:39 +01:00
try :
2022-11-06 13:37:12 +01:00
if not custom : # custom already login
login ( )
2022-10-31 15:32:39 +01:00
except Banned :
2022-11-12 23:46:12 +01:00
LogError ( " THIS ACCOUND IS BANNED. FIX THIS ISSUE WITH -U " , driver , _mail )
2022-10-31 15:32:39 +01:00
return ( )
2022-04-14 23:03:16 +02:00
2022-10-31 15:32:39 +01:00
try :
AllCard ( )
except Exception as e :
LogError ( f " DailyRoutine - AllCard - \n { e } " , driver , _mail )
2022-05-18 19:07:25 +02:00
2022-10-31 15:32:39 +01:00
try :
BingPcSearch ( )
except Exception as e :
LogError ( f " DailyRoutine - BingPcSearch - \n { e } " , driver , _mail )
try :
BingMobileSearch ( )
except Exception as e :
LogError ( f " DailyRoutine - BingMobileSearch - \n { e } " , driver , _mail )
2022-11-09 19:36:22 +01:00
try :
Fidelite ( )
except Exception as e :
LogError ( f " DailyRoutine - Fidelité - \n { e } " , driver , _mail )
2022-10-31 15:32:39 +01:00
try :
LogPoint ( _mail )
except Exception as e :
LogError ( f " DailyRoutine - LogPoint - \n { e } " , driver , _mail )
2022-04-14 23:03:16 +02:00
2021-12-22 14:01:58 +01:00
2021-12-23 13:05:16 +01:00
def close ( ) :
driver . quit ( )
quit ( )
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
2022-04-11 12:30:45 +02:00
def dev ( ) :
2022-10-24 20:08:33 +02:00
pass
2021-12-22 14:01:58 +01:00
2022-04-14 23:03:16 +02:00
2022-02-14 16:48:57 +01:00
def CustomStart ( Credentials ) :
2022-11-16 13:42:20 +01:00
global START_TIME
2022-09-23 15:13:14 +02:00
if not LINUX_HOST :
2022-08-29 11:44:35 +02:00
raise NameError ( ' You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry. ' )
2022-11-12 23:31:58 +01:00
global driver , _mail , _password , p , task
2022-02-14 16:48:57 +01:00
2022-04-14 23:03:16 +02:00
system ( " clear " ) # clear from previous command to allow a clean choice
2022-10-31 15:32:39 +01:00
actions = [ " tout " , " daily " , " pc " , " mobile " , " LogPoint " , " Fidelite " , " dev " ]
2022-04-14 23:03:16 +02:00
Actions = enquiries . choose ( " quels Actions ? " , actions , multi = True )
2022-11-12 23:31:58 +01:00
liste = SelectAccount ( )
2022-11-14 22:36:56 +01:00
START_TIME = time ( ) # Reset timer to the start of the actions
2022-11-12 23:31:58 +01:00
with Progress (
TextColumn ( " [progress.description] {task.description} " ) ,
BarColumn ( ) ,
TaskProgressColumn ( ) ,
TimeRemainingColumn ( ) ,
TimeElapsedColumn ( ) ,
) as p :
task = modules . progress . dico ( p )
for _mail , _password in liste :
2022-02-23 18:50:41 +01:00
2022-11-12 23:31:58 +01:00
driver = FirefoxDriver ( )
driver . implicitly_wait ( 10 )
2022-04-14 23:03:16 +02:00
2022-11-12 23:31:58 +01:00
if login ( ) != " STOP " :
if " tout " in Actions :
DailyRoutine ( True )
2022-02-23 18:50:41 +01:00
2022-11-12 23:31:58 +01:00
if " daily " in Actions :
try :
AllCard ( )
except Exception as e :
LogError ( f " AllCards - { e } -- override " , driver , _mail )
2022-02-23 18:50:41 +01:00
2022-11-12 23:31:58 +01:00
if " pc " in Actions :
try :
ShowTask ( task [ " PC " ] )
BingPcSearch ( )
except Exception as e :
LogError ( f " il y a eu une erreur dans BingPcSearch, { e } -- override " , driver , _mail )
2022-02-23 18:50:41 +01:00
2022-11-12 23:31:58 +01:00
if " mobile " in Actions :
try :
ShowTask ( task [ " Mobile " ] )
BingMobileSearch ( )
except Exception as e :
LogError ( f " BingMobileSearch - { e } -- override " , driver , _mail )
2022-02-23 18:50:41 +01:00
2022-11-12 23:31:58 +01:00
if " Fidelite " in Actions :
try :
Fidelite ( )
except Exception as e :
LogError ( f " Fidelite - { e } -- override " , driver , _mail )
2022-02-23 18:50:41 +01:00
2022-11-12 23:31:58 +01:00
if " dev " in Actions :
try :
dev ( )
except Exception as e :
printf ( e )
break
2022-09-30 15:05:58 +02:00
2022-11-12 23:31:58 +01:00
if not " tout " in Actions :
try :
LogPoint ( _mail )
except Exception as e :
2022-11-18 17:19:40 +01:00
print ( f " CustomStart { e } " )
2022-11-12 23:31:58 +01:00
driver . close ( )
2022-02-23 18:50:41 +01:00
2022-04-14 23:03:16 +02:00
2022-10-31 15:32:39 +01:00
def SelectAccount ( multiple = True ) :
system ( " clear " ) # clear from previous command to allow a clean choice
emails = [ x [ 0 ] for x in Credentials ] # list of all email adresses
2023-01-14 17:36:28 +01:00
emailsSelected = enquiries . choose ( f " quel { ' s ' if multiple else ' ' } compte { ' s ' if multiple else ' ' } ? " , emails , multi = multiple )
2022-10-31 15:32:39 +01:00
return ( [ x for x in Credentials if x [ 0 ] in emailsSelected ] )
2021-12-22 14:01:58 +01:00
2022-11-12 23:00:45 +01:00
def unban2 ( ) :
2022-11-23 22:43:29 +01:00
global _mail , _password , driver
2022-10-31 15:32:39 +01:00
_mail , _password = SelectAccount ( False ) [ 0 ]
try :
2022-11-07 22:39:15 +01:00
driver = FirefoxDriver ( )
2022-10-31 15:32:39 +01:00
login ( )
raise NotBanned
except Banned :
unban ( )
except NotBanned :
2022-11-16 18:11:18 +01:00
printf ( " you are not currently banned on this account " )
2022-12-20 12:42:00 +01:00
2022-11-16 18:11:18 +01:00
def SavePointsFromFile ( file ) :
with open ( file ) as f :
reader = csv . reader ( f )
points_list = list ( reader )
for item in points_list :
compte , points = item [ 0 ] , item [ 1 ]
add_to_database ( compte , points , sql_host , sql_usr , sql_pwd , sql_database , save_if_fail = False )
with open ( file , " w " ) as f :
f . write ( " " )
2021-12-22 14:01:58 +01:00
2022-11-12 23:00:45 +01:00
2022-11-12 23:31:58 +01:00
def StartTask ( task ) :
2022-11-16 13:42:20 +01:00
ChangeColor ( task , " blue " )
2022-11-12 23:00:45 +01:00
p . start_task ( task )
2022-11-14 22:36:56 +01:00
p . update ( task , advance = 0 ) # Reset the Task if it was already filled to 100%
2022-11-12 23:00:45 +01:00
def ShowTask ( task ) :
p . update ( task , visible = True )
def AdvanceTask ( task , pourcentage ) :
2022-11-12 23:31:58 +01:00
p . update ( task , advance = pourcentage )
2022-11-12 23:00:45 +01:00
def ChangeColor ( task , newcolor ) :
2022-11-12 23:31:58 +01:00
old = p . tasks [ task ] . description
2022-11-12 23:00:45 +01:00
old = old . split ( ' ] ' )
old [ 0 ] = f " [ { newcolor } "
new = " ] " . join ( old )
2022-11-12 23:31:58 +01:00
p . update ( task , description = new )
2022-11-12 23:00:45 +01:00
2022-11-16 13:42:20 +01:00
def ShowDefaultTask ( ) :
for i in [ " all " , " carte1 " , " carte2 " , " carte0 " ] :
ShowTask ( task [ " daily " ] [ i ] )
for i in [ " PC " , " Mobile " ] :
ShowTask ( task [ i ] )
2022-11-12 23:07:51 +01:00
if CUSTOM_START :
CustomStart ( Credentials )
elif UNBAN :
unban2 ( )
2023-01-14 16:56:33 +01:00
elif CLAIM :
2023-01-14 17:19:52 +01:00
global _mail , _password
_mail , _password = SelectAccount ( False ) [ 0 ]
2023-01-14 17:36:28 +01:00
reward = enquiries . choose ( f " quels recompense ? " , [ " amazon " , " fnac " , " RP " ] , multi = False )
2023-01-14 17:19:52 +01:00
driver = FirefoxDriver ( )
login ( )
2023-01-14 17:36:28 +01:00
claim ( False , reward )
2023-01-14 17:19:52 +01:00
2022-11-16 18:11:18 +01:00
elif POINTS_FILE != " " :
SavePointsFromFile ( POINTS_FILE )
2022-11-12 23:07:51 +01:00
else :
with Progress (
2022-11-12 23:31:58 +01:00
TextColumn ( " [progress.description] {task.description} " ) ,
BarColumn ( ) ,
TaskProgressColumn ( ) ,
TimeRemainingColumn ( ) ,
TimeElapsedColumn ( ) ,
2022-11-12 23:07:51 +01:00
) as p :
task = modules . progress . dico ( p )
2022-11-12 23:00:45 +01:00
for _mail , _password in Credentials :
#system("pkill -9 firefox")
print ( " \n \n " )
print ( _mail )
CustomSleep ( 1 )
printf ( " début du driver " )
driver = FirefoxDriver ( )
printf ( " driver demarré " )
driver . implicitly_wait ( 7 )
try :
DailyRoutine ( )
driver . quit ( )
attente = uniform ( 1200 , 3600 )
printf ( f " finis. attente de { round ( attente / 60 ) } min " )
CustomSleep ( attente )
except KeyboardInterrupt :
print ( " canceled " )
close ( )