forked from mementocoder/ClassCardMacro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacro.py
173 lines (134 loc) · 5.67 KB
/
Macro.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
from selenium import webdriver
import time
import sys
options = webdriver.ChromeOptions()
options.add_argument("start-maximized");
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
if getattr(sys, 'frozen', False):
chromedriver_path = os.path.join(sys._MEIPASS, "chromedriver.exe")
driver = webdriver.Chrome(chromedriver_path, chrome_options = options)
else:
driver = webdriver.Chrome(chrome_options = options)
#해당 url로 이동
url = "https://www.classcard.net/Login"
driver.get(url)
driver.implicitly_wait(5)
#아이디
id_input_xpath = '//*[@id="login_id"]'
driver.find_element_by_xpath(id_input_xpath).send_keys('아이디')
driver.implicitly_wait(5)
#비밀번호
password_input_xpath = '//*[@id="login_pwd"]'
driver.find_element_by_xpath(password_input_xpath).send_keys('비밀번호')
driver.implicitly_wait(5)
#로그인 버튼
login_btn_xpath = '//*[@id="loginForm"]/div[2]/button'
driver.find_element_by_xpath(login_btn_xpath).click()
driver.implicitly_wait(5)
#세트 클릭
level1_btn_xpath = '/html/body/div[1]/div[2]/div/div/div[2]/div[2]/div[2]/div[1]/div[8]/div[1]/div[2]/div/a'
driver.find_element_by_xpath(level1_btn_xpath).click()
driver.implicitly_wait(5)
#매칭 버튼 클릭
btn_box_study_xpath = '/html/body/div[1]/div[2]/div/div[1]/div[2]/div/div[3]'
driver.find_element_by_xpath(btn_box_study_xpath).click()
driver.implicitly_wait(5)
#매칭 시작 버튼 클릭
start_btn_xpath = '//*[@id="newRankModal"]/div[2]/div/div/div[1]/div[4]/a[1]'
driver.find_element_by_xpath(start_btn_xpath).click()
driver.implicitly_wait(5)
def match():
while 1:
try:
left_card_0_xpath = '//*[@id="left_card_0"]'
left_card_1_xpath = '//*[@id="left_card_1"]'
left_card_2_xpath = '//*[@id="left_card_2"]'
left_card_3_xpath = '//*[@id="left_card_3"]'
left_card_0 = driver.find_element_by_xpath(left_card_0_xpath)
left_card_1 = driver.find_element_by_xpath(left_card_1_xpath)
left_card_2 = driver.find_element_by_xpath(left_card_2_xpath)
left_card_3 = driver.find_element_by_xpath(left_card_3_xpath)
left_card_0_idx = left_card_0.get_attribute('data-idx')
left_card_1_idx = left_card_1.get_attribute('data-idx')
left_card_2_idx = left_card_2.get_attribute('data-idx')
left_card_3_idx = left_card_3.get_attribute('data-idx')
right_card_0_xpath = '//*[@id="right_card_0"]'
right_card_1_xpath = '//*[@id="right_card_1"]'
right_card_2_xpath = '//*[@id="right_card_2"]'
right_card_3_xpath = '//*[@id="right_card_3"]'
right_card_0 = driver.find_element_by_xpath(right_card_0_xpath)
right_card_1 = driver.find_element_by_xpath(right_card_1_xpath)
right_card_2 = driver.find_element_by_xpath(right_card_2_xpath)
right_card_3 = driver.find_element_by_xpath(right_card_3_xpath)
right_card_0_idx = right_card_0.get_attribute('data-idx')
right_card_1_idx = right_card_1.get_attribute('data-idx')
right_card_2_idx = right_card_2.get_attribute('data-idx')
right_card_3_idx = right_card_3.get_attribute('data-idx')
if left_card_0_idx == right_card_0_idx:
left_card_0.click()
right_card_0.click()
continue
elif left_card_0_idx == right_card_1_idx:
left_card_0.click()
right_card_1.click()
continue
elif left_card_0_idx == right_card_2_idx:
left_card_0.click()
right_card_2.click()
continue
elif left_card_0_idx == right_card_3_idx:
left_card_0.click()
right_card_3.click()
continue
elif left_card_1_idx == right_card_0_idx:
left_card_1.click()
right_card_0.click()
continue
elif left_card_1_idx == right_card_1_idx:
left_card_1.click()
right_card_1.click()
continue
elif left_card_1_idx == right_card_2_idx:
left_card_1.click()
right_card_2.click()
continue
elif left_card_1_idx == right_card_3_idx:
left_card_1.click()
right_card_3.click()
continue
elif left_card_2_idx == right_card_0_idx:
left_card_2.click()
right_card_0.click()
continue
elif left_card_2_idx == right_card_1_idx:
left_card_2.click()
right_card_1.click()
continue
elif left_card_2_idx == right_card_2_idx:
left_card_2.click()
right_card_2.click()
continue
elif left_card_2_idx == right_card_3_idx:
left_card_2.click()
right_card_3.click()
continue
elif left_card_3_idx == right_card_0_idx:
left_card_3.click()
right_card_0.click()
continue
elif left_card_3_idx == right_card_1_idx:
left_card_3.click()
right_card_1.click()
continue
elif left_card_3_idx == right_card_2_idx:
left_card_3.click()
right_card_2.click()
continue
elif left_card_3_idx == right_card_3_idx:
left_card_3.click()
right_card_3.click()
continue
except:
continue
match()