small fix

This commit is contained in:
piair 2023-04-17 22:00:46 +02:00
parent 3b82419d4d
commit 6f325c5a6a
3 changed files with 38 additions and 32 deletions

42
V5.py
View File

@ -5,6 +5,7 @@ from modules.db import add_to_database
from modules.tools import *
from modules.error import *
from modules.driver_tools import *
from modules.cards import *
import modules.globals as g
@ -12,10 +13,6 @@ driver = g.driver
display = g.display
# TODO
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg:
# create a webdriver
def firefox_driver(mobile=False, headless=False):
PC_USER_AGENT = (
@ -221,6 +218,8 @@ def all_cards():
printf("no promo card")
for i in range(len(liste)):
if(len(liste) < 20):
log_error("moins de 20 cartes", driver)
printf(f"carte {i}")
try :
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
@ -228,6 +227,11 @@ def all_cards():
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
printf(f"staled, {len(liste)}")
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except IndexError:
log_error("IndexError ?", driver)
driver.refresh()
custom_sleep(10)
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
if checked:
custom_sleep(3)
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
@ -249,38 +253,13 @@ def all_cards():
pass
else :
try :
welcome_tour(liste[i])
welcome_tour(liste[i], driver)
except Exception as e:
print(format_error(e))
log_error("no new windows", driver)
custom_sleep(3)
def welcome_tour(elm):
try :
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
except :
pass
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
elm.click()
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
elm.click()
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
def spotify():
custom_sleep(5)
driver.find_element(By.CSS_SELECTOR, '[data-bi-id="spotify-premium gratuit"]').click()
custom_sleep(5)
close_tab(driver.window_handles[1])
def promo():
elm = driver.find_element(By.ID, "promo-item")
for i in range(10):
@ -296,12 +275,13 @@ def promo():
close_tab(driver.window_handles[1])
else :
try :
spotify()
spotify(driver)
except :
log_error("no new windows", driver)
driver.get("https://rewards.bing.com")
custom_sleep(3)
# Find out which type of action to do
def try_play(nom="inconnu"):
def play(number):

26
modules/cards.py Normal file
View File

@ -0,0 +1,26 @@
from modules.imports import *
def welcome_tour(elm, driver):
try :
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
except :
pass
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
elm.click()
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
elm.click()
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
def spotify(driver):
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[data-bi-id="spotify-premium gratuit"]').click()
sleep(5)
close_tab(driver.window_handles[1])

View File

@ -1 +1 @@
v5.9.2
v5.9.3