0w0
[selenium] zzzscore.com/color/ 솔랑솔랑 본문
728x90
반응형
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
|
#http://zzzscore.com/color/#
import sys, io, time
from selenium import webdriver
from collections import Counter
bs_driver=webdriver.Chrome('C:\Workspace\webdriver\chrome\chromedriver')
bs_driver.get('http://zzzscore.com/color/#')
btns=bs_driver.find_elements_by_xpath("""//*[@id="grid"]/div""")
#print(btns[0])
#print(btns[0].value_of_css_property('background-color'))
def click_color():
#btns_rgba=[btn.value_of_css_property('background-color') for in btns]
btns_rgba=[]
for btn in btns:
btns_rgba.append(btn.value_of_css_property('background-color'))
# for i in btns_rgba:
# print(i)
#Counter함수를 통해 종류별 개수를 확인, 딕셔너리
result=Counter(btns_rgba)
#print(result)
#출력
#Counter({'rgba(255, 0, 0, 1)': 226, 'rgba(34, 212, 209, 1)': 3, 'rgba(1, 179, 176, 1)': 1})
#딕셔너리의 items()함수를 사용해 key와 value를 구분
for key,value in result.items():
if value==1:
answer=key
break
index=btns_rgba.index(answer)
#print(index)
btns[index].click()
#main
start_time=time.time()
while time.time()-start_time<=60:
click_color()
|
cs |
728x90
반응형
'Coding > Python' 카테고리의 다른 글
[urllib] 파라미터 데이터 가져오기, API data 및 RSS 가져오기 (0) | 2019.08.15 |
---|---|
[selenium] zzzscore.com/color/ 2 솔랑솔랑 (0) | 2019.08.14 |
[selenium] zzzscore.com/1to50/ 솔랑솔랑 (0) | 2019.08.13 |
[selenium] selenium 참조, 자주사용되는 메소드 및 API (0) | 2019.08.10 |
[selenium] CLI, GUI (백그라운드, 포그라운드) (0) | 2019.08.10 |
Comments