Skip to content

Commit

Permalink
Correctly handling login event
Browse files Browse the repository at this point in the history
Need to handle session cookie
  • Loading branch information
tatoalo committed Jan 30, 2021
1 parent 7e89aff commit e137a53
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Personal
keys

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
10 changes: 10 additions & 0 deletions .idea/buddyStream.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 31 additions & 5 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions buddyStream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import time


def init_chrome():
opt_args = Options()
opt_args.add_argument("--no-sandbox")
opt_args.add_argument("--remote-debugging-port=9222")
# opt_args.add_argument("--headless")
opt_args.add_argument("--window-size=1920,1080")
opt_args.add_argument("--disable-gpu")

browser = webdriver.Chrome(options=opt_args)
browser.get("https://app.buddyfit.club/classes/replay/8a1d6bc3-0273-4b66-96f5-326d8ab23bf2/live")

return browser


def extract_keys():
try:
with open("keys") as f:
auth_data = f.read()

auth_info = []

for s in auth_data.splitlines():
if not (s == ''):
auth_info.append(s)

return auth_info[0], auth_info[1]

except FileNotFoundError:
print("*** file doesn't exists, creating 'keys'"
" file, now fill it with data! ... exiting ***")
open("keys", 'w')
return -1


def logged_checker(b):
try:
time.sleep(1)
# b.find_element(By.XPATH, '//button[text()="Entra"]')
login_button = b.find_element_by_xpath("//button[@class='button is-medium is-fullwidth is-rounded is-primary']")
handle_login(b, login_button)

except NoSuchElementException:
print("Login needed but could not find button")


def handle_login(b, button):

e, p = extract_keys()

email = b.find_element_by_xpath("//input[@type='email']")
psw = b.find_element_by_xpath("//input[@type='password']")

email.send_keys(e)
psw.send_keys(p)

button.click()


def main():
b = init_chrome()

logged_checker(b)

if input("Quit?") == "Y":
b.close()
else:
b.close()


if __name__ == "__main__":
main()

0 comments on commit e137a53

Please sign in to comment.