10 Commits

Author SHA1 Message Date
93bb634f7c some fixes here and there 2023-04-06 23:41:11 +02:00
31426a1dfd well, it should be really more robust as it doesn't rely on XPATH everywhere anymore 2023-04-06 23:04:57 +02:00
f862af8699 version control 2023-04-04 21:27:02 +02:00
78e7342acf last update of the night ? 2023-04-04 21:26:40 +02:00
4d8157ba1e better stronger faster 2023-04-04 21:18:09 +02:00
661566aade no clue if that's better 2023-04-04 21:07:12 +02:00
eb2b9dc2d3 you should now start using main : it can finally pass args 2023-04-04 20:59:45 +02:00
3385540350 better way if manually updated 2023-04-04 20:50:56 +02:00
0588180dda should be good for now 2023-04-04 20:46:10 +02:00
9995bc8e25 Auto Updates ? 2023-04-04 20:37:48 +02:00
5 changed files with 66 additions and 38 deletions

2
.gitignore vendored
View File

@ -11,3 +11,5 @@ data
/user_data
install.sh
nohup.out
test.py
points.csv

49
V5.py
View File

@ -221,9 +221,10 @@ def all_cards(): # return to the main page and closes all other tabs
if len(driver.window_handles) == 1:
driver.get("https://www.bing.com/rewardsapp/flyout")
if part2:
driver.find_element(
By.XPATH, "/html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1]"
).click()
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
expanded = row_element.get_attribute("aria-expanded")
if expanded != "true":
row_element.click()
else:
driver.switch_to.window(driver.window_handles[1])
printf(f"fermeture : {driver.current_url}")
@ -236,7 +237,7 @@ def all_cards(): # return to the main page and closes all other tabs
def daily_cards(): # cartes de la premiere partie (renouvelées chaque jours).
try:
# make sure that the daily area is expanded
row_element = driver.find_element(By.XPATH, "/html/body/div/div/div[3]/div[2]/div[1]/div[1]")
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[0]
expanded = row_element.get_attribute("aria-expanded")
if expanded != "true":
row_element.click()
@ -244,9 +245,8 @@ def all_cards(): # return to the main page and closes all other tabs
custom_sleep(uniform(3, 5))
try:
titre = "Placeholder"
driver.find_element(
By.XPATH,f"/html/body/div/div/div[3]/div[2]/div[1]/div[2]/div/div[{i+1}]/a",
).click()
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
elm[i].click()
sleep(1)
titre = driver.title
try_play(titre)
@ -255,7 +255,7 @@ def all_cards(): # return to the main page and closes all other tabs
printf(f"DailyCard {titre} ok")
except Exception as e:
log_error(f"all_cards card {titre} error ({format_error(e)})")
"""
try : # devrait renvoyer vrai si la carte i est faite ou pas, a l'aide su symbole en haut a droite de la carte
elm = 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]/div[1]/div[2]/div")
if not ("correctCircle" in elm.get_attribute("innerHTML")):
@ -266,23 +266,25 @@ def all_cards(): # return to the main page and closes all other tabs
except Exception as e :
printf(format_error(e) + "probablement ok - check card")
# if it fail, it's probably okay -> when all three card are done, the pannel fold
"""
except Exception as e:
log_error(e)
def weekly_cards():
# make sure that the weekly area is expanded
row_element = driver.find_element(By.XPATH, "/html/body/div/div/div[3]/div[2]/div[2]/div[2]")
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
expanded = row_element.get_attribute("aria-expanded")
if expanded != "true":
row_element.click()
for i in range(20): # Should raise an error whene there is no card left
printf("début de l'une des cartes")
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()
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
try :
elm[0].click()
except Exception as e :
print(f"{e} + {driver.current_url}")
break
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
sleep(1)
titre = driver.title
@ -290,13 +292,13 @@ def all_cards(): # return to the main page and closes all other tabs
try_play(titre)
reset(True)
sleep(1)
try:
findall('href="([^<]+)" title=""', driver.page_source)[3] # return error if there is no cards left to do
except:
break
#try:
# findall('href="([^<]+)" title=""', driver.page_source)[3] # return error if there is no cards left to do
#except:
# break
def top_cards():
for _ in range(10):
for _ in range(2):
try :
driver.find_element(By.XPATH, "/html/body/div/div/div[3]/div[1]/div/div[1]/div[2]").click()
reset()
@ -305,17 +307,20 @@ def all_cards(): # return to the main page and closes all other tabs
break
try :
top_cards()
#top_cards()
print("top card not working really well right now. Disableing them")
except Exception as e:
log_error(e)
try:
daily_cards()
print("daily card")
except Exception as e:
log_error(e)
try :
weekly_cards()
print("weekly card")
except Exception as e:
log_error(e)
@ -665,7 +670,6 @@ def fidelity():
fidelity_link = fidelity_link_page.content.decode("UTF-8")
if (fidelity_link.split(":")[0] == "https") or (fidelity_link.split(":")[0] == "http") :
driver.get(fidelity_link)
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
try :
@ -678,9 +682,10 @@ def fidelity():
answer_number = search("([0-9]) de ([0-9]) finalisé", driver.page_source)
if answer_number is None :
answer_number = search("([0-9]) licence\(s\) sur ([0-9]) disponible\(s\)", driver.page_source)
if answer_number is None :
answer_number = search("([0-9])&nbsp;défi\(s\) terminé\(s\) sur ([0-9])", driver.page_source)
if answer_number is None :
answer_number = [0,0,0]
for _ in range(int(answer_number[2]) - int(answer_number[1])):
driver.refresh()
custom_sleep(2)

