posting_duo 0.0.69 → 0.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/posting_duo.rb +1227 -761
  3. metadata +2 -2
data/lib/posting_duo.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'glimmer-dsl-libui'
2
2
  require 'selenium-webdriver'
3
- # require 'webdrivers'
3
+ require 'webdrivers'
4
4
  require 'iconv'
5
5
  require 'nokogiri'
6
6
  require 'open-uri'
@@ -27,42 +27,71 @@ using Rainbow
27
27
 
28
28
 
29
29
  class Naver
30
-
31
- def chrome_start(proxy)
30
+ def initialize
31
+
32
+ begin
33
+ # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
34
+
35
+ # Webdrivers가 드라이버를 다운로드할 경로를 설정
36
+ Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
37
+ Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
38
+ # 크롬드라이버 자동 업데이트 시도
39
+ Webdrivers::Chromedriver.update
40
+ puts "chromedriver 자동 다운로드 성공"
41
+ rescue => e
42
+ puts "chromedriver 자동 다운로드 실패: #{e.message}"
43
+ puts "폴더내 크롬드라이버를 사용합니다."
44
+ puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
45
+ puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
46
+ chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
47
+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
48
+ end
49
+
50
+ end
51
+
52
+
53
+ def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
54
+ board_cookie_dir = "C:/board_cookie"
55
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
56
+
57
+ if proxy == ''
58
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --window-position=0,0 --remote-debugging-port=9222 --user-data-dir=C:/board_cookie --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
59
+ else
60
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --window-position=0,0 --remote-debugging-port=9222 --user-data-dir=C:/board_cookie --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
61
+ end
62
+ end
63
+
64
+
65
+
66
+ def chrome_start(proxy, board_cookie_dir = "C:/board_cookie")
67
+ board_cookie_dir = "C:/board_cookie"
68
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
32
69
  if proxy == ''
33
70
  begin
34
-
35
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
36
71
  options = Selenium::WebDriver::Chrome::Options.new
37
- options.add_extension('./crx/free.crx')
38
- options.add_extension('./crx/app.crx')
72
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
73
+ #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
74
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
75
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
76
+ options.add_argument('--no-default-browser-check')
39
77
  options.page_load_strategy = :normal
40
- options.timeouts = { page_load: 20_000 }
78
+ options.timeouts = {page_load: 30_000}
79
+ options.page_load_strategy = 'none'
80
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
41
81
  options.add_argument('--disable-gpu')
42
- options.add_argument('--start-maximized')
43
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
44
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
45
- options.add_argument('--disable-web-security') # 보안 비활성화
46
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
47
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
48
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
49
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
50
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
51
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
52
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
53
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
54
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
55
- options.add_argument("--disable-logging")
56
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
57
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
58
-
82
+ options.add_argument('--remote-debugging-port=9222')
83
+ options.add_argument('user-data-dir=C:/board_cookie')
84
+
85
+ options.add_argument('--disable-save-password-bubble') # 비밀번호 저장 팝업 비활성화
86
+ options.add_argument('--disable-password-manager') # 비밀번호 관리 비활성화
87
+
88
+
59
89
  # 'capabilities'과 'options' 배열로 설정
60
90
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
61
91
  capabilities["goog:chromeOptions"] = options.as_json
62
92
 
63
93
  # Selenium 4에서는 'capabilities'만 사용하는 방식
64
94
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
65
-
66
95
 
67
96
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
68
97
 
@@ -71,35 +100,23 @@ class Naver
71
100
  end
72
101
  else
73
102
  begin
74
- puts '프록시 연결합니다.......'.magenta
75
- puts '프록시 연결시 프록시 서버에 의해 인터넷속도가 낮아질수있어.......'.magenta
76
- puts '원활한 작업이 되지않을수있습니다.......'.magenta
77
103
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
78
104
  options = Selenium::WebDriver::Chrome::Options.new
105
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
106
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
107
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
108
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
109
+ options.add_argument('--no-default-browser-check')
79
110
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
80
- options.add_extension('./crx/free.crx')
81
- options.add_extension('./crx/app.crx')
82
111
  options.page_load_strategy = :normal
83
- options.timeouts = { page_load: 20_000 }
112
+ options.timeouts = {page_load: 30_000}
113
+ options.page_load_strategy = 'none'
114
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
84
115
  options.add_argument('--disable-gpu')
85
- options.add_argument('--start-maximized')
86
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
87
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
88
- options.add_argument('--disable-web-security') # 웹 보안 비활성화
89
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
90
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
91
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
92
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
93
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
94
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
95
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
96
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
97
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
98
- options.add_argument("--disable-logging")
99
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
100
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
101
-
102
-
116
+ options.add_argument('--remote-debugging-port=9222')
117
+ options.add_argument('user-data-dir=C:/board_cookie')
118
+
119
+
103
120
  # 'capabilities'과 'options' 배열로 설정
104
121
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
105
122
  capabilities["goog:chromeOptions"] = options.as_json
@@ -108,35 +125,27 @@ class Naver
108
125
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
109
126
 
110
127
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
111
-
112
128
  rescue => e
113
129
  puts e
114
130
  puts 'proxy error...'
115
131
  begin
116
132
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
117
133
  options = Selenium::WebDriver::Chrome::Options.new
118
- options.add_extension('./crx/free.crx')
119
- options.add_extension('./crx/app.crx')
134
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
135
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
136
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
137
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
138
+ options.add_argument('--no-default-browser-check')
120
139
  options.page_load_strategy = :normal
121
- options.timeouts = { page_load: 20_000 }
140
+ options.timeouts = {page_load: 30_000}
141
+ options.page_load_strategy = 'none'
142
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
122
143
  options.add_argument('--disable-gpu')
123
- options.add_argument('--start-maximized')
124
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
125
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
126
- options.add_argument('--disable-web-security') # 웹 보안 비활성화
127
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
128
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
129
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
130
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
131
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
132
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
133
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
134
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
135
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
136
- options.add_argument("--disable-logging")
137
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
138
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
139
-
144
+ options.add_argument('--remote-debugging-port=9222')
145
+ options.add_argument('user-data-dir=C:/board_cookie')
146
+
147
+
148
+
140
149
  # 'capabilities'과 'options' 배열로 설정
141
150
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
142
151
  capabilities["goog:chromeOptions"] = options.as_json
@@ -151,51 +160,394 @@ class Naver
151
160
  end
152
161
  end
153
162
  end
154
-
155
-
156
- def login(proxy)
157
- chrome_start(proxy)
158
163
 
159
- @driver.get('about:blank')
160
- sleep(2)
164
+ def login(proxy, captcha_key, board_cookie_dir = "C:/board_cookie")
165
+ @captcha_key = captcha_key
166
+ @board_cookie_dir = "C:/board_cookie"
167
+ current_dir = File.dirname(__FILE__)
168
+ board_cookie_dir = "C:/board_cookie"
169
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
170
+
171
+ unless File.exist?(board_cookie_dir)
172
+ driverfile_src = File.join(current_dir, 'driverfile')
173
+ if Dir.exist?(driverfile_src)
174
+ FileUtils.cp_r(driverfile_src, board_cookie_dir)
175
+ end
176
+ end
177
+
178
+ # 새로운 스레드 생성 및 실행
179
+ Thread.new { chrome_setup(proxy, board_cookie_dir) }
180
+
181
+ # 충분한 대기 시간을 두고 실행
182
+ sleep(1)
161
183
 
184
+ chrome_start(proxy, board_cookie_dir)
185
+
162
186
  # 열린 모든 탭 핸들 확인
163
187
  all_windows = @driver.window_handles
164
- puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
165
-
166
- # 탭만 남기고 나머지 탭 닫기
188
+ #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
189
+
190
+ # 원하는 URL
191
+ target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
192
+
193
+ # 각 탭을 순회하면서
167
194
  all_windows.each do |window|
168
- @driver.switch_to.window(window)
169
- current_url = @driver.current_url
170
- puts "탭 URL: #{current_url}" # 각 탭 URL 출력
171
-
172
- # 'chrome-extension://'로 시작하는 확장 프로그램 탭을 제외하고 닫기
173
- if current_url.start_with?('chrome-extension://')
174
- puts "확장 프로그램 탭을 닫지 않음: #{current_url}"
175
- else
176
- @driver.close # 등 다른 탭은 닫기
177
- puts " 또는 확장 프로그램이 아닌 탭을 닫았습니다."
178
- end
195
+ @driver.switch_to.window(window)
196
+ current_url = @driver.current_url
197
+ #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
198
+
199
+ # 원하는 URL이 아니면 탭을 닫기
200
+ if current_url != target_url
201
+ begin
202
+ @driver.close # 다른 탭을 닫기
203
+ rescue Selenium::WebDriver::Error::WebDriverError => e
204
+ #puts "탭을 닫는 오류 발생: #{e.message}"
205
+ end
179
206
  end
180
-
181
- # 빈 탭을 남긴 후, 빈 탭으로 다시 전환
207
+ end
208
+
209
+ # 남아 있는 탭으로 전환
182
210
  all_windows = @driver.window_handles # 남은 탭 리스트 갱신
183
- if all_windows.size == 1
184
- @driver.switch_to.window(all_windows.first) # 남은 탭으로 전환
185
- puts "빈 탭으로 전환됨."
211
+ if all_windows.size > 0
212
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
186
213
  else
187
- puts " 탭을 찾을 수 없습니다."
214
+ #puts "남은 탭이 없습니다."
188
215
  end
189
-
190
- sleep(1)
191
-
192
- # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
193
- @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
216
+
217
+
218
+
219
+ @driver.manage.window.maximize
194
220
  sleep(1)
