a tester encore un peu, mais devrais marcher
This commit is contained in:
parent
3c5fb6e702
commit
decd289994
53
V4.py
53
V4.py
|
@ -15,12 +15,13 @@ from selenium.webdriver.firefox.options import Options
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.support.ui import Select
|
from selenium.webdriver.support.ui import Select
|
||||||
|
from rich.progress import BarColumn, Progress, TextColumn, Progress, TimeElapsedColumn, TaskProgressColumn, TimeRemainingColumn
|
||||||
|
|
||||||
from modules.db import add_to_database
|
from modules.db import add_to_database
|
||||||
from modules.config import *
|
from modules.config import *
|
||||||
from modules.tools import *
|
from modules.tools import *
|
||||||
from modules.error import *
|
from modules.error import *
|
||||||
|
import modules.progress
|
||||||
global driver
|
global driver
|
||||||
|
|
||||||
|
|
||||||
|
@ -417,6 +418,7 @@ def login():
|
||||||
|
|
||||||
|
|
||||||
def BingPcSearch(override=randint(35, 40)):
|
def BingPcSearch(override=randint(35, 40)):
|
||||||
|
ChangeColor(task["PC"], "blue")
|
||||||
driver.get(f"https://www.bing.com/search?q=test") # {choice(Liste_de_mot)}')
|
driver.get(f"https://www.bing.com/search?q=test") # {choice(Liste_de_mot)}')
|
||||||
CustomSleep(uniform(1, 2))
|
CustomSleep(uniform(1, 2))
|
||||||
RGPD()
|
RGPD()
|
||||||
|
@ -443,7 +445,7 @@ def BingPcSearch(override=randint(35, 40)):
|
||||||
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), mot)
|
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), mot)
|
||||||
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
||||||
|
|
||||||
progressBar(i, override, name="PC")
|
AdvanceTask(task["PC"], 1/override)
|
||||||
CustomSleep(uniform(5, 20))
|
CustomSleep(uniform(5, 20))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -456,7 +458,7 @@ def BingPcSearch(override=randint(35, 40)):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogError(f"BingPcSearch - clear la barre de recherche - {e}", driver, _mail)
|
LogError(f"BingPcSearch - clear la barre de recherche - {e}", driver, _mail)
|
||||||
|
|
||||||
print("\n\n")
|
ChangeColor(task["PC"], "green")
|
||||||
|
|
||||||
|
|
||||||
def unban():
|
def unban():
|
||||||
|
@ -729,6 +731,7 @@ def Alerte():
|
||||||
|
|
||||||
|
|
||||||
def BingMobileSearch(override=randint(22, 25)):
|
def BingMobileSearch(override=randint(22, 25)):
|
||||||
|
ChangeColor(task["Mobile"], "blue")
|
||||||
global MobileDriver
|
global MobileDriver
|
||||||
MobileDriver = "unable to start"
|
MobileDriver = "unable to start"
|
||||||
try:
|
try:
|
||||||
|
@ -737,6 +740,7 @@ def BingMobileSearch(override=randint(22, 25)):
|
||||||
MobileDriver.implicitly_wait(15)
|
MobileDriver.implicitly_wait(15)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile", MobileDriver, _mail)
|
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile", MobileDriver, _mail)
|
||||||
|
ChangeColor(task["Mobile"], "red")
|
||||||
echec = 0
|
echec = 0
|
||||||
|
|
||||||
if not Mlogin(echec):
|
if not Mlogin(echec):
|
||||||
|
@ -750,18 +754,17 @@ def BingMobileSearch(override=randint(22, 25)):
|
||||||
mot = choice(Liste_de_mot)
|
mot = choice(Liste_de_mot)
|
||||||
send_keys_wait(MobileDriver.find_element(By.ID, "sb_form_q"), 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)
|
MobileDriver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
||||||
progressBar(i, override, name="Mobile")
|
AdvanceTask(task["Mobile"], 1/override * 100)
|
||||||
#printf(MobileDriver.current_url)
|
#printf(MobileDriver.current_url)
|
||||||
CustomSleep(uniform(5, 20))
|
CustomSleep(uniform(5, 20))
|
||||||
|
|
||||||
Alerte() # verifie si il y a des alertes (demande de positions ....)
|
Alerte() # verifie si il y a des alertes (demande de positions ....)
|
||||||
|
|
||||||
MobileDriver.find_element(By.ID, "sb_form_q").clear()
|
MobileDriver.find_element(By.ID, "sb_form_q").clear()
|
||||||
except :
|
except :
|
||||||
driver.refresh()
|
driver.refresh()
|
||||||
CustomSleep(30)
|
CustomSleep(30)
|
||||||
i -= 1
|
i -= 1
|
||||||
MobileDriver.quit()
|
MobileDriver.quit()
|
||||||
|
ChangeColor(task["Mobile"], "green")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogError("BingMobileSearch - 4 - " + str(e), MobileDriver, _mail)
|
LogError("BingMobileSearch - 4 - " + str(e), MobileDriver, _mail)
|
||||||
|
@ -769,6 +772,9 @@ def BingMobileSearch(override=randint(22, 25)):
|
||||||
|
|
||||||
|
|
||||||
def DailyRoutine(custom = False):
|
def DailyRoutine(custom = False):
|
||||||
|
for i in ["PC", "Mobile"]:
|
||||||
|
ShowTask(task[i])
|
||||||
|
|
||||||
try :
|
try :
|
||||||
if not custom: # custom already login
|
if not custom: # custom already login
|
||||||
login()
|
login()
|
||||||
|
@ -876,9 +882,8 @@ def SelectAccount(multiple = True):
|
||||||
return([x for x in Credentials if x[0] in emailsSelected])
|
return([x for x in Credentials if x[0] in emailsSelected])
|
||||||
|
|
||||||
|
|
||||||
if CUSTOM_START:
|
def unban2():
|
||||||
CustomStart(Credentials)
|
global _mail, _password
|
||||||
elif UNBAN:
|
|
||||||
_mail, _password = SelectAccount(False)[0]
|
_mail, _password = SelectAccount(False)[0]
|
||||||
try :
|
try :
|
||||||
driver = FirefoxDriver()
|
driver = FirefoxDriver()
|
||||||
|
@ -888,6 +893,36 @@ elif UNBAN:
|
||||||
unban()
|
unban()
|
||||||
except NotBanned :
|
except NotBanned :
|
||||||
printf("you are not cureently banned on this account")
|
printf("you are not cureently banned on this account")
|
||||||
|
|
||||||
|
|
||||||
|
def EnableTask(task):
|
||||||
|
p.start_task(task)
|
||||||
|
|
||||||
|
def ShowTask(task):
|
||||||
|
p.update(task, visible=True)
|
||||||
|
|
||||||
|
def AdvanceTask(task, pourcentage):
|
||||||
|
progress.update(task, advance=pourcentage)
|
||||||
|
|
||||||
|
def ChangeColor(task, newcolor):
|
||||||
|
old = progress.tasks[task].description
|
||||||
|
old = old.split(']')
|
||||||
|
old[0] = f"[{newcolor}"
|
||||||
|
new = "]".join(old)
|
||||||
|
progress.update(task,description=new)
|
||||||
|
|
||||||
|
with Progress(
|
||||||
|
TextColumn("[progress.description]{task.description}"),
|
||||||
|
BarColumn(),
|
||||||
|
TaskProgressColumn(),
|
||||||
|
TimeRemainingColumn(),
|
||||||
|
TimeElapsedColumn(),
|
||||||
|
) as p:
|
||||||
|
task = modules.progress.dico(p)
|
||||||
|
if CUSTOM_START:
|
||||||
|
CustomStart(Credentials)
|
||||||
|
elif UNBAN:
|
||||||
|
unban2()
|
||||||
else:
|
else:
|
||||||
for _mail, _password in Credentials:
|
for _mail, _password in Credentials:
|
||||||
#system("pkill -9 firefox")
|
#system("pkill -9 firefox")
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#add return a string witx tabs
|
||||||
|
def tabs(x):
|
||||||
|
return(x*4*" ")
|
||||||
|
|
||||||
|
|
||||||
|
#create dictionnary with all progress bars
|
||||||
|
def dico(progress):
|
||||||
|
dico_task = {
|
||||||
|
"daily" : {
|
||||||
|
"all" : progress.add_task("[yellow]ligne 1", total=100, start=False),
|
||||||
|
"carte1" : progress.add_task(f"[yellow]{tabs(1)}carte 1", total=100, start=False, visible = False),
|
||||||
|
"carte2" : progress.add_task(f"[yellow]{tabs(1)}carte 2", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 3", total=100, start=False, visible = False)
|
||||||
|
},
|
||||||
|
"weekly" : {
|
||||||
|
"all" : progress.add_task("[yellow]ligne 1", total=100, start=False),
|
||||||
|
"carte1" : progress.add_task(f"[yellow]{tabs(1)}carte 1", total=100, start=False, visible = False),
|
||||||
|
"carte2" : progress.add_task(f"[yellow]{tabs(1)}carte 2", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 3", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 4", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 5", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 6", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 7", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 8", total=100, start=False, visible = False),
|
||||||
|
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 9", total=100, start=False, visible = False),
|
||||||
|
},
|
||||||
|
"PC" : progress.add_task(f"[yellow]PC", total=100, start=False, visible = False),
|
||||||
|
"Mobile" : progress.add_task(f"[yellow]Mobile", total=100, start=False, visible = False),
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return(dico_task)
|
|
@ -3,3 +3,4 @@ argparse
|
||||||
discord.py==1.7.3
|
discord.py==1.7.3
|
||||||
selenium
|
selenium
|
||||||
enquiries
|
enquiries
|
||||||
|
rich
|
Loading…
Reference in New Issue