43
main.py
View File

@ -1,8 +1,11 @@
#/usr/bin/python3.10
from packaging.version import parse as parse_version
import configparser
import os
import shutil
import requests
import sys
config = configparser.ConfigParser()
@ -16,8 +19,6 @@ except :
config.read(config_path)
def confirm(texte, default = False):
if default :
txt = '[Y/n]'
@ -41,12 +42,12 @@ text = {"fr" : {
"next" : "voulez vous ajouter un compte ? ",
"finc" : "comptes en cours d'ajout ",
"ajout" : "comptes ajouté ",
"fidelity" : "avez vous un lien sur lequel le lien vers la page fidelité du mois est le seul contenu de la page ? ",
"fidelity" : "avez vous un lien sur lequel le lien vers la page fidélité du mois est le seul contenu de la page ? ",
"lien" : "entrez le lien ",
"discorde" : "voulez vous envoyer les erreurs sur discord ? ",
"w1" : "entrez le lien du WebHook pour envoyer les points ",
"w2" : "entrez le lien du WebHook pour envoyer les erreurs ",
"msqle" : "voulez vous untiliser une base de donnée ",
"msqle" : "voulez vous utiliser une base de donnée ",
"msqll" : "entrez le lien de la base de donnée ",
"msqlu" : "entrez l'utilisateur de la base de donnée ",
"msqlp" : "entrez le mot de passe de la base de donnée ",
@ -83,8 +84,6 @@ def setup_comptes():
f.write("\n")
f.close()
print(t["ajout"])
#modifie le fichier de configuration
edit_config_txt("logpath",f'{os.getcwd()}/user_data/login.csv')
@ -111,7 +110,7 @@ def setup_settings():
discord()
proxy()
sql()
amazon()
def general():
if confirm(t["fidelity"]):
@ -144,6 +143,7 @@ def sql() :
pwd = input(t["msqlp"])
edit_config_txt("pwd",pwd)
def proxy() :
enabled = confirm(t["proxye"], default = False)
if enabled :
@ -153,13 +153,32 @@ def proxy() :
port = input(t["proxyp"])
edit_config_txt("port",port)
def amazon():
enabled = confirm("claim les recompenses automatiquement sur amazon ?", default = False)
edit_config_txt("claim_amazon",enabled)
def check_update():
try :
latest = requests.get("https://api.github.com/repos/piair338/MsRewards/releases").json()[0]["tag_name"]
latest = parse_version(latest)
except Exception as e :
print(e)
return ()
f = open("./version", 'r')
txt = f.readlines()[0].replace("\n","")
f.close()
cur = parse_version(txt)
if not (cur < latest) :
print("Already up to date.")
else :
print(f"updating to {latest}")
os.system("git reset --hard")
os.system("git pull")
os.system("python3 -m pip install -r requirements.txt > update.result")
print(f"updated to {latest}")
LogPath = config["PATH"]["logpath"]
if LogPath == "/your/path/to/loginandpass.csv" :
setup()
else :
os.system("python3 V5.py")
args = " ".join(sys.argv[1::])
check_update()
os.system("python3 V5.py " + args)

View File

@ -9,3 +9,4 @@ pyvirtualdisplay
pillow
EasyProcess
pyotp
packaging

1
version Normal file
View File

@ -0,0 +1 @@
v5.2.5