195
- end
196
-
197
-
198
-
221
+ begin
222
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
223
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
224
+ check_cookie_login = 1
225
+ puts'[Step.01] CAPTCHA 세션 및 브라우저 설정 완료 상태 확인!!.......'.yellow
226
+ rescue
227
+ begin
228
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
229
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
230
+ sleep(1.5)
231
+ @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
232
+ puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.yellow
233
+ puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.yellow
234
+ sleep(1.5)
235
+ mouse_move_percentage(0.3,0.02)
236
+ sleep(0.5)
237
+ left_click
238
+ sleep(1)
239
+ key_stroke('tab')
240
+ sleep(0.5)
241
+ key_stroke('enter')
242
+ check_cookie_login = 0
243
+ sleep(1)
244
+ rescue
245
+ @driver.quit
246
+ return 0
247
+ end
248
+ end
249
+
250
+ if check_cookie_login == 0
251
+ sleep(10)
252
+ begin
253
+
254
+ begin
255
+ # 열린 모든 탭 핸들 확인
256
+ all_windows = @driver.window_handles
257
+ puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
258
+
259
+ # 각 탭을 순회하면서
260
+ all_windows.each do |window|
261
+ @driver.switch_to.window(window)
262
+ current_url = @driver.current_url
263
+ puts "탭 URL: #{current_url}" # 각 탭 URL 출력
264
+
265
+ # 확장 프로그램 탭인지 확인
266
+ if current_url.include?('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
267
+ begin
268
+ @driver.close # 확장 프로그램 탭을 닫기
269
+
270
+ rescue Selenium::WebDriver::Error::WebDriverError => e
271
+ end
272
+ else
273
+ end
274
+ end
275
+
276
+ # 남아 있는 탭으로 전환
277
+ all_windows = @driver.window_handles # 남은 탭 리스트 갱신
278
+ if all_windows.size > 0
279
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
280
+ else
281
+ end
282
+
283
+ sleep(1)
284
+
285
+ rescue => e
286
+ @driver.quit if @driver
287
+ end
288
+
289
+
290
+
291
+
292
+
293
+ # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
294
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
295
+ sleep(1)
296
+
297
+
298
+
299
+
300
+
301
+ begin
302
+ puts '-[√] 캡챠 연결 설정 1차 시도.......'.green
303
+ # 요소 찾기 타임아웃을 10초로 설정
304
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
305
+ #요소가 나타날 때까지 60초 동안 기다립니다.
306
+ wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
307
+ @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
308
+ sleep(1)
309
+ Clipboard.copy(captcha_key)
310
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
311
+ sleep(1)
312
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
313
+ sleep(1)
314
+
315
+ begin
316
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
317
+ wait.until do
318
+ begin
319
+ alert = @driver.switch_to.alert
320
+ alert.accept
321
+ sleep(1)
322
+ true
323
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
324
+ false
325
+ end
326
+ end
327
+ rescue Selenium::WebDriver::Error::TimeoutError
328
+ puts "alert이 없으므로 버튼 클릭"
329
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
330
+ begin
331
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
332
+ wait.until do
333
+ begin
334
+ alert = @driver.switch_to.alert
335
+ alert.accept
336
+ sleep(1)
337
+ true
338
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
339
+ false
340
+ end
341
+ end
342
+ puts "두 번째 alert 처리 완료"
343
+ rescue Selenium::WebDriver::Error::TimeoutError
344
+ puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
345
+ system('taskkill /F /IM chrome.exe')
346
+ @driver.quit if @driver
347
+ end
348
+ end
349
+ puts '-[√] 브라우저 필요 설정 1차 시도.......'.green
350
+ @driver.get('chrome://settings/security')
351
+ sleep(2)
352
+ mouse_move_percentage(0.3,0.02)
353
+ sleep(0.5)
354
+ left_click
355
+ sleep(1)
356
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
357
+ 6.times do
358
+ key_stroke('tab') # 'tab' 키를 입력
359
+ sleep(0.5) # 0.5초 대기
360
+ end
361
+ key_stroke('enter')
362
+ sleep(1)
363
+
364
+ @driver.get('chrome://password-manager/settings')
365
+ sleep(2)
366
+ mouse_move_percentage(0.3,0.02)
367
+ sleep(0.5)
368
+ left_click
369
+ sleep(1)
370
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
371
+ 3.times do
372
+ key_stroke('tab') # 'tab' 키를 입력
373
+ sleep(0.5) # 0.5초 대기
374
+ end
375
+ key_stroke('enter')
376
+ sleep(1)
377
+
378
+ rescue
379
+ begin
380
+ puts '-[√] 캡챠 연결 설정 2차 시도.......'.green
381
+ sleep(1)
382
+ #@driver.switch_to.window(@driver.window_handles[0])
383
+
384
+
385
+ # 요소 찾기 타임아웃을 10초로 설정
386
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
387
+ #요소가 나타날 때까지 60초 동안 기다립니다.
388
+ wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
389
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
390
+ sleep(1)
391
+ begin
392
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
393
+ rescue
394
+
395
+ puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
396
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
397
+
398
+ end
399
+
400
+ Clipboard.copy(captcha_key)
401
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
402
+ sleep(1)
403
+ begin
404
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
405
+ sleep(1)
406
+
407
+ begin
408
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
409
+ wait.until do
410
+ begin
411
+ alert = @driver.switch_to.alert
412
+ alert.accept
413
+ sleep(1)
414
+ true
415
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
416
+ false
417
+ end
418
+ end
419
+ rescue Selenium::WebDriver::Error::TimeoutError
420
+ puts "alert이 없으므로 버튼 클릭"
421
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
422
+ begin
423
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
424
+ wait.until do
425
+ begin
426
+ alert = @driver.switch_to.alert
427
+ alert.accept
428
+ sleep(1)
429
+ true
430
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
431
+ false
432
+ end
433
+ end
434
+ puts "두 번째 alert 처리 완료"
435
+ rescue Selenium::WebDriver::Error::TimeoutError
436
+ puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
437
+ system('taskkill /F /IM chrome.exe')
438
+ @driver.quit if @driver
439
+ end
440
+ end
441
+
442
+ rescue => e
443
+ @driver.window_handles.each do |handle|
444
+ @driver.switch_to.window(handle)
445
+ begin
446
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
447
+ @driver.close
448
+ rescue Selenium::WebDriver::Error::WebDriverError => e
449
+ puts "크롬 브라우저 종료: #{e.message}"
450
+ end
451
+ end
452
+ return 0
453
+ @driver.quit
454
+ end
455
+ puts '-[√] 브라우저 필요 설정 2차 시도.......'.green
456
+ @driver.get('chrome://settings/security')
457
+ sleep(2)
458
+ mouse_move_percentage(0.3,0.02)
459
+ sleep(0.5)
460
+ left_click
461
+ sleep(1)
462
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
463
+ 6.times do
464
+ key_stroke('tab') # 'tab' 키를 입력
465
+ sleep(0.5) # 0.5초 대기
466
+ end
467
+ key_stroke('enter')
468
+ sleep(1)
469
+
470
+ @driver.get('chrome://password-manager/settings')
471
+ sleep(2)
472
+ mouse_move_percentage(0.3,0.02)
473
+ sleep(0.5)
474
+ left_click
475
+ sleep(1)
476
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
477
+ 3.times do
478
+ key_stroke('tab') # 'tab' 키를 입력
479
+ sleep(0.5) # 0.5초 대기
480
+ end
481
+ key_stroke('enter')
482
+ sleep(1)
483
+
484
+ rescue => e
485
+ puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
486
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
487
+ @driver.window_handles.each do |handle|
488
+ @driver.switch_to.window(handle)
489
+ begin
490
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
491
+ @driver.close
492
+ rescue Selenium::WebDriver::Error::WebDriverError => e
493
+ puts "크롬 브라우저 종료: #{e.message}"
494
+ end
495
+ end
496
+ return 0
497
+ @driver.quit
498
+ end
499
+
500
+ end
501
+
502
+ rescue => e
503
+ puts '-[√] 로딩 지연 접속 실패.......'.red
504
+ @driver.window_handles.each do |handle|
505
+ @driver.switch_to.window(handle)
506
+ begin
507
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
508
+ @driver.close
509
+ rescue Selenium::WebDriver::Error::WebDriverError => e
510
+ puts "Failed to close tab: #{e.message}"
511
+ end
512
+ end
513
+ @driver.quit
514
+ return 0
515
+ end
516
+
517
+ else
518
+ # @driver.switch_to.default_content
519
+ end
520
+
521
+ begin
522
+
523
+
524
+
525
+ @driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
526
+
527
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
528
+ #요소가 나타날 때까지 3초 동안 기다립니다.
529
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
530
+
531
+
532
+
533
+ rescue => e
534
+ puts '-[√] 로그인 실패.......'.red
535
+ @driver.window_handles.each do |handle|
536
+ @driver.switch_to.window(handle)
537
+ begin
538
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
539
+ @driver.close
540
+ rescue Selenium::WebDriver::Error::WebDriverError => e
541
+ puts "Failed to close tab: #{e.message}"
542
+ end
543
+ end
544
+ @driver.quit
545
+ return 0
546
+ end
547
+ end
548
+
549
+
550
+
199
551
 
200
552
 
201
553
  def update(user_id, user_pw, title, content, option, post_url, signup_url, login_url, cc_check_url, image_url_cheng, img_link2, category, more_txt1, more_txt2, more_txt3, more_txt4, captcha_key, keyword)
@@ -218,210 +570,81 @@ def update(user_id, user_pw, title, content, option, post_url, signup_url, login
218
570
 
219
571
 
220
572
  ####################탭나누기 수정중######################################
221
- begin
222
- puts '-[√] 투 캡챠 api 입력 시도 1.......'.green
223
-
224
- #@driver.switch_to.window(@driver.window_handles[0])
225
-
226
573
 
227
- # 요소 찾기 타임아웃을 10초로 설정
228
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
229
- #요소가 나타날 때까지 60초 동안 기다립니다.
230
- wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
231
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
232
- sleep(1)
233
- Clipboard.copy(captcha_key)
234
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
235
- sleep(1)
236
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
237
- sleep(1)
238
-
239
- begin
240
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
241
- wait.until do
242
- begin
243
- alert = @driver.switch_to.alert
244
- alert.accept
245
- true
246
- rescue Selenium::WebDriver::Error::NoSuchAlertError
247
- false
248
- end
249
- end
250
- rescue Selenium::WebDriver::Error::TimeoutError
251
- puts "alert이 없으므로 버튼 클릭"
252
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
253
- begin
254
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
255
- wait.until do
256
- begin
257
- alert = @driver.switch_to.alert
258
- alert.accept
259
- true
260
- rescue Selenium::WebDriver::Error::NoSuchAlertError
261
- false
262
- end
263
- end
264
- puts "두 번째 alert 처리 완료"
265
- rescue Selenium::WebDriver::Error::TimeoutError
266
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
267
- system('taskkill /F /IM chrome.exe')
268
- @driver.quit if @driver
269
- end
270
- end
271
-
272
574
 
273
- rescue
274
- begin
275
- puts '-[√] 투 캡챠 api 입력 시도 2.......'.green
276
- sleep(1)
277
- #@driver.switch_to.window(@driver.window_handles[0])
575
+
576
+ signup_url = option['signup_url'].to_s
278
577
 
279
578
 
280
- # 요소 찾기 타임아웃을 10초로 설정
281
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
282
- #요소가 나타날 때까지 60초 동안 기다립니다.
283
- wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
284
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
285
- sleep(1)
286
- begin
287
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
288
- rescue
289
-
290
- puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
291
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
292
-
293
- end
294
579
 
295
- Clipboard.copy(captcha_key)
296
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
297
- sleep(1)
298
- begin
299
- @driver.find_element(:class_name, 'default-btn').click
300
- sleep(1)
301
580
 
581
+ begin
582
+ if signup_url == '' or signup_url == '회원가입 페이지 url'
583
+
584
+ else
585
+ @driver.get(signup_url)
586
+ puts '-[√] 회원가입 페이지 URL 이동.......'.magenta
587
+
588
+
589
+
590
+
591
+
302
592
  begin
303
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
304
- wait.until do
305
- begin
306
- alert = @driver.switch_to.alert
307
- alert.accept
308
- true
309
- rescue Selenium::WebDriver::Error::NoSuchAlertError
310
- false
311
- end
593
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
594
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
595
+ if error_text
596
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
597
+ @driver.quit if @driver
598
+ return 0
312
599
  end
313
- rescue Selenium::WebDriver::Error::TimeoutError
314
- puts "alert이 없으므로 버튼 클릭"
315
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
316
- begin
317
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
318
- wait.until do
319
- begin
320
- alert = @driver.switch_to.alert
321
- alert.accept
322
- true
323
- rescue Selenium::WebDriver::Error::NoSuchAlertError
324
- false
325
- end
326
- end
327
- puts "두 번째 alert 처리 완료"
328
- rescue Selenium::WebDriver::Error::TimeoutError
329
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
330
- system('taskkill /F /IM chrome.exe')
331
- @driver.quit if @driver
332
- end
600
+ rescue
333
601
  end
334
-
335
- rescue => e
336
- @driver.window_handles.each do |handle|
337
- @driver.switch_to.window(handle)
338
- begin
339
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
340
- @driver.close
341
- rescue Selenium::WebDriver::Error::WebDriverError => e
342
- puts "크롬 브라우저 종료: #{e.message}"
343
- end
344
- end
345
- return 0
346
- @driver.quit
347
- end
348
602
 
349
- rescue => e
350
- puts '-[√] 로딩 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
351
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
352
- @driver.window_handles.each do |handle|
353
- @driver.switch_to.window(handle)
354
- begin
355
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
356
- @driver.close
357
- rescue Selenium::WebDriver::Error::WebDriverError => e
358
- puts "크롬 브라우저 종료: #{e.message}"
603
+ begin
604
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 없음" 텍스트를 찾습니다.
605
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
606
+ if error_text
607
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
608
+ @driver.quit if @driver
609
+ return 0
359
610
  end
611
+ rescue
360
612
  end
361
- return 0
362
- @driver.quit
363
- end
364
-
365
- end
366
- #@driver.switch_to.window(@driver.window_handles[0])
367
- ####################탭나누기 수정중######################################
368
- sleep(2)
369
-
370
613
 
614
+ begin
615
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
616
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
617
+ alert.accept # 알림을 확인
618
+ rescue
619
+ end
371
620
 
372
- ##################
373
- signup_url = option['signup_url'].to_s
374
-
621
+
622
+ sleep(1)
623
+
624
+
625
+
375
626
 
376
627
 
377
628
 
378
- begin
379
- if signup_url == '' or signup_url == '회원가입 페이지 url'
380
629
 
381
- else
382
-
630
+ #오른쪽 마우스 해제 코드
383
631
  begin
384
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
385
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
386
- @driver.get(signup_url)
387
- sleep(1)
388
- puts '-[√] 회원가입 페이지 URL 이동.......'.magenta
389
-
390
- # Alert 처리 부분
391
- begin
392
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
393
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
394
- alert.accept # 알림을 확인
395
- rescue
396
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
397
- end
398
-
399
-
400
- rescue Selenium::WebDriver::Error::UnknownError => e
401
- puts "#{signup_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
402
- # 열린 모든 창을 닫음
403
- @driver.window_handles.each do |handle|
404
- @driver.switch_to.window(handle)
405
- begin
406
- @driver.close
407
- rescue Selenium::WebDriver::Error::WebDriverError => e
408
- puts "사이트 내부에 예외 발생: #{e.message}"
409
- end
410
- end
411
-
412
- # 드라이버 종료
413
- @driver.quit if @driver
414
- return 0
415
-
416
- rescue Selenium::WebDriver::Error::TimeoutError => e
417
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
418
- @driver.quit if @driver
419
- return 0
420
-
421
- rescue
422
- end
423
-
424
-
632
+ @driver.execute_script <<-JS
633
+ document.querySelectorAll('body').forEach(function(element) {
634
+ element.oncontextmenu = null;
635
+ });
636
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
637
+ JS
638
+
639
+ @driver.execute_script <<-JS
640
+ document.addEventListener('contextmenu', function(e) {
641
+ e.stopImmediatePropagation();
642
+ }, true);
643
+ JS
644
+
645
+ @driver.execute_script("window.oncontextmenu = null;")
646
+ rescue
647
+ end
425
648
 
426
649
 
427
650
 
@@ -435,6 +658,8 @@ sleep(2)
435
658
  puts '-[√] 3 캡챠 발생 유무 확인.......'.green
436
659
  sleep(2)
437
660
 
661
+
662
+
438
663
  begin
439
664
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
440
665
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -610,9 +835,22 @@ sleep(2)
610
835
  begin
611
836
  sleep(1)
612
837
  @driver.switch_to.alert.accept
838
+ sleep(1)
613
839
  rescue
614
840
  end
615
841
 
842
+ begin
843
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
844
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
845
+ if error_text
846
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
847
+ @driver.quit if @driver
848
+ return 0
849
+ end
850
+ rescue Selenium::WebDriver::Error::NoSuchElementError
851
+ # 해당 텍스트가 없으면 아무 작업 안함
852
+ end
853
+
616
854
 
617
855
  ##체크박스1-1 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
618
856
  puts '-[√] 회원가입 체크박스 1차 탐색.......'.yellow
@@ -1468,15 +1706,28 @@ sleep(2)
1468
1706
 
1469
1707
 
1470
1708
 
1471
-
1472
-
1473
-
1474
-
1475
1709
 
1476
1710
 
1477
1711
  sleep(1)
1478
1712
  ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
1479
-
1713
+ #오른쪽 마우스 해제 코드
1714
+ begin
1715
+ @driver.execute_script <<-JS
1716
+ document.querySelectorAll('body').forEach(function(element) {
1717
+ element.oncontextmenu = null;
1718
+ });
1719
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
1720
+ JS
1721
+
1722
+ @driver.execute_script <<-JS
1723
+ document.addEventListener('contextmenu', function(e) {
1724
+ e.stopImmediatePropagation();
1725
+ }, true);
1726
+ JS
1727
+
1728
+ @driver.execute_script("window.oncontextmenu = null;")
1729
+ rescue
1730
+ end
1480
1731
  sleep(1)
1481
1732
  ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
1482
1733
  puts '-[√] 캡챠 유형 탐색.......'.green
@@ -1575,12 +1826,7 @@ rescue
1575
1826
  rescue
1576
1827
  begin
1577
1828
  @driver.switch_to.default_content()
1578
- @driver.find_elements(:tag_name, 'img').each do |img|
1579
- if img.attribute('src').include?('kboard_captcha')
1580
- el = img # 캡챠 이미지를 el에 저장
1581
- break # 첫 번째 이미지를 찾으면 루프 종료
1582
- end
1583
- end
1829
+ el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
1584
1830
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
1585
1831
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
1586
1832
  puts '-[√] 챕챠 코드 code 5-1.......'.red
@@ -1597,11 +1843,13 @@ rescue
1597
1843
  @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
1598
1844
  sleep(1)
1599
1845
  puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
1846
+
1847
+
1600
1848
  rescue
1601
1849
  begin
1602
1850
  @driver.switch_to.default_content()
1603
1851
  #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
1604
- el = @driver.find_element(:css, 'label[for="kboard-input-captcha"] img')
1852
+ el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
1605
1853
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
1606
1854
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
1607
1855
  puts '-[√] 챕챠 코드 code 5-2.......'.red
@@ -2444,6 +2692,7 @@ end
2444
2692
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
2445
2693
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2446
2694
  alert.accept # 알림을 확인
2695
+ sleep(1)
2447
2696
  rescue
2448
2697
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
2449
2698
  end
@@ -2465,58 +2714,69 @@ login_url = option['login_url'].to_s
2465
2714
  if login_url == '' or login_url == '로그인 페이지 url'
2466
2715
 
2467
2716
  else
2468
-
2717
+ @driver.get(login_url)
2718
+ puts '-[√] 로그인 페이지 URL 이동.......'.magenta
2719
+
2720
+
2721
+
2722
+
2723
+
2469
2724
  begin
2470
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
2471
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
2472
- @driver.get(login_url)
2473
- sleep(1)
2474
- puts '-[√] 로그인 페이지 URL 이동.......'.magenta
2475
- # Alert 처리 부분
2476
- begin
2477
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
2478
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2479
- alert.accept # 알림을 확인
2480
- rescue
2481
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
2482
- end
2483
-
2484
- rescue Selenium::WebDriver::Error::UnknownError => e
2485
- puts "#{login_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
2486
- # 열린 모든 창을 닫음
2487
- @driver.window_handles.each do |handle|
2488
- @driver.switch_to.window(handle)
2489
- begin
2490
- @driver.close
2491
- rescue Selenium::WebDriver::Error::WebDriverError => e
2492
- puts "사이트 내부에 예외 발생: #{e.message}"
2493
- end
2494
- end
2495
-
2496
- # 드라이버 종료
2725
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
2726
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
2727
+ if error_text
2728
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
2497
2729
  @driver.quit if @driver
2498
- return 0
2499
-
2500
- rescue Selenium::WebDriver::Error::TimeoutError => e
2501
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
2730
+ return 0
2731
+ end
2732
+ rescue
2733
+ end
2734
+
2735
+ begin
2736
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
2737
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
2738
+ if error_text
2739
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
2502
2740
  @driver.quit if @driver
2503
2741
  return 0
2504
-
2505
- rescue
2506
2742
  end
2507
-
2508
-
2509
-
2510
- sleep(1)
2743
+ rescue
2744
+ end
2745
+
2746
+ begin
2747
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
2748
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2749
+ alert.accept # 알림을 확인
2750
+ rescue
2751
+ end
2752
+
2753
+
2754
+
2755
+ sleep(1)
2756
+
2511
2757
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
2758
+ #오른쪽 마우스 해제 코드
2759
+ begin
2760
+ @driver.execute_script <<-JS
2761
+ document.querySelectorAll('body').forEach(function(element) {
2762
+ element.oncontextmenu = null;
2763
+ });
2764
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
2765
+ JS
2512
2766
 
2513
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
2514
- sleep(1)
2515
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
2516
- sleep(1)
2517
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
2518
- sleep(1)
2519
-
2767
+ @driver.execute_script <<-JS
2768
+ document.addEventListener('contextmenu', function(e) {
2769
+ e.stopImmediatePropagation();
2770
+ }, true);
2771
+ JS
2772
+
2773
+ @driver.execute_script("window.oncontextmenu = null;")
2774
+ rescue
2775
+ end
2776
+
2777
+ sleep(5)
2778
+
2779
+
2520
2780
  begin
2521
2781
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
2522
2782
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -2612,7 +2872,7 @@ login_url = option['login_url'].to_s
2612
2872
  rescue
2613
2873
  begin
2614
2874
  # 타임아웃을 3초로 설정
2615
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
2875
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2)
2616
2876
  # 요소가 나타날 때까지 30초 동안 기다립니다.
2617
2877
  wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
2618
2878
  sleep(1)
@@ -2700,7 +2960,7 @@ login_url = option['login_url'].to_s
2700
2960
 
2701
2961
 
2702
2962
  begin
2703
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2963
+
2704
2964
  chat_box = @driver.find_element(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')
2705
2965
  @driver.execute_script("arguments[0].remove();", chat_box)
2706
2966
  puts '-[√] 숨김 code 1 제거 완료.......'.green
@@ -2709,7 +2969,7 @@ login_url = option['login_url'].to_s
2709
2969
  end
2710
2970
 
2711
2971
  begin
2712
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2972
+
2713
2973
  chat_box = @driver.find_element(:xpath, '//*[@class="google-auto-placed"]')
2714
2974
  @driver.execute_script("arguments[0].remove();", chat_box)
2715
2975
  puts '-[√] 숨김 code 2 제거 완료.......'.green
@@ -2718,7 +2978,7 @@ login_url = option['login_url'].to_s
2718
2978
  end
2719
2979
 
2720
2980
  begin
2721
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2981
+
2722
2982
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[1]
2723
2983
  @driver.execute_script("arguments[0].remove();", chat_box)
2724
2984
  puts '-[√] 숨김 code 3 제거 완료.......'.green
@@ -2727,7 +2987,7 @@ login_url = option['login_url'].to_s
2727
2987
  end
2728
2988
 
2729
2989
  begin
2730
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2990
+
2731
2991
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[2]
2732
2992
  @driver.execute_script("arguments[0].remove();", chat_box)
2733
2993
  puts '-[√] 숨김 code 4 제거 완료.......'.green
@@ -2736,7 +2996,7 @@ login_url = option['login_url'].to_s
2736
2996
  end
2737
2997
 
2738
2998
  begin
2739
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2999
+
2740
3000
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[3]
2741
3001
  @driver.execute_script("arguments[0].remove();", chat_box)
2742
3002
  puts '-[√] 숨김 code 5 제거 완료.......'.green
@@ -2757,12 +3017,10 @@ login_url = option['login_url'].to_s
2757
3017
  rescue
2758
3018
  end
2759
3019
 
2760
-
2761
-
2762
3020
 
2763
3021
 
2764
3022
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2765
- puts '-[√] 팝업 여부 확인 체크 01.......'.yellow
3023
+
2766
3024
 
2767
3025
  begin
2768
3026
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -2844,7 +3102,7 @@ login_url = option['login_url'].to_s
2844
3102
  @driver.find_element(:xpath, '//*[@id="hd_pops_1"]/div[2]/button[1]').click
2845
3103
  sleep(1)
2846
3104
  rescue
2847
- puts '.......'.yellow
3105
+
2848
3106
 
2849
3107
  end
2850
3108
 
@@ -2874,7 +3132,7 @@ login_url = option['login_url'].to_s
2874
3132
 
2875
3133
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
2876
3134
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2877
- puts '-[√] 팝업 여부 확인 체크 02.......'.yellow
3135
+
2878
3136
 
2879
3137
  begin
2880
3138
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -2956,7 +3214,7 @@ login_url = option['login_url'].to_s
2956
3214
  @driver.find_element(:xpath, '//*[@id="hd_pops_2"]/div[2]/button[1]').click
2957
3215
  sleep(1)
2958
3216
  rescue
2959
- puts '.......'.yellow
3217
+
2960
3218
 
2961
3219
  end
2962
3220
 
@@ -2986,7 +3244,7 @@ login_url = option['login_url'].to_s
2986
3244
  end
2987
3245
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
2988
3246
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2989
- puts '-[√] 팝업 여부 확인 체크 03.......'.yellow
3247
+
2990
3248
 
2991
3249
  begin
2992
3250
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3068,7 +3326,7 @@ login_url = option['login_url'].to_s
3068
3326
  @driver.find_element(:xpath, '//*[@id="hd_pops_3"]/div[2]/button[1]').click
3069
3327
  sleep(1)
3070
3328
  rescue
3071
- puts '.......'.yellow
3329
+
3072
3330
 
3073
3331
  end
3074
3332
 
@@ -3098,7 +3356,7 @@ login_url = option['login_url'].to_s
3098
3356
  end
3099
3357
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3100
3358
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
3101
- puts '-[√] 팝업 여부 확인 체크 04.......'.yellow
3359
+
3102
3360
 
3103
3361
  begin
3104
3362
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3180,7 +3438,7 @@ login_url = option['login_url'].to_s
3180
3438
  @driver.find_element(:xpath, '//*[@id="hd_pops_4"]/div[2]/button[1]').click
3181
3439
  sleep(1)
3182
3440
  rescue
3183
- puts '.......'.yellow
3441
+
3184
3442
 
3185
3443
  end
3186
3444
 
@@ -3210,7 +3468,7 @@ login_url = option['login_url'].to_s
3210
3468
  end
3211
3469
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3212
3470
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
3213
- puts '-[√] 팝업 여부 확인 체크 05.......'.yellow
3471
+
3214
3472
 
3215
3473
  begin
3216
3474
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3292,7 +3550,7 @@ login_url = option['login_url'].to_s
3292
3550
  @driver.find_element(:xpath, '//*[@id="hd_pops_5"]/div[2]/button[1]').click
3293
3551
  sleep(1)
3294
3552
  rescue
3295
- puts '.......'.yellow
3553
+
3296
3554
 
3297
3555
  end
3298
3556
 
@@ -3322,10 +3580,20 @@ login_url = option['login_url'].to_s
3322
3580
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3323
3581
 
3324
3582
 
3325
-
3583
+ begin
3584
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3585
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
3586
+ if error_text
3587
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
3588
+ @driver.quit if @driver
3589
+ return 0
3590
+ end
3591
+ rescue Selenium::WebDriver::Error::NoSuchElementError
3592
+ # 해당 텍스트가 없으면 아무 작업 안함
3593
+ end
3326
3594
 
3327
3595
  ##아이디 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3328
- puts '-[√] 로그인 ID/PW 입력 필드 탐색.......'.cyan
3596
+
3329
3597
  sleep(1)
3330
3598
  begin
3331
3599
  @driver.find_element(:xpath, '//*[@name="mb_id"]').send_keys(user_id)
@@ -3422,20 +3690,7 @@ login_url = option['login_url'].to_s
3422
3690
  begin
3423
3691
  @driver.find_element(:xpath, '//*[@class="username"]').send_keys(user_id)
3424
3692
  sleep(3)
3425
- rescue => e
3426
- puts '-[√] 로그인 페이지 접속 시도 실패 (페이지 로딩 지연 및 접속 불량).......'.red
3427
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
3428
- @driver.window_handles.each do |handle|
3429
- @driver.switch_to.window(handle)
3430
- begin
3431
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
3432
- @driver.close
3433
- rescue Selenium::WebDriver::Error::WebDriverError => e
3434
- puts "크롬 브라우저 종료: #{e.message}"
3435
- end
3436
- end
3437
- return 0
3438
- @driver.quit
3693
+ rescue
3439
3694
  end
3440
3695
 
3441
3696
  end
@@ -3556,7 +3811,7 @@ login_url = option['login_url'].to_s
3556
3811
  end
3557
3812
  end
3558
3813
  end
3559
- puts '-[√] 로그인 ID/PW 입력 필드 종료.......'.cyan
3814
+
3560
3815
  sleep(1)
3561
3816
  end
3562
3817
  ##패스워드 입력 코드 부분─────────────────────────────────────────────────────────────────────<
@@ -3595,47 +3850,53 @@ login_url = option['login_url'].to_s
3595
3850
  sleep(3)
3596
3851
  rescue
3597
3852
  begin
3598
- @driver.find_element(:xpath, '//*[@alt="로그인"]').click
3853
+ @driver.find_element(:xpath, '//*[@class="btn btn-color pull-right"]').click
3599
3854
  puts '-[√] 로그인 버튼 코드 7 타겟.......'.cyan
3600
3855
  sleep(3)
3601
3856
  rescue
3602
3857
  begin
3603
- @driver.find_element(:xpath, '//*[@id="mb_login"]/form/div[5]/button').click
3858
+ @driver.find_element(:xpath, '//*[@alt="로그인"]').click
3604
3859
  puts '-[√] 로그인 버튼 코드 8 타겟.......'.cyan
3605
3860
  sleep(3)
3606
3861
  rescue
3607
3862
  begin
3608
- @driver.find_element(:xpath, '//*[@id="ol_submit"]').click
3863
+ @driver.find_element(:xpath, '//*[@id="mb_login"]/form/div[5]/button').click
3609
3864
  puts '-[√] 로그인 버튼 코드 9 타겟.......'.cyan
3610
3865
  sleep(3)
3611
3866
  rescue
3612
3867
  begin
3613
- @driver.find_element(:xpath, '//*[@alt="login"]').click
3868
+ @driver.find_element(:xpath, '//*[@id="ol_submit"]').click
3614
3869
  puts '-[√] 로그인 버튼 코드 10 타겟.......'.cyan
3615
3870
  sleep(3)
3616
3871
  rescue
3617
3872
  begin
3618
- @driver.find_element(:xpath, '//*[@title="login"]').click
3873
+ @driver.find_element(:xpath, '//*[@alt="login"]').click
3619
3874
  puts '-[√] 로그인 버튼 코드 11 타겟.......'.cyan
3620
3875
  sleep(3)
3621
3876
  rescue
3622
3877
  begin
3623
- @driver.find_element(:xpath, '//*[@id="signIn_1"]').click
3878
+ @driver.find_element(:xpath, '//*[@title="login"]').click
3624
3879
  puts '-[√] 로그인 버튼 코드 12 타겟.......'.cyan
3625
3880
  sleep(3)
3626
3881
  rescue
3627
3882
  begin
3628
- @driver.find_element(:xpath, '//*[@id="btn_login"]').click
3883
+ @driver.find_element(:xpath, '//*[@id="signIn_1"]').click
3629
3884
  puts '-[√] 로그인 버튼 코드 13 타겟.......'.cyan
3630
3885
  sleep(3)
3631
3886
  rescue
3632
3887
  begin
3633
- @driver.find_element(:xpath, '//*[@name="wp-submit"]').click
3888
+ @driver.find_element(:xpath, '//*[@id="btn_login"]').click
3634
3889
  puts '-[√] 로그인 버튼 코드 14 타겟.......'.cyan
3635
3890
  sleep(3)
3636
3891
  rescue
3637
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
3638
- sleep(3)
3892
+ begin
3893
+ @driver.find_element(:xpath, '//*[@name="wp-submit"]').click
3894
+ puts '-[√] 로그인 버튼 코드 15 타겟.......'.cyan
3895
+ sleep(3)
3896
+ rescue
3897
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
3898
+ sleep(3)
3899
+ end
3639
3900
  end
3640
3901
  end
3641
3902
  end
@@ -3652,11 +3913,14 @@ login_url = option['login_url'].to_s
3652
3913
  end
3653
3914
  ##로그인 버튼 코드 부분─────────────────────────────────────────────────────────────────────<
3654
3915
 
3916
+
3917
+
3655
3918
  # Alert 처리 부분
3656
3919
  begin
3657
3920
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3658
3921
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3659
3922
  alert.accept # 알림을 확인
3923
+ sleep(1)
3660
3924
  rescue
3661
3925
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
3662
3926
  end
@@ -3667,7 +3931,7 @@ login_url = option['login_url'].to_s
3667
3931
 
3668
3932
 
3669
3933
  rescue => e
3670
- puts '-[√] 로그인 PASS.......'.cyan
3934
+ #puts '-[√] 로그인 PASS.......'.cyan
3671
3935
  puts e
3672
3936
  end
3673
3937
 
@@ -3685,57 +3949,68 @@ begin
3685
3949
 
3686
3950
  else
3687
3951
 
3952
+ @driver.get(cc_check_url)
3953
+ puts '-[√] 출석 체크 페이지 URL 이동.......'.magenta
3954
+
3955
+
3956
+
3957
+
3958
+
3688
3959
  begin
3689
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3690
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
3691
- @driver.get(cc_check_url)
3692
- sleep(1)
3693
- puts '-[√] 출석체크 페이지 URL 이동.......'.magenta
3694
- # Alert 처리 부분
3695
- begin
3696
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3697
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3698
- alert.accept # 알림을 확인
3699
- rescue
3700
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
3701
- end
3702
-
3703
- rescue Selenium::WebDriver::Error::UnknownError => e
3704
- puts "#{cc_check_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
3705
- # 열린 모든 창을 닫음
3706
- @driver.window_handles.each do |handle|
3707
- @driver.switch_to.window(handle)
3708
- begin
3709
- @driver.close
3710
- rescue Selenium::WebDriver::Error::WebDriverError => e
3711
- puts "사이트 내부에 예외 발생: #{e.message}"
3712
- end
3713
- end
3714
-
3715
- # 드라이버 종료
3960
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3961
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
3962
+ if error_text
3963
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3716
3964
  @driver.quit if @driver
3717
- return 0
3718
-
3719
- rescue Selenium::WebDriver::Error::TimeoutError => e
3720
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
3965
+ return 0
3966
+ end
3967
+ rescue
3968
+ end
3969
+
3970
+ begin
3971
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3972
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
3973
+ if error_text
3974
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3721
3975
  @driver.quit if @driver
3722
3976
  return 0
3723
-
3724
- rescue
3725
3977
  end
3978
+ rescue
3979
+ end
3726
3980
 
3727
-
3981
+ begin
3982
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
3983
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3984
+ alert.accept # 알림을 확인
3985
+ rescue
3986
+ end
3728
3987
 
3988
+
3729
3989
 
3730
3990
  sleep(1)
3991
+ #오른쪽 마우스 해제 코드
3992
+ begin
3993
+ @driver.execute_script <<-JS
3994
+ document.querySelectorAll('body').forEach(function(element) {
3995
+ element.oncontextmenu = null;
3996
+ });
3997
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
3998
+ JS
3999
+
4000
+ @driver.execute_script <<-JS
4001
+ document.addEventListener('contextmenu', function(e) {
4002
+ e.stopImmediatePropagation();
4003
+ }, true);
4004
+ JS
4005
+
4006
+ @driver.execute_script("window.oncontextmenu = null;")
4007
+ rescue
4008
+ end
3731
4009
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3732
4010
  begin
3733
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
3734
- sleep(1)
3735
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
3736
- sleep(1)
3737
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
3738
- sleep(1)
4011
+ sleep(5)
4012
+
4013
+
3739
4014
  # 타임아웃을 3초로 설정
3740
4015
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
3741
4016
  # 요소가 나타날 때까지 30초 동안 기다립니다.
@@ -3774,7 +4049,7 @@ begin
3774
4049
  end
3775
4050
  ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
3776
4051
 
3777
- begin
4052
+ begin
3778
4053
  # 요소 찾기 타임아웃을 10초로 설정
3779
4054
  wait = Selenium::WebDriver::Wait.new(:timeout => 20)
3780
4055
  #요소가 나타날 때까지 20초 동안 기다립니다.
@@ -3799,6 +4074,19 @@ begin
3799
4074
  end
3800
4075
  end
3801
4076
 
4077
+ begin
4078
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4079
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4080
+ if error_text
4081
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
4082
+ @driver.quit if @driver
4083
+ return 0
4084
+ end
4085
+ rescue Selenium::WebDriver::Error::NoSuchElementError
4086
+ # 해당 텍스트가 없으면 아무 작업 안함
4087
+ end
4088
+
4089
+
3802
4090
  ##출석 체크 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3803
4091
  cctxt_value = ['ㅊㅊ','출석체크','출석 체크해요','출첵~','추추','출석~','출석 체크 하고 가요','출석 체크 합니다.','안녕하세요','출첵왔어요','출석체크합니다.','출석체크~','출석했어요','출첵!!','출석 체크~,','출석 도장 쾅~!','출석 도장 쾅쾅!!','출석 하고 가요','출첵^^*','출석 체크~!^^','^^','^*^','출첵*_*','추추^^*'].sample
3804
4092
  begin
@@ -3909,6 +4197,7 @@ begin
3909
4197
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3910
4198
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3911
4199
  alert.accept # 알림을 확인
4200
+ sleep(1)
3912
4201
  rescue
3913
4202
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
3914
4203
  end
@@ -3925,71 +4214,67 @@ end
3925
4214
 
3926
4215
 
3927
4216
 
3928
- login_url = option['login_url'].to_s
4217
+ post_url = option['post_url'].to_s
3929
4218
 
3930
4219
  begin
3931
4220
  if post_url == '' or post_url == '게시판 글쓰기 url'
3932
4221
 
3933
4222
  else
3934
-
4223
+ @driver.get(post_url)
4224
+ puts '-[√] 게시판 페이지 URL 이동.......'.magenta
4225
+
4226
+
4227
+
4228
+
4229
+
3935
4230
  begin
3936
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3937
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
3938
- @driver.get(post_url)
3939
- sleep(1)
3940
- puts '-[√] 글쓰기 페이지 URL 이동.......'.magenta
3941
- # Alert 처리 부분
3942
- begin
3943
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3944
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3945
- alert.accept # 알림을 확인
3946
- rescue
3947
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
3948
- end
3949
-
3950
- rescue Selenium::WebDriver::Error::UnknownError => e
3951
- puts "#{post_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
3952
- # 열린 모든 창을 닫음
3953
- @driver.window_handles.each do |handle|
3954
- @driver.switch_to.window(handle)
3955
- begin
3956
- @driver.close
3957
- rescue Selenium::WebDriver::Error::WebDriverError => e
3958
- puts "사이트 내부에 예외 발생: #{e.message}"
3959
- end
3960
- end
3961
-
3962
- # 드라이버 종료
3963
- @driver.quit if @driver
3964
- return 0
3965
-
3966
- rescue Selenium::WebDriver::Error::TimeoutError => e
3967
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
4231
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4232
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4233
+ if error_text
4234
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3968
4235
  @driver.quit if @driver
3969
4236
  return 0
3970
-
3971
- rescue
3972
4237
  end
4238
+ rescue
4239
+ end
3973
4240
 
4241
+ begin
4242
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4243
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
4244
+ if error_text
4245
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
4246
+ @driver.quit if @driver
4247
+ return 0
4248
+ end
4249
+ rescue
4250
+ end
3974
4251
 
4252
+ begin
4253
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
4254
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
4255
+ alert.accept # 알림을 확인
4256
+ rescue
4257
+ end
3975
4258
 
3976
-
4259
+
3977
4260
  sleep(1)
4261
+
4262
+
3978
4263
  begin
3979
- puts '-[√] 글쓰기 버튼 클릭이 필수인지 탐색합니다.......'.green
4264
+
3980
4265
  el_post_btn = @driver.find_element(:xpath, '//*[@class="btn btn-primary btn-sm float_r"]')
3981
4266
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3982
4267
  sleep(1)
3983
4268
  @driver.find_element(:xpath, '//*[@class="btn btn-primary btn-sm float_r"]').click
3984
4269
  sleep(3.7)
3985
- puts '-[√] 글쓰기 버튼 code 1.......'.green
4270
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 1 타겟.......'.green
3986
4271
  rescue
3987
4272
  begin
3988
4273
  el_post_btn = @driver.find_element(:xpath, '//*[@class="btn-block-right"]')
3989
4274
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3990
4275
  sleep(1)
3991
4276
  @driver.find_element(:xpath, '//*[@class="btn-block-right"]').click
3992
- puts '-[√] 글쓰기 버튼 code 2.......'.green
4277
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 2 타겟.......'.green
3993
4278
  sleep(3.7)
3994
4279
  rescue
3995
4280
  begin
@@ -3997,7 +4282,7 @@ login_url = option['login_url'].to_s
3997
4282
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3998
4283
  sleep(1)
3999
4284
  @driver.find_element(:xpath, '//*[@class="write_btn"]').click
4000
- puts '-[√] 글쓰기 버튼 code 3.......'.green
4285
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 3 타겟.......'.green
4001
4286
  sleep(3.7)
4002
4287
  rescue
4003
4288
  begin
@@ -4005,7 +4290,7 @@ login_url = option['login_url'].to_s
4005
4290
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
4006
4291
  sleep(1)
4007
4292
  @driver.find_element(:xpath, '//*[@class="gRight"]').click
4008
- puts '-[√] 글쓰기 버튼 code 4.......'.green
4293
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 4 타겟.......'.green
4009
4294
  sleep(3.7)
4010
4295
  rescue
4011
4296
 
@@ -4013,18 +4298,33 @@ login_url = option['login_url'].to_s
4013
4298
  end
4014
4299
  end
4015
4300
  end
4016
-
4301
+
4017
4302
  sleep(1)
4303
+ #오른쪽 마우스 해제 코드
4304
+ begin
4305
+ @driver.execute_script <<-JS
4306
+ document.querySelectorAll('body').forEach(function(element) {
4307
+ element.oncontextmenu = null;
4308
+ });
4309
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
4310
+ JS
4018
4311
 
4019
- ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4312
+ @driver.execute_script <<-JS
4313
+ document.addEventListener('contextmenu', function(e) {
4314
+ e.stopImmediatePropagation();
4315
+ }, true);
4316
+ JS
4317
+
4318
+ @driver.execute_script("window.oncontextmenu = null;")
4319
+ rescue
4320
+ end
4321
+
4322
+ ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4020
4323
 
4021
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
4022
- sleep(1)
4023
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
4024
- sleep(1)
4025
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
4026
- sleep(1)
4027
4324
 
4325
+ sleep(5)
4326
+
4327
+
4028
4328
  begin
4029
4329
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
4030
4330
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -4162,7 +4462,7 @@ login_url = option['login_url'].to_s
4162
4462
  end
4163
4463
  end
4164
4464
  rescue
4165
- puts '-[√] 캡챠 발생 없음.......'.green
4465
+
4166
4466
  end
4167
4467
  end
4168
4468
  end
@@ -4201,6 +4501,7 @@ login_url = option['login_url'].to_s
4201
4501
  rescue => e
4202
4502
  begin
4203
4503
  @driver.switch_to.alert.accept
4504
+ sleep(1)
4204
4505
  rescue
4205
4506
  end
4206
4507
  puts '-[√] 글쓰기 페이지 접속 시도 실패 (페이지 로딩 지연 및 접속 불량).......'.red
@@ -4216,7 +4517,20 @@ login_url = option['login_url'].to_s
4216
4517
  sleep(2)
4217
4518
  rescue
4218
4519
  end
4219
-
4520
+
4521
+ begin
4522
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4523
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4524
+ if error_text
4525
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
4526
+ @driver.quit if @driver
4527
+ return 0
4528
+ end
4529
+ rescue Selenium::WebDriver::Error::NoSuchElementError
4530
+ # 해당 텍스트가 없으면 아무 작업 안함
4531
+ end
4532
+
4533
+
4220
4534
 
4221
4535
  begin
4222
4536
  chat_box = @driver.find_element(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')
@@ -4350,69 +4664,82 @@ login_url = option['login_url'].to_s
4350
4664
  rescue
4351
4665
  end
4352
4666
 
4353
-
4354
4667
  end
4355
4668
 
4356
4669
 
4357
4670
 
4358
4671
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4359
- puts '-[√] 팝업 여부 확인 체크 01.......'.yellow
4672
+
4360
4673
 
4361
4674
  begin
4362
4675
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4363
4676
  sleep(1)
4677
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4364
4678
  rescue
4365
4679
  begin
4366
4680
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4367
4681
  sleep(1)
4682
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4368
4683
  rescue
4369
4684
  begin
4370
4685
  @driver.find_element(:xpath, '//*[@class="close"]').click
4371
4686
  sleep(1)
4687
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4372
4688
  rescue
4373
4689
  begin
4374
4690
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4375
4691
  sleep(1)
4692
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4376
4693
  rescue
4377
4694
  begin
4378
4695
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4379
4696
  sleep(1)
4697
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4380
4698
  rescue
4381
4699
  begin
4382
4700
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4383
4701
  sleep(1)
4702
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4384
4703
  rescue
4385
4704
  begin
4386
4705
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4387
4706
  sleep(1)
4707
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4388
4708
  rescue
4389
4709
  begin
4390
4710
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4391
4711
  sleep(1)
4712
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4392
4713
  rescue
4393
4714
  begin
4394
4715
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4395
4716
  sleep(1)
4717
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4396
4718
  rescue
4397
4719
  begin
4398
4720
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4399
4721
  sleep(1)
4722
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4400
4723
  rescue
4401
4724
  begin
4402
4725
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4403
4726
  sleep(1)
4727
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4404
4728
  rescue
4405
4729
  begin
4406
4730
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4407
4731
  sleep(1)
4732
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4408
4733
  rescue
4409
4734
  begin
4410
4735
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4411
4736
  sleep(1)
4737
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4412
4738
  rescue
4413
4739
  begin
4414
4740
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4415
4741
  sleep(1)
4742
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4416
4743
  rescue
4417
4744
  begin
4418
4745
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4421,29 +4748,35 @@ login_url = option['login_url'].to_s
4421
4748
  sleep(1)
4422
4749
  @driver.switch_to.default_content()
4423
4750
  sleep(1)
4751
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4424
4752
  rescue
4425
4753
  begin
4426
4754
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4427
4755
  sleep(1)
4756
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4428
4757
  rescue
4429
4758
  begin
4430
4759
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4431
4760
  sleep(1)
4761
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4432
4762
  rescue
4433
4763
  begin
4434
4764
  @driver.find_element(:xpath, '//*[@id="banner"]/div[1]/div/div[1]').click
4435
4765
  sleep(1)
4766
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4436
4767
  rescue
4437
4768
 
4438
4769
  begin
4439
4770
  @driver.find_element(:xpath, '//*[@id="hd_pops_1"]/div[2]/button[1]').click
4440
4771
  sleep(1)
4772
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4441
4773
  rescue
4442
4774
  begin
4443
4775
  @driver.find_element(:xpath, '//*[@class="modal_close"]').click
4444
4776
  sleep(1)
4777
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4445
4778
  rescue
4446
- puts '.......'.yellow
4779
+
4447
4780
 
4448
4781
  end
4449
4782
 
@@ -4474,63 +4807,77 @@ login_url = option['login_url'].to_s
4474
4807
 
4475
4808
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4476
4809
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4477
- puts '-[√] 팝업 여부 확인 체크 02.......'.yellow
4810
+
4478
4811
 
4479
4812
  begin
4480
4813
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4481
4814
  sleep(1)
4815
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4482
4816
  rescue
4483
4817
  begin
4484
4818
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4485
4819
  sleep(1)
4820
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4486
4821
  rescue
4487
4822
  begin
4488
4823
  @driver.find_element(:xpath, '//*[@class="close"]').click
4489
4824
  sleep(1)
4825
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4490
4826
  rescue
4491
4827
  begin
4492
4828
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4493
4829
  sleep(1)
4830
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4494
4831
  rescue
4495
4832
  begin
4496
4833
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4497
4834
  sleep(1)
4835
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4498
4836
  rescue
4499
4837
  begin
4500
4838
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4501
4839
  sleep(1)
4840
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4502
4841
  rescue
4503
4842
  begin
4504
4843
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4505
4844
  sleep(1)
4845
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4506
4846
  rescue
4507
4847
  begin
4508
4848
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4509
4849
  sleep(1)
4850
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4510
4851
  rescue
4511
4852
  begin
4512
4853
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4513
4854
  sleep(1)
4855
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4514
4856
  rescue
4515
4857
  begin
4516
4858
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4517
4859
  sleep(1)
4860
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4518
4861
  rescue
4519
4862
  begin
4520
4863
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4521
4864
  sleep(1)
4865
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4522
4866
  rescue
4523
4867
  begin
4524
4868
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4525
4869
  sleep(1)
4870
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4526
4871
  rescue
4527
4872
  begin
4528
4873
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4529
4874
  sleep(1)
4875
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4530
4876
  rescue
4531
4877
  begin
4532
4878
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4533
4879
  sleep(1)
4880
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4534
4881
  rescue
4535
4882
  begin
4536
4883
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4539,25 +4886,29 @@ login_url = option['login_url'].to_s
4539
4886
  sleep(1)
4540
4887
  @driver.switch_to.default_content()
4541
4888
  sleep(1)
4889
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4542
4890
  rescue
4543
4891
  begin
4544
4892
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4545
4893
  sleep(1)
4894
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4546
4895
  rescue
4547
4896
  begin
4548
4897
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4549
4898
  sleep(1)
4899
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4550
4900
  rescue
4551
4901
  begin
4552
4902
  @driver.find_element(:xpath, '//*[@id="banner"]/div[2]/div/div[1]').click
4553
4903
  sleep(1)
4904
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4554
4905
  rescue
4555
4906
  begin
4556
4907
  @driver.find_element(:xpath, '//*[@id="hd_pops_2"]/div[2]/button[1]').click
4557
4908
  sleep(1)
4558
-
4909
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4559
4910
  rescue
4560
- puts '.......'.yellow
4911
+
4561
4912
 
4562
4913
  end
4563
4914
 
@@ -4587,63 +4938,76 @@ login_url = option['login_url'].to_s
4587
4938
  end
4588
4939
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4589
4940
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4590
- puts '-[√] 팝업 여부 확인 체크 03.......'.yellow
4591
4941
 
4592
4942
  begin
4593
4943
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4594
4944
  sleep(1)
4945
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4595
4946
  rescue
4596
4947
  begin
4597
4948
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4598
4949
  sleep(1)
4950
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4599
4951
  rescue
4600
4952
  begin
4601
4953
  @driver.find_element(:xpath, '//*[@class="close"]').click
4602
4954
  sleep(1)
4955
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4603
4956
  rescue
4604
4957
  begin
4605
4958
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4606
4959
  sleep(1)
4960
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4607
4961
  rescue
4608
4962
  begin
4609
4963
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4610
4964
  sleep(1)
4965
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4611
4966
  rescue
4612
4967
  begin
4613
4968
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4614
4969
  sleep(1)
4970
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4615
4971
  rescue
4616
4972
  begin
4617
4973
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4618
4974
  sleep(1)
4975
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4619
4976
  rescue
4620
4977
  begin
4621
4978
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4622
4979
  sleep(1)
4980
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4623
4981
  rescue
4624
4982
  begin
4625
4983
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4626
4984
  sleep(1)
4985
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4627
4986
  rescue
4628
4987
  begin
4629
4988
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4630
4989
  sleep(1)
4990
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4631
4991
  rescue
4632
4992
  begin
4633
4993
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4634
4994
  sleep(1)
4995
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4635
4996
  rescue
4636
4997
  begin
4637
4998
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4638
4999
  sleep(1)
5000
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4639
5001
  rescue
4640
5002
  begin
4641
5003
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4642
5004
  sleep(1)
5005
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4643
5006
  rescue
4644
5007
  begin
4645
5008
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4646
5009
  sleep(1)
5010
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4647
5011
  rescue
4648
5012
  begin
4649
5013
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4652,24 +5016,29 @@ login_url = option['login_url'].to_s
4652
5016
  sleep(1)
4653
5017
  @driver.switch_to.default_content()
4654
5018
  sleep(1)
5019
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4655
5020
  rescue
4656
5021
  begin
4657
5022
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4658
5023
  sleep(1)
5024
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4659
5025
  rescue
4660
5026
  begin
4661
5027
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4662
5028
  sleep(1)
5029
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4663
5030
  rescue
4664
5031
  begin
4665
5032
  @driver.find_element(:xpath, '//*[@id="banner"]/div[3]/div/div[1]').click
4666
5033
  sleep(1)
5034
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4667
5035
  rescue
4668
5036
  begin
4669
5037
  @driver.find_element(:xpath, '//*[@id="hd_pops_3"]/div[2]/button[1]').click
4670
5038
  sleep(1)
5039
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4671
5040
  rescue
4672
- puts '.......'.yellow
5041
+
4673
5042
 
4674
5043
  end
4675
5044
 
@@ -4699,63 +5068,77 @@ login_url = option['login_url'].to_s
4699
5068
  end
4700
5069
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4701
5070
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4702
- puts '-[√] 팝업 여부 확인 체크 04.......'.yellow
5071
+
4703
5072
 
4704
5073
  begin
4705
5074
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4706
5075
  sleep(1)
5076
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4707
5077
  rescue
4708
5078
  begin
4709
5079
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4710
5080
  sleep(1)
5081
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4711
5082
  rescue
4712
5083
  begin
4713
5084
  @driver.find_element(:xpath, '//*[@class="close"]').click
4714
5085
  sleep(1)
5086
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4715
5087
  rescue
4716
5088
  begin
4717
5089
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4718
5090
  sleep(1)
5091
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4719
5092
  rescue
4720
5093
  begin
4721
5094
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4722
5095
  sleep(1)
5096
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4723
5097
  rescue
4724
5098
  begin
4725
5099
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4726
5100
  sleep(1)
5101
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4727
5102
  rescue
4728
5103
  begin
4729
5104
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4730
5105
  sleep(1)
5106
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4731
5107
  rescue
4732
5108
  begin
4733
5109
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4734
5110
  sleep(1)
5111
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4735
5112
  rescue
4736
5113
  begin
4737
5114
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4738
5115
  sleep(1)
5116
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4739
5117
  rescue
4740
5118
  begin
4741
5119
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4742
5120
  sleep(1)
5121
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4743
5122
  rescue
4744
5123
  begin
4745
5124
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4746
5125
  sleep(1)
5126
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4747
5127
  rescue
4748
5128
  begin
4749
5129
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4750
5130
  sleep(1)
5131
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4751
5132
  rescue
4752
5133
  begin
4753
5134
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4754
5135
  sleep(1)
5136
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4755
5137
  rescue
4756
5138
  begin
4757
5139
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4758
5140
  sleep(1)
5141
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4759
5142
  rescue
4760
5143
  begin
4761
5144
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4764,24 +5147,29 @@ login_url = option['login_url'].to_s
4764
5147
  sleep(1)
4765
5148
  @driver.switch_to.default_content()
4766
5149
  sleep(1)
5150
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4767
5151
  rescue
4768
5152
  begin
4769
5153
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4770
5154
  sleep(1)
5155
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4771
5156
  rescue
4772
5157
  begin
4773
5158
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4774
5159
  sleep(1)
5160
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4775
5161
  rescue
4776
5162
  begin
4777
5163
  @driver.find_element(:xpath, '//*[@id="banner"]/div[4]/div/div[1]').click
4778
5164
  sleep(1)
5165
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4779
5166
  rescue
4780
5167
  begin
4781
5168
  @driver.find_element(:xpath, '//*[@id="hd_pops_4"]/div[2]/button[1]').click
4782
5169
  sleep(1)
5170
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4783
5171
  rescue
4784
- puts '.......'.yellow
5172
+
4785
5173
 
4786
5174
  end
4787
5175
 
@@ -4811,63 +5199,77 @@ login_url = option['login_url'].to_s
4811
5199
  end
4812
5200
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4813
5201
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4814
- puts '-[√] 팝업 여부 확인 체크 05.......'.yellow
5202
+
4815
5203
 
4816
5204
  begin
4817
5205
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4818
5206
  sleep(1)
5207
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4819
5208
  rescue
4820
5209
  begin
4821
5210
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4822
5211
  sleep(1)
5212
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4823
5213
  rescue
4824
5214
  begin
4825
5215
  @driver.find_element(:xpath, '//*[@class="close"]').click
4826
5216
  sleep(1)
5217
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4827
5218
  rescue
4828
5219
  begin
4829
5220
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4830
5221
  sleep(1)
5222
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4831
5223
  rescue
4832
5224
  begin
4833
5225
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4834
5226
  sleep(1)
5227
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4835
5228
  rescue
4836
5229
  begin
4837
5230
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4838
5231
  sleep(1)
5232
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4839
5233
  rescue
4840
5234
  begin
4841
5235
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4842
5236
  sleep(1)
5237
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4843
5238
  rescue
4844
5239
  begin
4845
5240
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4846
5241
  sleep(1)
5242
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4847
5243
  rescue
4848
5244
  begin
4849
5245
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4850
5246
  sleep(1)
5247
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4851
5248
  rescue
4852
5249
  begin
4853
5250
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4854
5251
  sleep(1)
5252
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4855
5253
  rescue
4856
5254
  begin
4857
5255
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4858
5256
  sleep(1)
5257
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4859
5258
  rescue
4860
5259
  begin
4861
5260
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4862
5261
  sleep(1)
5262
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4863
5263
  rescue
4864
5264
  begin
4865
5265
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4866
5266
  sleep(1)
5267
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4867
5268
  rescue
4868
5269
  begin
4869
5270
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4870
5271
  sleep(1)
5272
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4871
5273
  rescue
4872
5274
  begin
4873
5275
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4876,22 +5278,27 @@ login_url = option['login_url'].to_s
4876
5278
  sleep(1)
4877
5279
  @driver.switch_to.default_content()
4878
5280
  sleep(1)
5281
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4879
5282
  rescue
4880
5283
  begin
4881
5284
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4882
5285
  sleep(1)
5286
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4883
5287
  rescue
4884
5288
  begin
4885
5289
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4886
5290
  sleep(1)
5291
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4887
5292
  rescue
4888
5293
  begin
4889
5294
  @driver.find_element(:xpath, '//*[@id="banner"]/div[5]/div/div[1]').click
4890
5295
  sleep(1)
5296
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4891
5297
  rescue
4892
5298
  begin
4893
5299
  @driver.find_element(:xpath, '//*[@id="hd_pops_5"]/div[2]/button[1]').click
4894
5300
  sleep(1)
5301
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4895
5302
  rescue
4896
5303
  begin
4897
5304
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="aswift_1"]'))
@@ -4900,8 +5307,9 @@ login_url = option['login_url'].to_s
4900
5307
  sleep(1)
4901
5308
  @driver.switch_to.default_content
4902
5309
  sleep(1)
5310
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4903
5311
  rescue
4904
- puts '.......'.yellow
5312
+
4905
5313
 
4906
5314
  end
4907
5315
 
@@ -4939,7 +5347,6 @@ login_url = option['login_url'].to_s
4939
5347
 
4940
5348
 
4941
5349
  ##닉네임 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4942
- puts '-[√] 닉네임 입력 가능 여부 체크.......'.yellow
4943
5350
 
4944
5351
 
4945
5352
  begin
@@ -6101,6 +6508,7 @@ begin
6101
6508
  begin
6102
6509
  sleep(2)
6103
6510
  @driver.switch_to.alert.accept
6511
+ sleep(1)
6104
6512
  rescue
6105
6513
  sleep(1)
6106
6514
  end
@@ -6394,7 +6802,7 @@ rescue
6394
6802
  end
6395
6803
  ##<<─────────────────────────────────────────────────────────────────────내용 임시부분 제거
6396
6804
 
6397
- puts '-[√] 포스팅할 내용 준비.......'.cyan
6805
+
6398
6806
  puts content
6399
6807
  noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
6400
6808
  toomung = 0
@@ -6402,7 +6810,7 @@ end
6402
6810
 
6403
6811
  sleep(1)
6404
6812
  data = Hash.new
6405
- puts '-[√] 내용 등록 마무리 진행 중.......'.cyan
6813
+
6406
6814
 
6407
6815
 
6408
6816
 
@@ -7376,42 +7784,106 @@ end
7376
7784
 
7377
7785
 
7378
7786
 
7379
- #@driver.action.key_down(:tab).key_up(:tab).perform #x탭
7787
+ begin
7788
+
7789
+ @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]')
7790
+ check_captcha = 1
7380
7791
 
7792
+ rescue
7793
+ check_captcha = 0
7794
+ end
7381
7795
 
7382
- sleep(1)
7383
- ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
7384
- puts '-[√] 캡챠 유형 탐색.......'.green
7796
+ if check_captcha == 1
7797
+ begin
7798
+ # 타임아웃을 3초로 설정
7799
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
7800
+ # 요소가 나타날 때까지 30초 동안 기다립니다.
7801
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
7802
+ sleep(1)
7385
7803
 
7804
+ el_ready = @driver.find_element(:xpath, '//*[@data-state="ready"]')
7805
+ @driver.action.move_to(el_ready).perform
7806
+ sleep(1)
7386
7807
 
7387
- begin
7388
- @driver.switch_to.default_content()
7389
- #@driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7390
- el = @driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7391
- puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7392
- puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7393
- puts '-[√] 챕챠 코드 code 1.......'.red
7394
- sleep(1)
7395
- @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7396
- sleep(1)
7397
- mouse_move_percentage(0.3,0.02)
7398
- sleep(0.5)
7399
- left_click
7400
- sleep(1)
7401
- @driver.switch_to.window(@driver.window_handle) #핸들 주입
7402
- @driver.action.context_click(el).perform #우 클릭
7403
- sleep(1)
7404
- @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
7405
- sleep(1)
7406
- puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
7407
- rescue
7808
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
7809
+ begin
7810
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
7811
+ rescue
7812
+ begin
7813
+ @driver.find_element(:xpath, '//*[@class="captcha-solver-image"]').click #캡챠우회버튼
7814
+ rescue
7815
+ begin
7816
+ @driver.find_element(:xpath, '//*[@class="captcha-solver-info"]').click #캡챠우회버튼
7817
+ rescue
7818
+ begin
7819
+ @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]').click #캡챠우회버튼
7820
+ rescue
7821
+ end
7822
+ end
7823
+ end
7824
+ end
7825
+
7826
+
7827
+ sleep(10)
7828
+ begin
7829
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click
7830
+ puts '-[√] 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
7831
+ puts '-[√] 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
7832
+ @driver.window_handles.each do |handle|
7833
+ @driver.switch_to.window(handle)
7834
+ begin
7835
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
7836
+ @driver.close
7837
+ rescue Selenium::WebDriver::Error::WebDriverError => e
7838
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
7839
+ end
7840
+ end
7841
+ return 0
7842
+ @driver.quit
7843
+ rescue
7844
+ # 타임아웃을 77초로 설정
7845
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
7846
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
7847
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
7848
+ sleep(1)
7849
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click
7850
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
7851
+ sleep(3)
7852
+ begin
7853
+ @driver.find_element(:xpath, '//*[@name="user_captcha"]').click
7854
+ sleep(1)
7855
+ @driver.action.key_down(:right).key_up(:right).perform
7856
+ rescue
7857
+ begin
7858
+ @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
7859
+ sleep(1)
7860
+ @driver.action.key_down(:right).key_up(:right).perform
7861
+ rescue
7862
+ begin
7863
+ @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
7864
+ sleep(1)
7865
+ @driver.action.key_down(:right).key_up(:right).perform
7866
+ rescue
7867
+ end
7868
+ end
7869
+ end
7870
+ sleep(1)
7871
+ end
7872
+ rescue
7873
+
7874
+ end
7875
+ else
7876
+ end
7877
+
7878
+ if check_captcha == 0
7879
+ puts'캡챠 유무 확인.......'.yellow
7408
7880
  begin
