This commit is contained in:
piair
2023-04-12 18:25:12 +02:00
parent f810f0ee3c
commit b4c9204bf2
5 changed files with 127 additions and 184 deletions

View File

@ -1,6 +1,6 @@
from modules.imports import *
from modules.config import *
import modules.globals as g
def setup_proxy(ip, port, options, socks=False) :
PROXY = f"{ip}:{port}"
@ -25,12 +25,12 @@ def rgpd_popup(driver) -> None:
pass
# save webdriver cookies
def save_cookies(driver, _mail):
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{_mail}.pkl", "wb"))
def save_cookies(driver):
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "wb"))
# load cookies previously saved to the driver
def load_cookies(driver, _mail):
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{_mail}.pkl", "rb"))
def load_cookies(driver):
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "rb"))
for cookie in cookies:
driver.add_cookie(cookie)
@ -52,6 +52,8 @@ def send_keys_wait(element, keys):
def wait_until_visible(search_by: str, identifier: str, timeout = 20, browser = None) -> None:
try :
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((search_by,identifier)), "element not found")
return(True)
except TimeoutException as e:
print(f"element not found after {timeout}s")
return(False)

5
modules/globals.py Normal file
View File

@ -0,0 +1,5 @@
driver = None
_mail = '_mail temp'
_password = '_password temp'
_otp = '_otp temp'
display = None

View File

@ -1,19 +1,23 @@
from modules.imports import *
from modules.config import *
import modules.globals as g
# add the time arround the text given in [text]&
def Timer(text: str, mail: str) -> str:
return(f"[{mail.split('@')[0]} - {datetime.today().strftime('%d/%m')} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
def Timer(text: str) -> str:
return(f"[{g._mail.split('@')[0]} - {datetime.today().strftime('%d/%m')} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
# replace the function print, with more options
# [txt] : string, [driver] : selenium webdriver
def printf2(txt, mail, LOG = LOG):
print(Timer(txt, mail))
def printf(txt):
print(Timer(txt))
# return current page domain
def get_domain(driver):
return(driver.current_url.split("/")[2])
# check if the user is using IPV4 using ipify.org
# [driver] : selenium webdriver
# never used here
@ -26,7 +30,6 @@ def check_ipv4(driver):
return False
def custom_sleep(temps):
try :
if FAST and temps > 50: