small fix
This commit is contained in:
parent
3b82419d4d
commit
6f325c5a6a
42
V5.py
42
V5.py
|
@ -5,6 +5,7 @@ from modules.db import add_to_database
|
||||||
from modules.tools import *
|
from modules.tools import *
|
||||||
from modules.error import *
|
from modules.error import *
|
||||||
from modules.driver_tools import *
|
from modules.driver_tools import *
|
||||||
|
from modules.cards import *
|
||||||
import modules.globals as g
|
import modules.globals as g
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,10 +13,6 @@ driver = g.driver
|
||||||
display = g.display
|
display = g.display
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
|
||||||
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg:
|
|
||||||
|
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
def firefox_driver(mobile=False, headless=False):
|
def firefox_driver(mobile=False, headless=False):
|
||||||
PC_USER_AGENT = (
|
PC_USER_AGENT = (
|
||||||
|
@ -221,6 +218,8 @@ def all_cards():
|
||||||
printf("no promo card")
|
printf("no promo card")
|
||||||
|
|
||||||
for i in range(len(liste)):
|
for i in range(len(liste)):
|
||||||
|
if(len(liste) < 20):
|
||||||
|
log_error("moins de 20 cartes", driver)
|
||||||
printf(f"carte {i}")
|
printf(f"carte {i}")
|
||||||
try :
|
try :
|
||||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
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")
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||||
printf(f"staled, {len(liste)}")
|
printf(f"staled, {len(liste)}")
|
||||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
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:
|
if checked:
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
||||||
|
@ -249,38 +253,13 @@ def all_cards():
|
||||||
pass
|
pass
|
||||||
else :
|
else :
|
||||||
try :
|
try :
|
||||||
welcome_tour(liste[i])
|
welcome_tour(liste[i], driver)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(format_error(e))
|
print(format_error(e))
|
||||||
log_error("no new windows", driver)
|
log_error("no new windows", driver)
|
||||||
custom_sleep(3)
|
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():
|
def promo():
|
||||||
elm = driver.find_element(By.ID, "promo-item")
|
elm = driver.find_element(By.ID, "promo-item")
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
@ -296,12 +275,13 @@ def promo():
|
||||||
close_tab(driver.window_handles[1])
|
close_tab(driver.window_handles[1])
|
||||||
else :
|
else :
|
||||||
try :
|
try :
|
||||||
spotify()
|
spotify(driver)
|
||||||
except :
|
except :
|
||||||
log_error("no new windows", driver)
|
log_error("no new windows", driver)
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
|
|
||||||
# Find out which type of action to do
|
# Find out which type of action to do
|
||||||
def try_play(nom="inconnu"):
|
def try_play(nom="inconnu"):
|
||||||
def play(number):
|
def play(number):
|
||||||
|
|
|
@ -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])
|
Loading…
Reference in New Issue