7409
7881
  @driver.switch_to.default_content()
7410
- #@driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7411
- el = @driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7882
+ #@driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7883
+ el = @driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7412
7884
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7413
7885
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7414
- puts '-[√] 챕챠 코드 code 2.......'.red
7886
+ puts '-[√] 챕챠 코드 code 1.......'.red
7415
7887
  sleep(1)
7416
7888
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7417
7889
  sleep(1)
@@ -7428,17 +7900,11 @@ rescue
7428
7900
  rescue
7429
7901
  begin
7430
7902
  @driver.switch_to.default_content()
7431
- #@driver.find_element(:xpath, '//*[@id="captcha_img"]').send_keys(:tab)
7432
- el = @driver.find_element(:xpath, '//*[@id="captcha_img"]')
7903
+ #@driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7904
+ el = @driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7433
7905
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7434
7906
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7435
- puts '-[√] 챕챠 코드 code 3.......'.red
7436
- sleep(1)
7437
- #요소 자체 제거 하기 기능
7438
- chat_box = @driver.find_element(:xpath, '//*[@for="captcha_key"]')
7439
- @driver.execute_script("arguments[0].remove();", chat_box)
7440
- sleep(1)
7441
-
7907
+ puts '-[√] 챕챠 코드 code 2.......'.red
7442
7908
  sleep(1)
