2022-03-28 18:31:55 +02:00
|
|
|
#!/usr/bin/python3.10
|
2022-02-17 12:19:47 +01:00
|
|
|
import asyncio
|
2022-02-17 12:57:51 +01:00
|
|
|
import configparser
|
2021-12-22 17:09:18 +01:00
|
|
|
import os
|
2022-02-17 12:19:47 +01:00
|
|
|
from csv import reader
|
2021-12-22 14:01:58 +01:00
|
|
|
from os import path, sys, system
|
2022-02-23 17:51:11 +01:00
|
|
|
from queue import Full
|
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-03-28 16:30:11 +02:00
|
|
|
from time import sleep, time
|
2022-04-10 18:43:33 +02:00
|
|
|
from requests import get
|
2022-04-18 09:37:47 +02:00
|
|
|
from datetime import timedelta
|
2022-02-17 12:19:47 +01:00
|
|
|
import discord
|
|
|
|
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
|
2022-04-14 23:03:16 +02:00
|
|
|
Colour,
|
|
|
|
Embed,
|
|
|
|
RequestsWebhookAdapter,
|
|
|
|
Webhook,
|
|
|
|
)
|
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
|
2021-12-22 14:01:58 +01:00
|
|
|
from selenium.webdriver.support import expected_conditions as EC
|
2022-02-17 12:19:47 +01:00
|
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
2022-02-19 19:40:52 +01:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
parser.add_argument(
|
|
|
|
"-o", "--override", help="override", dest="override", action="store_true"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-l", "--log", dest="log", help="enable logging in terminal", action="store_true"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-fl",
|
|
|
|
"--fulllog",
|
|
|
|
dest="fulllog",
|
|
|
|
help="enable full logging in terminal",
|
|
|
|
action="store_true",
|
|
|
|
)
|
2022-02-19 19:40:52 +01:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
override = args.override
|
|
|
|
Log = args.log
|
2022-02-23 17:33:44 +01:00
|
|
|
FullLog = args.fulllog
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
IsLinux = platform == "linux"
|
2022-03-28 16:30:11 +02:00
|
|
|
start_time = time()
|
2022-04-18 09:22:00 +02:00
|
|
|
|
|
|
|
global driver
|
2022-04-18 09:25:51 +02:00
|
|
|
driver = None
|
2022-04-18 09:22:00 +02:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
def Timer(text="undefined"):
|
2022-04-18 09:41:23 +02:00
|
|
|
return(f"[{timedelta(seconds = round(float(time() - start_time)))}] : " + str(text))
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
if IsLinux:
|
2022-02-23 18:39:53 +01:00
|
|
|
import enquiries
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
|
|
|
system("") # enable colors in cmd
|
2022-02-17 13:51:07 +01:00
|
|
|
|
2022-02-18 10:57:01 +01:00
|
|
|
config_path = "/home/pi/MsReward/config"
|
2022-02-17 12:57:51 +01:00
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read(config_path)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-02-17 12:57:51 +01:00
|
|
|
MotPath = config["DEFAULT"]["motpath"]
|
|
|
|
LogPath = config["DEFAULT"]["logpath"]
|
|
|
|
SuccessLink = config["DEFAULT"]["successlink"]
|
|
|
|
ErrorLink = config["DEFAULT"]["errorlink"]
|
2022-04-10 18:43:33 +02:00
|
|
|
fidelity = config["DEFAULT"]["fidelity"]
|
2022-02-17 12:57:51 +01:00
|
|
|
embeds = config["DEFAULT"]["embeds"] == "True"
|
|
|
|
Headless = config["DEFAULT"]["headless"] == "True"
|
2022-02-15 22:40:39 +01:00
|
|
|
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
g = open(MotPath, "r", encoding="utf-8")
|
|
|
|
Liste_de_mot = list(g.readline().split(","))
|
2022-02-15 22:40:39 +01:00
|
|
|
g.close()
|
|
|
|
|
2022-02-16 07:06:54 +01:00
|
|
|
webhookSuccess = Webhook.from_url(SuccessLink, adapter=RequestsWebhookAdapter())
|
|
|
|
webhookFailure = Webhook.from_url(ErrorLink, adapter=RequestsWebhookAdapter())
|
2022-02-15 22:40:39 +01: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 = (
|
|
|
|
"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"
|
|
|
|
)
|
2022-04-22 12:41:05 +02:00
|
|
|
MOBILE_USER_AGENT = (
|
|
|
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_8_1 like Mac OS X)"
|
|
|
|
"AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1"
|
|
|
|
)
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2022-04-22 12:41:05 +02:00
|
|
|
options = Options()
|
2021-12-22 14:01:58 +01:00
|
|
|
options.set_preference("browser.link.open_newwindow", 3)
|
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-04-14 23:03:16 +02:00
|
|
|
return webdriver.Firefox(options=options)
|
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def printf(txt, end="", Mobdriver=driver):
|
|
|
|
if Log:
|
2022-04-18 09:25:51 +02:00
|
|
|
print(Timer(txt))
|
2022-04-18 09:29:45 +02:00
|
|
|
elif FullLog:
|
|
|
|
try :
|
|
|
|
LogError(Timer(txt), Mobdriver=Mobdriver)
|
|
|
|
except Exception as e:
|
2022-04-18 09:37:47 +02:00
|
|
|
print("\n" + Timer(e) + "\n")
|
2022-04-18 09:25:51 +02:00
|
|
|
|
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
def CustomSleep(temps):
|
2022-04-30 11:25:16 +02:00
|
|
|
if Log or not IsLinux: #only print sleep when user see it
|
2021-12-27 18:04:58 +01:00
|
|
|
c = False
|
2022-04-14 23:03:16 +02:00
|
|
|
points = [
|
|
|
|
" . ",
|
|
|
|
" . ",
|
|
|
|
" . ",
|
|
|
|
" .",
|
|
|
|
" .",
|
|
|
|
" . ",
|
|
|
|
" . ",
|
|
|
|
" . ",
|
|
|
|
]
|
|
|
|
for i in range(int(temps)):
|
2021-12-27 18:04:58 +01:00
|
|
|
c = True
|
2022-04-14 23:03:16 +02:00
|
|
|
for i in range(8):
|
2021-12-27 18:04:58 +01:00
|
|
|
sleep(0.125)
|
2022-04-14 23:03:16 +02:00
|
|
|
print(points[i], end="\r")
|
2021-12-27 18:04:58 +01:00
|
|
|
|
|
|
|
if c:
|
2022-04-14 23:03:16 +02:00
|
|
|
print(". ", end="\r")
|
2021-12-27 18:04:58 +01:00
|
|
|
sleep(temps - int(temps))
|
|
|
|
print("\n")
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
2021-12-27 18:04:58 +01:00
|
|
|
sleep(temps)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2021-12-29 11:51:08 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def ListTabs(Mdriver=None):
|
2021-12-22 14:01:58 +01:00
|
|
|
tabs = []
|
2022-04-14 23:03:16 +02:00
|
|
|
if Mdriver:
|
2021-12-29 11:08:15 +01:00
|
|
|
ldriver = Mdriver
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
2021-12-29 11:08:15 +01:00
|
|
|
ldriver = driver
|
2022-04-14 23:03:16 +02:00
|
|
|
for i in ldriver.window_handles:
|
2021-12-29 11:08:15 +01:00
|
|
|
ldriver.switch_to.window(i)
|
|
|
|
tabs.append(ldriver.current_url)
|
2022-04-14 23:03:16 +02:00
|
|
|
return tabs
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-22 12:41:05 +02:00
|
|
|
#il faut fix le fait qu'il essaye d'envoyer un truc sans url, listtab[0] = about:blank
|
2022-04-14 23:03:16 +02:00
|
|
|
def LogError(message, log=FullLog, Mobdriver=None):
|
|
|
|
if Mobdriver:
|
2021-12-29 10:54:25 +01:00
|
|
|
gdriver = Mobdriver
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
2021-12-29 10:54:25 +01:00
|
|
|
gdriver = driver
|
2022-04-14 23:03:16 +02:00
|
|
|
if not log:
|
|
|
|
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
|
|
|
|
if IsLinux:
|
|
|
|
with open("page.html", "w") as f:
|
2021-12-29 10:54:25 +01:00
|
|
|
f.write(gdriver.page_source)
|
2022-04-07 13:43:39 +02:00
|
|
|
|
2021-12-29 10:54:25 +01:00
|
|
|
gdriver.save_screenshot("screenshot.png")
|
2022-04-14 23:03:16 +02:00
|
|
|
if not log:
|
2022-02-23 17:51:11 +01:00
|
|
|
embed = discord.Embed(
|
|
|
|
title="An Error has occured",
|
|
|
|
description=str(message),
|
2022-04-14 23:03:16 +02:00
|
|
|
colour=Colour.red(),
|
2022-02-23 17:51:11 +01:00
|
|
|
)
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
2022-02-23 17:51:11 +01:00
|
|
|
embed = discord.Embed(
|
|
|
|
title="Full log is enabled",
|
|
|
|
description=str(message),
|
2022-04-14 23:03:16 +02:00
|
|
|
colour=Colour.blue(),
|
2022-02-23 17:51:11 +01:00
|
|
|
)
|
2022-04-07 13:43:39 +02:00
|
|
|
|
2022-02-23 17:33:44 +01:00
|
|
|
file = discord.File("screenshot.png")
|
|
|
|
embed.set_image(url="attachment://screenshot.png")
|
|
|
|
embed.set_footer(text=_mail)
|
|
|
|
webhookFailure.send(embed=embed, file=file)
|
2022-04-14 23:03:16 +02:00
|
|
|
webhookFailure.send(file=discord.File("page.html"))
|
2022-02-23 17:33:44 +01:00
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02: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")
|
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])
|
|
|
|
|
|
|
|
|
|
|
|
def RGPD():
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
driver.find_element(By.ID, "bnp_btn_accept").click()
|
|
|
|
except:
|
2021-12-22 14:01:58 +01:00
|
|
|
pass
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
driver.find_element(By.ID, "bnp_hfly_cta2").click()
|
|
|
|
except:
|
2021-12-22 14:01:58 +01:00
|
|
|
pass
|
|
|
|
|
2021-12-23 17:36:53 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def PlayQuiz2(override=None):
|
2022-03-28 16:55:35 +02:00
|
|
|
printf("debut de PlayQuiz2")
|
2022-04-14 23:03:16 +02:00
|
|
|
if not override:
|
2022-02-23 18:10:31 +01:00
|
|
|
override = 10
|
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:
|
|
|
|
LogError("PlayQuiz2" + str(e))
|
|
|
|
break
|
2022-03-28 16:55:35 +02:00
|
|
|
printf("PlayQuiz2 finis")
|
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 PlayQuiz8(override=3):
|
2022-03-28 16:55:35 +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
|
2021-12-23 17:36:53 +01:00
|
|
|
for i in range(override):
|
2022-04-11 12:36:03 +02:00
|
|
|
RGPD()
|
2022-04-14 23:03:16 +02:00
|
|
|
sleep(uniform(3, 5))
|
|
|
|
ListeOfGood = []
|
|
|
|
for i in range(1, 9):
|
|
|
|
try:
|
|
|
|
Card = driver.find_element(By.ID, f"rqAnswerOption{i-1}")
|
|
|
|
if 'iscorrectoption="True" ' in Card.get_attribute("outerHTML"):
|
|
|
|
ListeOfGood.append(f"rqAnswerOption{i-1}") # premier div = 3 ?
|
|
|
|
except Exception as e:
|
2022-02-17 14:20:44 +01:00
|
|
|
LogError("playquiz8 - 1 - " + e)
|
2021-12-22 14:01:58 +01:00
|
|
|
shuffle(ListeOfGood)
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
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:
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
driver.execute_script("arguments[0].click();", elem)
|
|
|
|
except Exception as e:
|
2022-02-17 14:20:44 +01:00
|
|
|
LogError("playquizz8 - 2 - " + e)
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
|
|
|
if override:
|
|
|
|
printf("playquiz8 - 3 -" + e)
|
|
|
|
else:
|
2022-02-17 14:20:44 +01:00
|
|
|
LogError("playquizz8 - 3 - " + e)
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
LogError("PlayQuiz8 - 4 - " + str(e))
|
|
|
|
print(str(ListeOfGood))
|
2022-03-28 16:55:35 +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-03-28 16:55:35 +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-03-28 16:55:35 +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)
|
|
|
|
printf(f"validation de la reponse ",end="\r",)
|
|
|
|
printf(f"validation de la reponse {i+1}/{override} {reponse}", end="\r")
|
|
|
|
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:
|
2021-12-22 14:01:58 +01:00
|
|
|
LogError("PlayQuiz4" + str(e))
|
|
|
|
raise ValueError(e)
|
2022-03-28 16:55:35 +02:00
|
|
|
printf("PlayQuiz4 : end")
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-03-28 17:00:36 +02:00
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
def PlayPoll():
|
2022-03-28 16:55:35 +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:
|
|
|
|
LogError("PlayPoll" + str(e))
|
2021-12-22 14:01:58 +01:00
|
|
|
raise ValueError(e)
|
2022-03-28 16:55:35 +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-03-28 16:55:35 +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:
|
2021-12-22 14:01:58 +01:00
|
|
|
for i in range(3):
|
|
|
|
sleep(1)
|
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
|
|
|
|
TryPlay(titre)
|
|
|
|
sleep(1)
|
|
|
|
reset()
|
|
|
|
print(f"DailyCard {titre} ok ")
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-03-28 17:00:36 +02:00
|
|
|
printf(f"Allcard card {titre} error ({e})")
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
|
|
|
LogError(f"Dailycards {e}")
|
|
|
|
|
|
|
|
try:
|
2022-04-07 13:43:39 +02:00
|
|
|
dailyCards()
|
2022-04-14 23:03:16 +02:00
|
|
|
except:
|
2022-04-07 13:43:39 +02:00
|
|
|
printf("erreur ici")
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
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):
|
2021-12-23 13:51:07 +01:00
|
|
|
printf("debut 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()
|
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])
|
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
|
|
|
|
except Exception as e:
|
2022-04-14 23:03:16 +02:00
|
|
|
LogError(f"2eme partie de AllCard (weekly card)\n {e}")
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def send_keys_wait(element, keys):
|
|
|
|
for i in keys:
|
2021-12-22 14:01:58 +01:00
|
|
|
element.send_keys(i)
|
2022-04-22 12:41:05 +02:00
|
|
|
sleep(uniform(0.1, 0.3))
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def login():
|
2022-03-28 16:55:35 +02:00
|
|
|
printf("login : start")
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
try:
|
|
|
|
driver.find_element(
|
|
|
|
By.CSS_SELECTOR, f'[title="Rejoindre"]'
|
|
|
|
).click() # depend of the language of the page
|
|
|
|
except:
|
|
|
|
driver.find_element(
|
|
|
|
By.CSS_SELECTOR, f'[title="Join now"]'
|
|
|
|
).click() # depend of the language of the page
|
2022-03-28 16:55:35 +02:00
|
|
|
|
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-04-10 19:43:45 +02:00
|
|
|
CustomSleep(5)
|
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-03-28 16:55:35 +02:00
|
|
|
printf("pwd envoyé")
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
driver.find_element(By.ID, "KmsiCheckboxField").click()
|
|
|
|
except Exception as e:
|
|
|
|
printf(
|
|
|
|
f"login - 1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}"
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
driver.find_element(By.ID, "idSIButton9").click()
|
|
|
|
except Exception as e:
|
|
|
|
printf(
|
|
|
|
f"login - 2 - erreur validation bouton idSIButton9. pas forcement grave {e}"
|
|
|
|
)
|
2022-03-28 16:55:35 +02:00
|
|
|
|
|
|
|
printf("login completed")
|
2021-12-22 14:01:58 +01:00
|
|
|
RGPD()
|
2022-04-14 23:03:16 +02:00
|
|
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
MainWindows = driver.current_window_handle
|
2022-04-14 23:03:16 +02:00
|
|
|
return MainWindows
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
except Exception as e:
|
2022-02-23 17:17:29 +01:00
|
|
|
LogError("login - 3 - " + str(e))
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
def BingPcSearch(override=randint(35, 40)):
|
|
|
|
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 :
|
|
|
|
printf(e)
|
2021-12-22 14:01:58 +01:00
|
|
|
sleep(10)
|
|
|
|
driver.refresh()
|
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-04-14 23:03:16 +02:00
|
|
|
progressBar(i, override, name="PC")
|
|
|
|
sleep(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:
|
|
|
|
printf(e)
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2021-12-23 13:05:16 +01:00
|
|
|
driver.refresh()
|
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:
|
|
|
|
LogError(f"BingPcSearch - clear la barre de recherche - {e}")
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
print("\n\n")
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def BingMobileSearch(override=randint(22, 25)):
|
|
|
|
MobileDriver = (
|
|
|
|
"si il y a ca dans les logs, c'est que Mobiledriver n'a pas demarrer "
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
try:
|
2022-04-22 12:41:05 +02:00
|
|
|
MobileDriver = FirefoxDriver(mobile=True)
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2021-12-29 13:32:16 +01:00
|
|
|
sleep(30)
|
2022-04-14 23:03:16 +02:00
|
|
|
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile")
|
2022-04-22 12:41:05 +02:00
|
|
|
MobileDriver = FirefoxDriver(mobile=True)
|
2021-12-29 13:32:16 +01:00
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
echec = 0
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
def Mlogin(echec):
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
MobileDriver.get(
|
|
|
|
"https://www.bing.com/search?q=test+speed&qs=LS&pq=test+s&sk=PRES1&sc=8-6&cvid=19&FORM=QBRE&sp=1"
|
|
|
|
)
|
|
|
|
CustomSleep(uniform(3, 5))
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("debut du login", Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
MobileDriver.find_element(By.ID, "mHamburger").click()
|
|
|
|
CustomSleep(uniform(1, 2))
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("login - 1", Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
MobileDriver.find_element(By.ID, "hb_s").click()
|
|
|
|
CustomSleep(uniform(1, 2))
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("login - 2", Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
mail = MobileDriver.find_element(By.ID, "i0116")
|
2021-12-22 14:01:58 +01:00
|
|
|
send_keys_wait(mail, _mail)
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("login - 3", Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
mail.send_keys(Keys.ENTER)
|
|
|
|
CustomSleep(uniform(1, 2))
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("login - 4", Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
pwd = MobileDriver.find_element(By.ID, "i0118")
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("login - 5", Mobdriver=MobileDriver)
|
2021-12-22 14:01:58 +01:00
|
|
|
send_keys_wait(pwd, _password)
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("login - 6", Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
pwd.send_keys(Keys.ENTER)
|
|
|
|
CustomSleep(uniform(1, 2))
|
2022-03-06 16:38:18 +01:00
|
|
|
printf("fin du login", Mobdriver=MobileDriver)
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2021-12-22 14:01:58 +01:00
|
|
|
echec += 1
|
2022-04-14 23:03:16 +02:00
|
|
|
if echec <= 3:
|
|
|
|
printf(
|
|
|
|
f"echec du login sur la version mobile. on reesaye ({echec}/3), {e}"
|
|
|
|
)
|
|
|
|
CustomSleep(uniform(5, 10))
|
2021-12-22 14:01:58 +01:00
|
|
|
Mlogin(echec)
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
|
|
|
LogError(
|
|
|
|
f"login impossible 3 fois de suite. {e}", Mobdriver=MobileDriver
|
|
|
|
)
|
2021-12-22 14:01:58 +01:00
|
|
|
MobileDriver.quit()
|
2022-04-14 23:03:16 +02:00
|
|
|
return True
|
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
def MRGPD():
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
MobileDriver.find_element(By.ID, "bnp_btn_accept").click()
|
2022-04-22 12:41:05 +02:00
|
|
|
except Exception as e:
|
|
|
|
printf(e)
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
MobileDriver.find_element(By.ID, "bnp_hfly_cta2").click()
|
2022-04-22 12:41:05 +02:00
|
|
|
except Exception as e:
|
|
|
|
printf(e)
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
def Alerte():
|
|
|
|
try:
|
|
|
|
alert = MobileDriver.switch_to.alert
|
|
|
|
alert.dismiss()
|
2022-04-14 23:03:16 +02:00
|
|
|
except exceptions.NoAlertPresentException as e:
|
2021-12-22 14:01:58 +01:00
|
|
|
pass
|
2021-12-23 13:05:16 +01:00
|
|
|
except Exception as e:
|
2022-04-14 23:03:16 +02:00
|
|
|
LogError(
|
|
|
|
f"error sur une alerte dans le driver mobile. {e}",
|
|
|
|
Mobdriver=MobileDriver,
|
|
|
|
)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
if not Mlogin(echec):
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
CustomSleep(uniform(1, 2))
|
2021-12-22 14:01:58 +01:00
|
|
|
MRGPD()
|
2022-04-14 23:03:16 +02:00
|
|
|
CustomSleep(uniform(1, 1.5))
|
|
|
|
send_keys_wait(
|
|
|
|
MobileDriver.find_element(By.ID, "sb_form_q"),
|
|
|
|
Keys.BACKSPACE
|
|
|
|
+ Keys.BACKSPACE
|
|
|
|
+ Keys.BACKSPACE
|
|
|
|
+ Keys.BACKSPACE
|
|
|
|
+ Keys.BACKSPACE
|
|
|
|
+ Keys.BACKSPACE,
|
|
|
|
)
|
|
|
|
|
|
|
|
for i in range(override): # 20
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-02-18 20:29:13 +01:00
|
|
|
mot = choice(Liste_de_mot)
|
2022-04-14 23:03:16 +02: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)
|
|
|
|
progressBar(i, override, name="Mobile")
|
2022-03-06 16:44:09 +01:00
|
|
|
printf(MobileDriver.current_url, Mobdriver=MobileDriver)
|
2022-04-14 23:03:16 +02:00
|
|
|
sleep(uniform(5, 20))
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
Alerte() # verifie si il y a des alertes (demande de positions ....)
|
2021-12-23 13:05:16 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
for i in range(len(mot)):
|
|
|
|
MobileDriver.find_element(By.ID, "sb_form_q").clear()
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
MobileDriver.quit()
|
|
|
|
|
|
|
|
except Exception as e:
|
2022-04-14 23:03:16 +02:00
|
|
|
LogError("BingMobileSearch" + str(e), Mobdriver=MobileDriver)
|
|
|
|
try:
|
2021-12-23 10:53:53 +01:00
|
|
|
MobileDriver.quit()
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-02-17 14:20:44 +01:00
|
|
|
LogError(f"can't close mobile driveer . {e}")
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2021-12-23 13:51:07 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def TryPlay(nom="inconnu"):
|
2021-12-22 14:01:58 +01:00
|
|
|
RGPD()
|
2022-03-02 10:33:43 +01:00
|
|
|
printf("TryPlay en cours")
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
def play(number, override=None):
|
|
|
|
if number == 8 or number == 9:
|
|
|
|
try:
|
|
|
|
printf(f"\033[96m Quiz 8 détécté sur la page {nom} \033[0m")
|
2022-03-28 19:20:06 +02:00
|
|
|
PlayQuiz8()
|
2022-04-14 23:03:16 +02:00
|
|
|
printf(f"\033[92m Quiz 8 reussit sur {nom} \033[0m")
|
|
|
|
except Exception as e:
|
|
|
|
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:
|
|
|
|
printf(f"\033[96m Quiz 4 détécté sur la page {nom} \033[0m")
|
2022-03-28 19:20:06 +02:00
|
|
|
PlayQuiz4()
|
2022-04-14 23:03:16 +02:00
|
|
|
print(f"\033[92m Quiz 4 reussit sur {nom} \033[0m")
|
|
|
|
except Exception as e:
|
|
|
|
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:
|
|
|
|
printf(f"\033[96m Quiz 2 détécté sur la page {nom}\033[0m")
|
2022-03-28 19:20:06 +02:00
|
|
|
PlayQuiz2()
|
2022-04-14 23:03:16 +02:00
|
|
|
print(f"\033[92m Quiz 2 reussit sur la page {nom}\033[0m")
|
|
|
|
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 detecté"
|
|
|
|
)
|
|
|
|
|
|
|
|
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-04-22 12:41:05 +02:00
|
|
|
# printf(e) normal error here
|
2022-04-14 23:03:16 +02:00
|
|
|
if "bt_PollRadio" in driver.page_source:
|
|
|
|
try:
|
|
|
|
print("Poll détected", end="\r")
|
2021-12-22 14:01:58 +01:00
|
|
|
RGPD()
|
|
|
|
PlayPoll()
|
2022-04-14 23:03:16 +02:00
|
|
|
print("Poll reussit ")
|
|
|
|
except Exception as e:
|
|
|
|
printf(f"TryPlay - 1 - Poll aborted {e}")
|
|
|
|
|
|
|
|
elif "rqQuestionState" in driver.page_source:
|
|
|
|
try:
|
|
|
|
number = driver.page_source.count("rqAnswerOption")
|
|
|
|
restant = len(
|
|
|
|
findall('"rqQuestionState.?." class=', driver.page_source)
|
|
|
|
) - len(
|
|
|
|
findall(
|
|
|
|
'"rqQuestionState.?." class="filledCircle"', driver.page_source
|
|
|
|
)
|
|
|
|
)
|
2021-12-23 17:55:04 +01:00
|
|
|
printf(f"recovery détécté. quiz : {number}, restant : {restant +1}")
|
2022-04-14 23:03:16 +02:00
|
|
|
play(number, override=restant + 1)
|
|
|
|
except Exception as e:
|
2022-02-17 14:20:44 +01:00
|
|
|
printf("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:
|
|
|
|
print(f"rien a 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
|
|
|
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
if not IsLinux:
|
2021-12-22 14:01:58 +01:00
|
|
|
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
2021-12-22 14:01:58 +01:00
|
|
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
regex1 = '<a href="https://rewards\.bing\.com/" title="((.{1,3}),(.{1,3})) points" target="_blank"'
|
|
|
|
try:
|
|
|
|
point = search(regex1, driver.page_source)[1].replace(",", "")
|
|
|
|
|
|
|
|
except Exception as e:
|
2022-02-08 09:45:53 +01: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-04-14 23:03:16 +02:00
|
|
|
CustomSleep(uniform(10, 20))
|
|
|
|
try:
|
|
|
|
point = search('availablePoints":([\d]+)', driver.page_source)[1]
|
|
|
|
except Exception as e:
|
2022-02-17 14:20:44 +01:00
|
|
|
LogError(f"LogPoint - 2 - {e}")
|
2022-02-08 09:45:53 +01:00
|
|
|
point = "erreur"
|
2021-12-22 14:01:58 +01:00
|
|
|
|
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-02-17 12:57:51 +01:00
|
|
|
if embeds:
|
|
|
|
embed = discord.Embed(
|
2022-04-14 23:03:16 +02:00
|
|
|
title=f"{account} actuellement à {str(point)} points", colour=Colour.green()
|
2022-02-17 12:57:51 +01:00
|
|
|
)
|
2022-02-17 13:40:37 +01:00
|
|
|
embed.set_footer(text=account)
|
2022-02-17 12:57:51 +01:00
|
|
|
webhookSuccess.send(embed=embed)
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
|
|
|
webhookSuccess.send(f"{account} actuellement à {str(point)} points")
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
|
2022-04-10 18:43:33 +02:00
|
|
|
def Fidelite(lien):
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
|
|
|
while 1:
|
|
|
|
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-04-10 18:43:33 +02:00
|
|
|
driver.get(lien)
|
|
|
|
sleep(2)
|
2022-04-14 23:03:16 +02:00
|
|
|
choix = driver.find_element(
|
|
|
|
By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]'
|
|
|
|
) # pull-left spacer-48-bottom punchcard-row
|
|
|
|
nb = search("([0-9]) of ([0-9]) completed", driver.page_source)
|
|
|
|
if not nb:
|
|
|
|
nb = search("([0-9]) de ([0-9]) finalisé", driver.page_source)
|
|
|
|
for i in range(int(nb[2]) - int(nb[1])):
|
2022-04-11 12:48:22 +02:00
|
|
|
driver.refresh()
|
|
|
|
CustomSleep(2)
|
2022-04-14 23:03:16 +02:00
|
|
|
choix = driver.find_element(By.CLASS_NAME, "spacer-48-bottom")
|
|
|
|
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()
|
2022-04-14 23:03:16 +02:00
|
|
|
CustomSleep(uniform(3, 5))
|
2022-04-11 12:27:58 +02:00
|
|
|
driver.switch_to.window(driver.window_handles[1])
|
2021-12-23 13:05:16 +01:00
|
|
|
TryPlay(driver.title)
|
2022-04-10 18:43:33 +02:00
|
|
|
driver.get(lien)
|
2022-04-14 23:03:16 +02:00
|
|
|
CustomSleep(uniform(3, 5))
|
|
|
|
try:
|
2022-04-11 12:27:58 +02:00
|
|
|
Close(driver.window_handles[1])
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-04-11 12:27:58 +02:00
|
|
|
printf(e)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
printf("on a reussit la partie fidélité")
|
|
|
|
except Exception as e:
|
2021-12-22 14:01:58 +01:00
|
|
|
LogError("Fidélité" + str(e))
|
|
|
|
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
def CheckPoint(): # a fix, ne marche pas dans 80% des cas, pas appelé aujourd'hui
|
2021-12-22 14:01:58 +01:00
|
|
|
driver.get("https://rewards.microsoft.com/pointsbreakdown")
|
|
|
|
txt = driver.page_source
|
2022-04-14 23:03:16 +02:00
|
|
|
pc = search("([0-9][0-9]|[0-9])</b> / 90", txt)
|
|
|
|
mobile = search("([0-9][0-9]|[0-9])</b> / 60", txt)
|
|
|
|
if mobile:
|
2021-12-22 14:01:58 +01:00
|
|
|
if mobile[1] != 60:
|
2022-04-14 23:03:16 +02:00
|
|
|
BingMobileSearch(22 - (int(mobile[1]) / 3))
|
|
|
|
if pc:
|
2021-12-22 14:01:58 +01:00
|
|
|
if pc[1] != 90:
|
2022-04-14 23:03:16 +02:00
|
|
|
BingPcSearch(32 - (int(pc[1]) / 3))
|
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
def DailyRoutine():
|
|
|
|
MainWindows = login()
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2021-12-22 14:01:58 +01:00
|
|
|
AllCard()
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
|
|
|
LogError(
|
|
|
|
f"pas normal sauf si relancer a la main, juste pour les recherches bing (DalyRoutine -> AllCard) \n {e}"
|
|
|
|
)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2021-12-22 14:01:58 +01:00
|
|
|
BingPcSearch()
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2021-12-22 14:01:58 +01:00
|
|
|
LogError(f"il y a eu une erreur dans BingPcSearch, {e}")
|
2022-04-14 23:03:16 +02:00
|
|
|
CustomSleep(uniform(3, 20))
|
|
|
|
|
|
|
|
try:
|
2021-12-22 14:01:58 +01:00
|
|
|
BingMobileSearch()
|
2021-12-22 17:01:00 +01:00
|
|
|
except Exception as e:
|
2022-04-14 23:03:16 +02:00
|
|
|
LogError(f"BingMobileSearch - {e}")
|
|
|
|
print("\n")
|
|
|
|
CustomSleep(uniform(3, 20))
|
|
|
|
try:
|
2022-04-10 19:43:45 +02:00
|
|
|
FidelityTest()
|
2022-04-14 23:03:16 +02:00
|
|
|
except:
|
2022-04-10 19:43:45 +02:00
|
|
|
pass
|
2022-04-14 23:03:16 +02:00
|
|
|
|
|
|
|
try:
|
2021-12-22 17:01:00 +01:00
|
|
|
LogPoint(_mail)
|
2021-12-23 13:51:07 +01:00
|
|
|
except Exception as e:
|
2022-04-14 23:03:16 +02:00
|
|
|
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
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2022-04-10 19:43:45 +02:00
|
|
|
def FidelityTest():
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2022-04-10 18:43:33 +02:00
|
|
|
result = get(fidelity)
|
|
|
|
lien = result.content.decode("UTF-8")
|
|
|
|
print(lien)
|
|
|
|
Fidelite(lien)
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-04-10 18:43:33 +02:00
|
|
|
print(f"erreur dans la partie dev : {e}")
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2022-04-11 12:30:45 +02:00
|
|
|
def dev():
|
|
|
|
FidelityTest()
|
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):
|
|
|
|
global driver
|
2022-02-14 16:55:07 +01:00
|
|
|
global _mail
|
|
|
|
global _password
|
2022-02-14 16:48:57 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
ids = [x[0] for x in Credentials] # list of all email adresses
|
|
|
|
actions = ["tout", "daily", "pc", "mobile", "LogPoint", "dev"]
|
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
|
|
|
|
Comptes = enquiries.choose("quels comptes ?", ids, multi=True)
|
|
|
|
Actions = enquiries.choose("quels Actions ?", actions, multi=True)
|
2022-02-23 18:50:41 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
for i in Comptes:
|
2022-02-23 18:50:41 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
_mail = Credentials[ids.index(i)][0]
|
2022-02-23 18:50:41 +01:00
|
|
|
_password = Credentials[ids.index(i)][1]
|
2022-04-22 12:41:05 +02:00
|
|
|
driver = FirefoxDriver()
|
2022-04-11 12:48:22 +02:00
|
|
|
driver.implicitly_wait(7)
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2022-02-18 20:29:13 +01:00
|
|
|
login()
|
2022-04-14 23:03:16 +02:00
|
|
|
if "tout" in Actions:
|
2022-02-23 18:50:41 +01:00
|
|
|
DailyRoutine()
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
if "daily" in Actions:
|
|
|
|
try:
|
2022-02-23 18:50:41 +01:00
|
|
|
AllCard()
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
|
|
|
LogError(
|
|
|
|
f"pas normal sauf si relancer a la main, juste pour les recherches bing (DalyRoutine -> AllCard) \n {str(e)}. -- override"
|
|
|
|
)
|
2022-02-23 18:50:41 +01:00
|
|
|
|
|
|
|
if "pc" in Actions:
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2022-02-23 18:50:41 +01:00
|
|
|
BingPcSearch()
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-02-23 18:50:41 +01:00
|
|
|
LogError(f"il y a eu une erreur dans BingPcSearch, {e} -- override")
|
|
|
|
|
|
|
|
if "mobile" in Actions:
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2022-02-23 18:50:41 +01:00
|
|
|
BingMobileSearch()
|
|
|
|
except Exception as e:
|
2022-04-14 23:03:16 +02:00
|
|
|
LogError(f"BingMobileSearch - {e} -- override")
|
2022-02-23 18:50:41 +01:00
|
|
|
|
2022-04-10 18:43:33 +02:00
|
|
|
if "dev" in Actions:
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2022-04-10 18:43:33 +02:00
|
|
|
dev()
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-04-10 18:43:33 +02:00
|
|
|
printf(e)
|
|
|
|
break
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2022-02-23 18:50:41 +01:00
|
|
|
LogPoint(_mail)
|
2022-04-14 23:03:16 +02:00
|
|
|
except Exception as e:
|
2022-02-23 18:50:41 +01:00
|
|
|
print("CustomStart " + str(e))
|
2022-02-23 19:02:24 +01:00
|
|
|
driver.close()
|
2022-02-23 18:50:41 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
|
2021-12-22 14:01:58 +01:00
|
|
|
with open(LogPath) as f:
|
|
|
|
reader = reader(f)
|
2022-02-23 19:02:24 +01:00
|
|
|
Credentials = list(reader)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
|
|
|
shuffle(Credentials)
|
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
if override:
|
2022-02-14 16:48:57 +01:00
|
|
|
CustomStart(Credentials)
|
2022-04-14 23:03:16 +02:00
|
|
|
else:
|
|
|
|
for i in Credentials:
|
2022-02-16 07:06:54 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
_mail = i[0]
|
2022-02-14 16:48:57 +01:00
|
|
|
_password = i[1]
|
2021-12-29 11:51:08 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
print("\n\n")
|
2022-02-14 16:48:57 +01:00
|
|
|
print(_mail)
|
|
|
|
CustomSleep(1)
|
2022-03-28 16:55:35 +02:00
|
|
|
printf("debut du driver")
|
2022-04-22 12:41:05 +02:00
|
|
|
driver = FirefoxDriver()
|
2022-03-28 16:55:35 +02:00
|
|
|
printf("driver demarré")
|
2022-04-11 12:48:22 +02:00
|
|
|
driver.implicitly_wait(7)
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
try:
|
2021-12-22 17:01:00 +01:00
|
|
|
DailyRoutine()
|
|
|
|
driver.quit()
|
2022-04-18 09:25:51 +02:00
|
|
|
attente = uniform(1200, 3600)
|
|
|
|
print(f"finis. attente de {round(attente/60)}min")
|
|
|
|
CustomSleep(attente)
|
2022-02-23 17:33:44 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("canceled")
|
2021-12-23 13:05:16 +01:00
|
|
|
close()
|
2021-12-22 14:01:58 +01:00
|
|
|
|
2022-04-14 23:03:16 +02:00
|
|
|
if IsLinux:
|
|
|
|
system("pkill -9 firefox")
|