-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
58 lines (50 loc) · 1.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from secrets import (
DRIVER_PATH,
OUTPUT_PATH,
WEBSITE_URL,
IDENTIFICATION,
PASSWORD,
HEADQUARTER_NAME,
DESIRED_DATE,
DESIRED_TIME,
WHATSAPP_URL,
CHAT_NAME,
PERSON_NAME,
CHROME_PROFILE_PATH
)
from smartfit_booking.website_bot import (
initialize,
login_to_website,
search_headquarter,
book_hour,
get_qr_code,
logout_from_website,
login_to_whatsapp,
search_chat,
send_message
)
from smartfit_booking.storage import (
save_file,
remove_file
)
from smartfit_booking.data_access_api import get_data
import os
def main():
""" book_an_hour """
driver = initialize(DRIVER_PATH, OUTPUT_PATH, CHROME_PROFILE_PATH)
login_to_website(driver, WEBSITE_URL, IDENTIFICATION, PASSWORD)
search_headquarter(driver, HEADQUARTER_NAME)
book_hour(driver, DESIRED_DATE, DESIRED_TIME)
qr_code_url = get_qr_code(driver)
logout_from_website(driver)
""" download_qr_code """
response = get_data(qr_code_url)
image_path = os.path.join(OUTPUT_PATH, 'code.jpg')
save_file(image_path, response)
""" send_whatsapp_message """
login_to_whatsapp(driver, WHATSAPP_URL)
search_chat(driver, CHAT_NAME)
send_message(driver, image_path, PERSON_NAME, DESIRED_DATE, DESIRED_TIME)
remove_file(image_path)
if __name__ == '__main__':
main()