7443
7909
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7444
7910
  sleep(1)
@@ -7455,11 +7921,17 @@ rescue
7455
7921
  rescue
7456
7922
  begin
7457
7923
  @driver.switch_to.default_content()
7458
- #@driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7459
- el = @driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7924
+ #@driver.find_element(:xpath, '//*[@id="captcha_img"]').send_keys(:tab)
7925
+ el = @driver.find_element(:xpath, '//*[@id="captcha_img"]')
7460
7926
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7461
7927
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7462
- puts '-[√] 챕챠 코드 code 4.......'.red
7928
+ puts '-[√] 챕챠 코드 code 3.......'.red
7929
+ sleep(1)
7930
+ #요소 자체 제거 하기 기능
7931
+ chat_box = @driver.find_element(:xpath, '//*[@for="captcha_key"]')
7932
+ @driver.execute_script("arguments[0].remove();", chat_box)
7933
+ sleep(1)
7934
+
7463
7935
  sleep(1)
7464
7936
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7465
7937
  sleep(1)
@@ -7476,10 +7948,11 @@ rescue
7476
7948
  rescue
7477
7949
  begin
7478
7950
  @driver.switch_to.default_content()
7479
- el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
7951
+ #@driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7952
+ el = @driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7480
7953
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7481
7954
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7482
- puts '-[√] 챕챠 코드 code 5-1.......'.red
7955
+ puts '-[√] 챕챠 코드 code 4.......'.red
7483
7956
  sleep(1)
7484
7957
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7485
7958
  sleep(1)
@@ -7496,11 +7969,10 @@ rescue
7496
7969
  rescue
7497
7970
  begin
7498
7971
  @driver.switch_to.default_content()
7499
- #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
7500
- el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
7972
+ el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
7501
7973
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7502
7974
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7503
- puts '-[√] 챕챠 코드 code 5-2.......'.red
7975
+ puts '-[√] 챕챠 코드 code 5-1.......'.red
7504
7976
  sleep(1)
7505
7977
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7506
7978
  sleep(1)
@@ -7517,12 +7989,11 @@ rescue
7517
7989
  rescue
7518
7990
  begin
7519
7991
  @driver.switch_to.default_content()
7520
- sleep(1)
7521
- #@driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7522
- el = @driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7992
+ #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
7993
+ el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
7523
7994
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7524
7995
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7525
- puts '-[√] 챕챠 코드 code 6.......'.red
7996
+ puts '-[√] 챕챠 코드 code 5-2.......'.red
7526
7997
  sleep(1)
7527
7998
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7528
7999
  sleep(1)
@@ -7539,11 +8010,12 @@ rescue
7539
8010
  rescue
7540
8011
  begin
7541
8012
  @driver.switch_to.default_content()
7542
- #@driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
7543
- el = @driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
8013
+ sleep(1)
8014
+ #@driver.find_element(:xpath, '//*[@id="captcha_Write"]')
8015
+ el = @driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7544
8016
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7545
8017
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7546
- puts '-[√] 챕챠 코드 code 7.......'.red
8018
+ puts '-[√] 챕챠 코드 code 6.......'.red
7547
8019
  sleep(1)
7548
8020
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7549
8021
  sleep(1)
@@ -7560,11 +8032,11 @@ rescue
7560
8032
  rescue
7561
8033
  begin
7562
8034
  @driver.switch_to.default_content()
7563
- #@driver.find_element(:xpath, '//*[@id="spamauth"]')
7564
- el = @driver.find_element(:xpath, '//*[@id="spamauth"]')
8035
+ #@driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
8036
+ el = @driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
7565
8037
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7566
8038
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7567
- puts '-[√] 챕챠 코드 code 8.......'.red
8039
+ puts '-[√] 챕챠 코드 code 7.......'.red
7568
8040
  sleep(1)
7569
8041
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7570
8042
  sleep(1)
@@ -7581,11 +8053,11 @@ rescue
7581
8053
  rescue
7582
8054
  begin
7583
8055
  @driver.switch_to.default_content()
7584
- #@driver.find_element(:xpath, '//*[@id="norobot_img"]')
7585
- el = @driver.find_element(:xpath, '//*[@id="norobot_img"]')
8056
+ #@driver.find_element(:xpath, '//*[@id="spamauth"]')
8057
+ el = @driver.find_element(:xpath, '//*[@id="spamauth"]')
7586
8058
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7587
8059
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7588
- puts '-[√] 챕챠 코드 code 9.......'.red
8060
+ puts '-[√] 챕챠 코드 code 8.......'.red
7589
8061
  sleep(1)
7590
8062
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7591
8063
  sleep(1)
@@ -7602,10 +8074,11 @@ rescue
7602
8074
  rescue
7603
8075
  begin
7604
8076
  @driver.switch_to.default_content()
7605
- el = @driver.find_element(:xpath, '//*[@class="CodeImage"]')
8077
+ #@driver.find_element(:xpath, '//*[@id="norobot_img"]')
8078
+ el = @driver.find_element(:xpath, '//*[@id="norobot_img"]')
7606
8079
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7607
8080
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7608
- puts '-[√] 챕챠 코드 code 10.......'.red
8081
+ puts '-[√] 챕챠 코드 code 9.......'.red
7609
8082
  sleep(1)
7610
8083
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7611
8084
  sleep(1)
@@ -7622,10 +8095,10 @@ rescue
7622
8095
  rescue
7623
8096
  begin
7624
8097
  @driver.switch_to.default_content()
7625
- el = @driver.find_element(:xpath, '//*[@id="kcaptcha_image"]')
8098
+ el = @driver.find_element(:xpath, '//*[@class="CodeImage"]')
7626
8099
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7627
8100
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7628
- puts '-[√] 챕챠 코드 code 11.......'.red
8101
+ puts '-[√] 챕챠 코드 code 10.......'.red
7629
8102
  sleep(1)
7630
8103
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7631
8104
  sleep(1)
@@ -7642,10 +8115,10 @@ rescue
7642
8115
  rescue
7643
8116
  begin
7644
8117
  @driver.switch_to.default_content()
7645
- el = @driver.find_element(:xpath, '//*[@class="lazy-loaded"]')
8118
+ el = @driver.find_element(:xpath, '//*[@id="kcaptcha_image"]')
7646
8119
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7647
8120
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7648
- puts '-[√] 챕챠 코드 code 12.......'.red
8121
+ puts '-[√] 챕챠 코드 code 11.......'.red
7649
8122
  sleep(1)
7650
8123
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7651
8124
  sleep(1)
@@ -7660,8 +8133,29 @@ rescue
7660
8133
  sleep(1)
7661
8134
  puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
7662
8135
  rescue
7663
-
7664
- end
8136
+ begin
8137
+ @driver.switch_to.default_content()
8138
+ el = @driver.find_element(:xpath, '//*[@class="lazy-loaded"]')
8139
+ puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
8140
+ puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
8141
+ puts '-[√] 챕챠 코드 code 12.......'.red
8142
+ sleep(1)
8143
+ @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
8144
+ sleep(1)
8145
+ mouse_move_percentage(0.3,0.02)
8146
+ sleep(0.5)
8147
+ left_click
8148
+ sleep(1)
8149
+ @driver.switch_to.window(@driver.window_handle) #핸들 주입
8150
+ @driver.action.context_click(el).perform #우 클릭
8151
+ sleep(1)
8152
+ @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
8153
+ sleep(1)
8154
+ puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
8155
+ rescue
8156
+
8157
+ end
8158
+ end
7665
8159
  end
7666
8160
  end
7667
8161
  end
@@ -7673,57 +8167,17 @@ rescue
7673
8167
  end
7674
8168
  end
7675
8169
  end
7676
- end
7677
- ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
7678
-
7679
- sleep(1)
7680
-
7681
- ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
7682
- puts '-[√] 캡챠 입력 항목 탐색.......'.green
7683
- begin
7684
- @driver.find_element(:xpath, '//*[@name="captcha_key"]').click
7685
-
7686
- sleep(1)
7687
8170
 
7688
- el2 = @driver.find_element(:xpath, '//*[@name="captcha_key"]')
7689
- @driver.action.context_click(el2).perform
7690
- sleep(1)
7691
- @driver.action.key_stroke('up')
7692
- sleep(1)
7693
- @driver.action.key_stroke('up')
7694
- sleep(1)
7695
- @driver.action.key_stroke('enter')
7696
8171
  sleep(1)
7697
8172
 
8173
+ puts '-[√] 캡챠 입력 항목 탐색.......'.green
7698
8174
  begin
7699
- # 요소 찾기 타임아웃을 7초로 설정
7700
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7701
- #요소가 나타날 때까지 7초 동안 기다립니다.
7702
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7703
- rescue
7704
- sleep(1)
7705
- @driver.action.key_stroke('left')
7706
- sleep(1)
7707
- @driver.action.key_stroke('up')
7708
- sleep(1)
7709
- @driver.action.key_stroke('enter')
7710
- sleep(1)
7711
- # 요소 찾기 타임아웃을 7초로 설정
7712
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7713
- #요소가 나타날 때까지 7초 동안 기다립니다.
7714
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7715
- end
7716
- puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
7717
- sleep(1)
7718
- rescue
7719
- begin
7720
- @driver.find_element(:xpath, '//*[@id="captcha_key"]').click
8175
+ @driver.find_element(:xpath, '//*[@name="captcha_key"]').click
7721
8176
 
7722
8177
  sleep(1)
7723
-
7724
- el2 = @driver.find_element(:xpath, '//*[@id="captcha_key"]')
8178
+
8179
+ el2 = @driver.find_element(:xpath, '//*[@name="captcha_key"]')
7725
8180
  @driver.action.context_click(el2).perform
7726
-
7727
8181
  sleep(1)
7728
8182
  @driver.action.key_stroke('up')
7729
8183
  sleep(1)
@@ -7731,33 +8185,34 @@ rescue
7731
8185
  sleep(1)
7732
8186
  @driver.action.key_stroke('enter')
7733
8187
  sleep(1)
8188
+
7734
8189
  begin
7735
- # 요소 찾기 타임아웃을 7초로 설정
7736
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7737
- #요소가 나타날 때까지 7초 동안 기다립니다.
7738
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7739
- rescue
7740
- sleep(1)
7741
- @driver.action.key_stroke('left')
7742
- sleep(1)
7743
- @driver.action.key_stroke('up')
7744
- sleep(1)
7745
- @driver.action.key_stroke('enter')
7746
- sleep(1)
7747
- # 요소 찾기 타임아웃을 7초로 설정
7748
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7749
- #요소가 나타날 때까지 7초 동안 기다립니다.
7750
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7751
- end
8190
+ # 요소 찾기 타임아웃을 7초로 설정
8191
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8192
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8193
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8194
+ rescue
8195
+ sleep(1)
8196
+ @driver.action.key_stroke('left')
8197
+ sleep(1)
8198
+ @driver.action.key_stroke('up')
8199
+ sleep(1)
8200
+ @driver.action.key_stroke('enter')
8201
+ sleep(1)
8202
+ # 요소 찾기 타임아웃을 7초로 설정
8203
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8204
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8205
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8206
+ end
7752
8207
  puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
7753
8208
  sleep(1)
7754
8209
  rescue
7755
8210
  begin
7756
- @driver.find_element(:xpath, '=//*[@id="code"]').click
7757
-
7758
- sleep(1)
8211
+ @driver.find_element(:xpath, '//*[@id="captcha_key"]').click
7759
8212
 
7760
- el2 = @driver.find_element(:xpath, '//*[@id="code"]')
8213
+ sleep(1)
8214
+
8215
+ el2 = @driver.find_element(:xpath, '//*[@id="captcha_key"]')
7761
8216
  @driver.action.context_click(el2).perform
7762
8217
 
7763
8218
  sleep(1)
@@ -7789,11 +8244,11 @@ rescue
7789
8244
  sleep(1)
7790
8245
  rescue
7791
8246
  begin
7792
- @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]').click
7793
-
8247
+ @driver.find_element(:xpath, '=//*[@id="code"]').click
8248
+
7794
8249
  sleep(1)
7795
8250
 
7796
- el2 = @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]')
8251
+ el2 = @driver.find_element(:xpath, '//*[@id="code"]')
7797
8252
  @driver.action.context_click(el2).perform
7798
8253
 
7799
8254
  sleep(1)
@@ -7825,11 +8280,11 @@ rescue
7825
8280
  sleep(1)
7826
8281
  rescue
7827
8282
  begin
7828
- @driver.find_element(:xpath, '//*[@fw-label="보안문자"]').click
8283
+ @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]').click
7829
8284
 
7830
8285
  sleep(1)
7831
8286
 
7832
- el2 = @driver.find_element(:xpath, '//*[@fw-label="보안문자"]')
8287
+ el2 = @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]')
7833
8288
  @driver.action.context_click(el2).perform
7834
8289
 
7835
8290
  sleep(1)
@@ -7861,23 +8316,24 @@ rescue
7861
8316
  sleep(1)
7862
8317
  rescue
7863
8318
  begin
7864
- @driver.find_element(:xpath, '//*[@name="captcha"]').click
8319
+ @driver.find_element(:xpath, '//*[@fw-label="보안문자"]').click
8320
+
7865
8321
  sleep(1)
7866
-
7867
- # CAPTCHA 요소 찾기
7868
- el2 = @driver.find_element(:xpath, '//*[@name="captcha"]')
7869
-
7870
- # 우클릭 (context_click) 실행
8322
+
8323
+ el2 = @driver.find_element(:xpath, '//*[@fw-label="보안문자"]')
7871
8324
  @driver.action.context_click(el2).perform
8325
+
7872
8326
  sleep(1)
7873
8327
  @driver.action.key_stroke('up')
7874
8328
  sleep(1)
7875
8329
  @driver.action.key_stroke('up')
7876
8330
  sleep(1)
7877
8331
  @driver.action.key_stroke('enter')
8332
+ sleep(1)
7878
8333
  begin
8334
+ # 요소 찾기 타임아웃을 7초로 설정
7879
8335
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7880
- # 요소가 나타날 때까지 7초 동안 기다립니다.
8336
+ #요소가 나타날 때까지 7초 동안 기다립니다.
7881
8337
  wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7882
8338
  rescue
7883
8339
  sleep(1)
@@ -7896,24 +8352,23 @@ rescue
7896
8352
  sleep(1)
7897
8353
  rescue
7898
8354
  begin
7899
- @driver.find_element(:xpath, '//*[@id="spamCode"]').click
7900
-
8355
+ @driver.find_element(:xpath, '//*[@name="captcha"]').click
7901
8356
  sleep(1)
7902
-
7903
- el2 = @driver.find_element(:xpath, '//*[@id="spamCode"]')
8357
+
8358
+ # CAPTCHA 요소 찾기
8359
+ el2 = @driver.find_element(:xpath, '//*[@name="captcha"]')
8360
+
8361
+ # 우클릭 (context_click) 실행
7904
8362
  @driver.action.context_click(el2).perform
7905
-
7906
8363
  sleep(1)
7907
8364
  @driver.action.key_stroke('up')
7908
8365
  sleep(1)
7909
8366
  @driver.action.key_stroke('up')
7910
8367
  sleep(1)
7911
8368
  @driver.action.key_stroke('enter')
7912
- sleep(1)
7913
8369
  begin
7914
- # 요소 찾기 타임아웃을 7초로 설정
7915
8370
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7916
- #요소가 나타날 때까지 7초 동안 기다립니다.
8371
+ # 요소가 나타날 때까지 7초 동안 기다립니다.
7917
8372
  wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7918
8373
  rescue
7919
8374
  sleep(1)
@@ -7932,13 +8387,14 @@ rescue
7932
8387
  sleep(1)
7933
8388
  rescue
7934
8389
  begin
7935
- @driver.find_element(:xpath, '//*[@id="norobot_code"]').click
7936
-
8390
+ @driver.find_element(:xpath, '//*[@id="spamCode"]').click
8391
+
7937
8392
  sleep(1)
7938
-
7939
- el2 = @driver.find_element(:xpath, '//*[@id="norobot_code"]')
8393
+
8394
+ el2 = @driver.find_element(:xpath, '//*[@id="spamCode"]')
7940
8395
  @driver.action.context_click(el2).perform
7941
-
8396
+
8397
+ sleep(1)
7942
8398
  @driver.action.key_stroke('up')
7943
8399
  sleep(1)
7944
8400
  @driver.action.key_stroke('up')
@@ -7967,51 +8423,48 @@ rescue
7967
8423
  sleep(1)
7968
8424
  rescue
7969
8425
  begin
7970
- @driver.switch_to.default_content()
7971
- sleep(1)
7972
- @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]').click
7973
-
7974
- sleep(1)
8426
+ @driver.find_element(:xpath, '//*[@id="norobot_code"]').click
7975
8427
 
7976
- el2 = @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]')
7977
- @driver.action.context_click(el2).perform
7978
-
8428
+ sleep(1)
8429
+
8430
+ el2 = @driver.find_element(:xpath, '//*[@id="norobot_code"]')
8431
+ @driver.action.context_click(el2).perform
8432
+
8433
+ @driver.action.key_stroke('up')
8434
+ sleep(1)
8435
+ @driver.action.key_stroke('up')
8436
+ sleep(1)
8437
+ @driver.action.key_stroke('enter')
8438
+ sleep(1)
8439
+ begin
8440
+ # 요소 찾기 타임아웃을 7초로 설정
8441
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8442
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8443
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8444
+ rescue
7979
8445
  sleep(1)
7980
- @driver.action.key_stroke('up')
8446
+ @driver.action.key_stroke('left')
7981
8447
  sleep(1)
7982
8448
  @driver.action.key_stroke('up')
7983
8449
  sleep(1)
7984
8450
  @driver.action.key_stroke('enter')
7985
- sleep(1)
7986
- begin
7987
- # 요소 찾기 타임아웃을 7초로 설정
7988
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7989
- #요소가 나타날 때까지 7초 동안 기다립니다.
7990
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7991
- rescue
7992
- sleep(1)
7993
- @driver.action.key_stroke('left')
7994
- sleep(1)
7995
- @driver.action.key_stroke('up')
7996
- sleep(1)
7997
- @driver.action.key_stroke('enter')
7998
- sleep(1)
7999
- # 요소 찾기 타임아웃을 7초로 설정
8000
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8001
- #요소가 나타날 때까지 7초 동안 기다립니다.
8002
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8003
- end
8004
- puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8005
- sleep(1)
8451
+ sleep(1)
8452
+ # 요소 찾기 타임아웃을 7초로 설정
8453
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8454
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8455
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8456
+ end
8457
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8458
+ sleep(1)
8006
8459
  rescue
8007
8460
  begin
8008
8461
  @driver.switch_to.default_content()
8009
8462
  sleep(1)
8010
- @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
8463
+ @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]').click
8011
8464
 
8012
8465
  sleep(1)
8013
8466
 
8014
- el2 = @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]')
8467
+ el2 = @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]')
8015
8468
  @driver.action.context_click(el2).perform
8016
8469
 
8017
8470
  sleep(1)
@@ -8045,11 +8498,11 @@ rescue
8045
8498
  begin
8046
8499
  @driver.switch_to.default_content()
8047
8500
  sleep(1)
8048
- @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
8501
+ @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
8049
8502
 
8050
8503
  sleep(1)
8051
8504
 
8052
- el2 = @driver.find_element(:xpath, '//*[@id="user_captcha"]')
8505
+ el2 = @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]')
8053
8506
  @driver.action.context_click(el2).perform
8054
8507
 
8055
8508
  sleep(1)
@@ -8083,11 +8536,11 @@ rescue
8083
8536
  begin
8084
8537
  @driver.switch_to.default_content()
8085
8538
  sleep(1)
8086
- @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]').click
8539
+ @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
8087
8540
 
8088
8541
  sleep(1)
8089
8542
 
8090
- el2 = @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]')
8543
+ el2 = @driver.find_element(:xpath, '//*[@id="user_captcha"]')
8091
8544
  @driver.action.context_click(el2).perform
8092
8545
 
8093
8546
  sleep(1)
@@ -8121,11 +8574,11 @@ rescue
8121
8574
  begin
8122
8575
  @driver.switch_to.default_content()
8123
8576
  sleep(1)
8124
- @driver.find_element(:xpath, '//*[@name="wr_key"]').click
8577
+ @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]').click
8125
8578
 
8126
8579
  sleep(1)
8127
8580
 
8128
- el2 = @driver.find_element(:xpath, '//*[@name="wr_key"]')
8581
+ el2 = @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]')
8129
8582
  @driver.action.context_click(el2).perform
8130
8583
 
8131
8584
  sleep(1)
@@ -8159,11 +8612,11 @@ rescue
8159
8612
  begin
8160
8613
  @driver.switch_to.default_content()
8161
8614
  sleep(1)
8162
- @driver.find_element(:xpath, '//*[@title="자동등록방지"]').click
8615
+ @driver.find_element(:xpath, '//*[@name="wr_key"]').click
8163
8616
 
8164
8617
  sleep(1)
8165
8618
 
8166
- el2 = @driver.find_element(:xpath, '//*[@title="자동등록방지"]')
8619
+ el2 = @driver.find_element(:xpath, '//*[@name="wr_key"]')
8167
8620
  @driver.action.context_click(el2).perform
8168
8621
 
8169
8622
  sleep(1)
@@ -8197,11 +8650,11 @@ rescue
8197
8650
  begin
8198
8651
  @driver.switch_to.default_content()
8199
8652
  sleep(1)
8200
- @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]').click
8653
+ @driver.find_element(:xpath, '//*[@title="자동등록방지"]').click
8201
8654
 
8202
8655
  sleep(1)
8203
8656
 
8204
- el2 = @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]')
8657
+ el2 = @driver.find_element(:xpath, '//*[@title="자동등록방지"]')
8205
8658
  @driver.action.context_click(el2).perform
8206
8659
 
8207
8660
  sleep(1)
@@ -8232,7 +8685,46 @@ rescue
8232
8685
  puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8233
8686
  sleep(1)
8234
8687
  rescue
8235
-
8688
+ begin
8689
+ @driver.switch_to.default_content()
8690
+ sleep(1)
8691
+ @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]').click
8692
+
8693
+ sleep(1)
8694
+
8695
+ el2 = @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]')
8696
+ @driver.action.context_click(el2).perform
8697
+
8698
+ sleep(1)
8699
+ @driver.action.key_stroke('up')
8700
+ sleep(1)
8701
+ @driver.action.key_stroke('up')
8702
+ sleep(1)
8703
+ @driver.action.key_stroke('enter')
8704
+ sleep(1)
8705
+ begin
8706
+ # 요소 찾기 타임아웃을 7초로 설정
8707
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8708
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8709
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8710
+ rescue
8711
+ sleep(1)
8712
+ @driver.action.key_stroke('left')
8713
+ sleep(1)
8714
+ @driver.action.key_stroke('up')
8715
+ sleep(1)
8716
+ @driver.action.key_stroke('enter')
8717
+ sleep(1)
8718
+ # 요소 찾기 타임아웃을 7초로 설정
8719
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8720
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8721
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8722
+ end
8723
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8724
+ sleep(1)
8725
+ rescue
8726
+
8727
+ end
8236
8728
  end
8237
8729
  end
8238
8730
  end
@@ -8246,9 +8738,8 @@ rescue
8246
8738
  end
8247
8739
  end
8248
8740
  end
8249
- end
8250
- end
8251
- ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
8741
+ end
8742
+
8252
8743
 
8253
8744
 
8254
8745
 
@@ -8342,7 +8833,8 @@ end
8342
8833
 
8343
8834
 
8344
8835
 
8345
-
8836
+ else
8837
+ end
8346
8838
 
8347
8839
 
8348
8840
 
@@ -8370,7 +8862,7 @@ sleep(1)
8370
8862
 
8371
8863
 
8372
8864
  ##등록 버튼 코드 부분─────────────────────────────────────────────────────────────────────>
8373
- puts '-[√] HTML 버튼 복구 여부 체크.......'.yellow
8865
+
8374
8866
  begin
8375
8867
  @driver.find_element(:xpath, '//*[@aria-label="코드 보기"]')
8376
8868
  sleep(1)
@@ -8395,7 +8887,7 @@ rescue
8395
8887
  @driver.find_element(:xpath, '//*[@title="에디터 타입"]').click
8396
8888
  sleep(1)
8397
8889
  rescue
8398
- puts '-[√] HTML 버튼 복구 여부 체크 종료.......'.yellow
8890
+
8399
8891
  end
8400
8892
  end
8401
8893
  end
@@ -8576,6 +9068,8 @@ rescue
8576
9068
  sleep(1)
8577
9069
 
8578
9070
  @driver.find_element(:xpath, '//*[@form="write"]').click
9071
+ sleep(1)
9072
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
8579
9073
  puts '-[√] 등록을 19번 코드로 시도하였습니다.......'.magenta
8580
9074
  sleep(5)
8581
9075
 
@@ -9502,64 +9996,36 @@ class Wordpress
9502
9996
  puts table[10]
9503
9997
  if table[8].to_i > table[10].to_i
9504
9998
  if @data['포스트설정']['테더링'].checked?
9505
- puts 'Tethering IP change...'
9506
-
9999
+ puts 'tedering ip change...'
9507
10000
  stdout, stderr, status = Open3.capture3('./adb devices')
9508
-
9509
10001
  if status.success?
9510
- device_id = stdout.split("\n")[1].split("\t")[0]
9511
- puts device_id
9512
-
9513
- # ADB 서버 초기화
9514
- puts 'adb kill-server'
9515
- Open3.capture3('./adb kill-server')
9516
- sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
9517
-
9518
- # 다시 ADB 서버 실행
9519
- puts 'adb start-server'
9520
- Open3.capture3('./adb start-server')
9521
- sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
9522
-
9523
- # 데이터를 끄고 켜기
9524
- puts 'adb -s ' + device_id + ' shell svc data disable'
9525
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
9526
- puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
9527
- sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
9528
- puts 'adb -s ' + device_id + ' shell svc data enable'
9529
- stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
9530
- puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
9531
- sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
9532
- puts 'adb ok'
9533
- sleep(8)
9534
-
9535
- # IP 변경 확인을 위한 람다 함수
9536
- robot_ip = lambda do
9537
- begin
9538
- # IP 변경 확인
9539
- http = HTTP.get('https://www.findip.kr/')
9540
- noko = Nokogiri::HTML(http.to_s)
9541
-
9542
- current_ip = noko.xpath('/html/body/header/h2').text.strip
9543
- if current_ip != @my_ip
9544
- @my_ip = current_ip
9545
- puts "IP 변경됨[ #{@my_ip} ]"
9546
- else
9547
- puts "현재 IP: #{@my_ip}"
9548
- puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
9549
- sleep(5) # 여유롭게 대기 시간 증가
9550
- robot_ip[] # 재시도
9551
- end
9552
- rescue HTTP::ConnectionError => e
9553
- puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
9554
- sleep(5) # 재시도 간 여유 시간 추가
9555
- retry # 재시도
10002
+ device_id = stdout.split("\n")[1].split("\t")[0]
10003
+ puts device_id
10004
+ puts 'adb -s '+device_id+' shell svc data disable'
10005
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
10006
+ sleep(3)
10007
+ puts 'adb -s '+device_id+' shell svc data enable'
10008
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
10009
+ sleep(3)
10010
+ puts 'adb ok'
10011
+ sleep(8)
10012
+ robot_ip = lambda do
10013
+ http = HTTP.get('https://www.findip.kr/')
10014
+ noko = Nokogiri::HTML(http.to_s)
10015
+ if noko.xpath('/html/body/header/h2').text != @my_ip
10016
+ @my_ip = noko.xpath('/html/body/header/h2').text
10017
+ else
10018
+ puts @my_ip
10019
+ puts '재시도...'
10020
+ sleep(3)
10021
+ robot_ip[]
10022
+ end
9556
10023
  end
9557
- end
9558
- robot_ip[] # IP 확인 시작
10024
+ robot_ip[]
9559
10025
  else
9560
- puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
10026
+ puts 'adb error pass'
9561
10027
  end
9562
- end
10028
+ end
9563
10029
 
9564
10030
  check_success = 1
9565
10031
  @data['table'][index][-1] = 0
@@ -9637,7 +10103,7 @@ class Wordpress
9637
10103
  @data['table'].pop
9638
10104
 
9639
10105
  #네이버로그인
9640
- login_check = naver.login(option['proxy'])
10106
+ login_check = naver.login(option['proxy'],captcha_key)
9641
10107
  if login_check == 0
9642
10108
  black_users << table[1].to_s
9643
10109
  next