posting_zon 0.0.137 → 0.0.173

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_zon.rb +355 -336
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c704e405ad36391ff9824557047bb9796014e610742f3c4f404f6d570c83e167
4
- data.tar.gz: 83f29840b0b681e2453db61529b6c827676ce6f72dd1602b70f0ad93fbd96416
3
+ metadata.gz: 84b0a890c754d54128949408947f225ff7e5bcd373b25fddb6fa5e65eaff2706
4
+ data.tar.gz: e3950842439ea08301706997bf6a9344152fbc415f5279de798864ce3bf38519
5
5
  SHA512:
6
- metadata.gz: '0653278d47afed770e9d9779beaa222cb5cc4773febd110866fa31d267584cb1152db6df5fbc5a0daae9b089c79d8c19289c5c44c8c9976ebca54a388d5ed4b3'
7
- data.tar.gz: b7defaa51d5a72526132d13ac8173b585342826f4b859c3fe79931727a0ab72f9f93a94ce3a8d7c86f825c90cc479a508f4c9342b8655813399a83e34ee05621
6
+ metadata.gz: 4c7c78cb090c2c463565e4bc3459a399aeb0715e4f02d3f55ade5c0041078a791eed9788a21d95515dfb16c75ed35759bd72730471e47061f767b6676a63ab76
7
+ data.tar.gz: 132fface7f9be9e689a4f68c8ab11d5935cff561fdabec9904b5bb2daec5a36fd046091a4a9aa87f9c3bd2a76fd19ef2ca4ecab2ef2f3a2782854978eea219a8
data/lib/posting_zon.rb CHANGED
@@ -20,6 +20,7 @@ require 'auto_click'
20
20
  require 'rainbow/refinement'
21
21
  require 'watir'
22
22
  require 'timeout'
23
+ require 'win32ole'
23
24
  include AutoClickMethods
24
25
  using Rainbow
25
26
 
@@ -51,16 +52,17 @@ class Naver
51
52
  end
52
53
 
53
54
 
54
- def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
55
+ def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
55
56
  board_cookie_dir = "C:/board_cookie"
56
57
  FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
57
58
 
58
- if proxy == ''
59
- 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})
60
- else
61
- 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})
62
- end
63
- end
59
+ if proxy == ''
60
+ 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})
61
+ else
62
+ 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})
63
+ end
64
+ end
65
+
64
66
 
65
67
 
66
68
 
@@ -85,17 +87,14 @@ class Naver
85
87
 
86
88
  options.add_argument('--disable-save-password-bubble') # 비밀번호 저장 팝업 비활성화
87
89
  options.add_argument('--disable-password-manager') # 비밀번호 관리 비활성화
88
-
89
-
90
+
90
91
  options.add_argument('--disable-web-security') # 웹 보안 비활성화
91
92
  options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
92
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
93
93
  options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
94
94
  options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
95
95
  options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
96
96
  options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
97
97
 
98
-
99
98
  # 'capabilities'과 'options' 배열로 설정
100
99
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
101
100
  capabilities["goog:chromeOptions"] = options.as_json
@@ -126,16 +125,17 @@ class Naver
126
125
  options.add_argument('--remote-debugging-port=9222')
127
126
  options.add_argument('user-data-dir=C:/board_cookie')
128
127
 
128
+
129
+ options.add_argument('--disable-save-password-bubble') # 비밀번호 저장 팝업 비활성화
130
+ options.add_argument('--disable-password-manager') # 비밀번호 관리 비활성화
131
+
129
132
  options.add_argument('--disable-web-security') # 웹 보안 비활성화
130
133
  options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
131
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
132
134
  options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
133
135
  options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
134
136
  options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
135
137
  options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
136
138
 
137
-
138
-
139
139
  # 'capabilities'과 'options' 배열로 설정
140
140
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
141
141
  capabilities["goog:chromeOptions"] = options.as_json
@@ -163,16 +163,16 @@ class Naver
163
163
  options.add_argument('--remote-debugging-port=9222')
164
164
  options.add_argument('user-data-dir=C:/board_cookie')
165
165
 
166
+ options.add_argument('--disable-save-password-bubble') # 비밀번호 저장 팝업 비활성화
167
+ options.add_argument('--disable-password-manager') # 비밀번호 관리 비활성화
168
+
166
169
  options.add_argument('--disable-web-security') # 웹 보안 비활성화
167
170
  options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
168
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
169
171
  options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
170
172
  options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
171
173
  options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
172
174
  options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
173
-
174
-
175
-
175
+
176
176
 
177
177
  # 'capabilities'과 'options' 배열로 설정
178
178
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -211,169 +211,268 @@ class Naver
211
211
 
212
212
  chrome_start(proxy, board_cookie_dir)
213
213
 
214
- # 열린 모든 탭 핸들 확인
215
- all_windows = @driver.window_handles
216
- #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
217
-
218
- # 원하는 URL
219
- target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
220
-
221
- # 각 탭을 순회하면서
222
- all_windows.each do |window|
223
- @driver.switch_to.window(window)
224
- current_url = @driver.current_url
225
- #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
226
-
227
- # 원하는 URL이 아니면 탭을 닫기
228
- if current_url != target_url
229
- begin
230
- @driver.close # 다른 탭을 닫기
231
- rescue Selenium::WebDriver::Error::WebDriverError => e
232
- #puts "탭을 닫는 데 오류 발생: #{e.message}"
233
- end
234
- end
235
- end
236
-
237
- # 남아 있는 탭으로 전환
238
- all_windows = @driver.window_handles # 남은 탭 리스트 갱신
239
- if all_windows.size > 0
240
- @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
241
- else
242
- #puts "남은 탭이 없습니다."
243
- end
244
-
245
-
214
+ # 열린 모든 탭 핸들 확인
215
+ all_windows = @driver.window_handles
216
+ #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
217
+
218
+ # 원하는 URL
219
+ target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
220
+
221
+ # 각 탭을 순회하면서
222
+ all_windows.each do |window|
223
+ @driver.switch_to.window(window)
224
+ current_url = @driver.current_url
225
+ #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
246
226
 
247
- @driver.manage.window.maximize
248
- sleep(1)
249
- begin
250
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
251
- wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
252
- check_cookie_login = 1
253
- puts'[Step.01] CAPTCHA 세션 및 브라우저 설정 완료 상태 확인!!.......'.yellow
254
- rescue
255
- begin
256
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
257
- wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
258
- sleep(1.5)
259
- @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
260
- puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.yellow
261
- puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.yellow
262
- sleep(1.5)
263
- mouse_move_percentage(0.3,0.02)
264
- sleep(0.5)
265
- left_click
266
- sleep(1)
267
- key_stroke('tab')
268
- sleep(0.5)
269
- key_stroke('enter')
270
- check_cookie_login = 0
271
- sleep(1)
272
- rescue
273
- @driver.quit
274
- return 0
275
- end
276
- end
227
+ # 원하는 URL이 아니면 탭을 닫기
228
+ if current_url != target_url
229
+ begin
230
+ @driver.close # 다른 탭을 닫기
231
+ rescue Selenium::WebDriver::Error::WebDriverError => e
232
+ #puts "탭을 닫는 데 오류 발생: #{e.message}"
233
+ end
234
+ end
235
+ end
277
236
 
278
- if check_cookie_login == 0
279
- sleep(10)
280
- begin
237
+ # 남아 있는 탭으로 전환
238
+ all_windows = @driver.window_handles # 남은 탭 리스트 갱신
239
+ if all_windows.size > 0
240
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
241
+ else
242
+ #puts "남은 탭이 없습니다."
243
+ end
281
244
 
282
- begin
283
- # 열린 모든 탭 핸들 확인
284
- all_windows = @driver.window_handles
285
- puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
286
-
287
- # 각 탭을 순회하면서
288
- all_windows.each do |window|
289
- @driver.switch_to.window(window)
290
- current_url = @driver.current_url
291
- puts "탭 URL: #{current_url}" # 각 탭 URL 출력
292
-
293
- # 확장 프로그램 탭인지 확인
294
- if current_url.include?('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
295
- begin
296
- @driver.close # 확장 프로그램 탭을 닫기
297
-
298
- rescue Selenium::WebDriver::Error::WebDriverError => e
299
- end
300
- else
301
- end
302
- end
303
-
304
- # 남아 있는 탭으로 전환
305
- all_windows = @driver.window_handles # 남은 탭 리스트 갱신
306
- if all_windows.size > 0
307
- @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
308
- else
309
- end
310
-
311
- sleep(1)
312
-
313
- rescue => e
314
- @driver.quit if @driver
315
- end
316
-
317
245
 
246
+
247
+
248
+ sleep(1)
249
+ begin
250
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
251
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
252
+ check_cookie_login = 1
253
+ puts'[Step.01] CAPTCHA 세션 및 브라우저 설정 완료 상태 확인!!.......'.yellow
254
+ rescue
255
+ begin
256
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
257
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
258
+ sleep(1.5)
259
+ @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
260
+ puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.red
261
+ puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.red
262
+ sleep(1.5)
263
+ shell = WIN32OLE.new('WScript.Shell')
264
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
265
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
266
+ sleep(1)
267
+ shell.SendKeys("{TAB}")
268
+ sleep(0.5)
269
+ shell.SendKeys("{ENTER}")
270
+
271
+ check_cookie_login = 0
272
+ sleep(1)
273
+ rescue
274
+ @driver.quit
275
+ return 0
276
+ end
277
+ end
278
+
279
+ if check_cookie_login == 0
280
+
281
+ begin
318
282
 
319
-
320
-
321
- # 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
322
- @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
323
- sleep(1)
324
-
283
+ begin
284
+ # 최대 20초 동안 확장 프로그램 탭이 열릴 때까지 대기
285
+ extension_url = 'chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html'
286
+ max_wait_time = 20
287
+ waited = 0
288
+ found = false
289
+
290
+ while waited < max_wait_time
291
+ all_windows = @driver.window_handles
292
+ all_windows.each do |window|
293
+ @driver.switch_to.window(window)
294
+ current_url = @driver.current_url
295
+ if current_url.include?(extension_url)
296
+ found = true
297
+ break
298
+ end
299
+ end
300
+ break if found
301
+
302
+ sleep(3)
303
+ waited += 1
304
+ end
305
+
306
+ if found
307
+ # 확장 프로그램 탭을 제외한 나머지 탭 닫기
308
+ all_windows = @driver.window_handles
309
+ all_windows.each do |window|
310
+ @driver.switch_to.window(window)
311
+ current_url = @driver.current_url
312
+ if !current_url.include?(extension_url)
313
+ sleep(2)
314
+ @driver.close
315
+ sleep(2)
316
+ end
317
+ end
318
+
319
+ # 확장 프로그램 탭으로 전환
320
+ remaining_windows = @driver.window_handles
321
+ if remaining_windows.size > 0
322
+ @driver.switch_to.window(remaining_windows.first)
323
+ end
324
+ else
325
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
326
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
327
+ end
328
+
329
+ rescue => e
330
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
331
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
332
+ @driver.quit if @driver
333
+ end
334
+
325
335
 
326
-
336
+
327
337
 
328
338
 
329
- begin
330
- puts '-[√] 캡챠 연결 설정 1차 시도.......'.green
331
- # 요소 찾기 타임아웃을 10초로 설정
332
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
333
- #요소가 나타날 때까지 60초 동안 기다립니다.
334
- wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
335
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
339
+ begin
340
+ # 요소 찾기 타임아웃을 10초로 설정
341
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
342
+ #요소가 나타날 때까지 60초 동안 기다립니다.
343
+ wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
344
+ @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
345
+ sleep(1)
346
+ Clipboard.copy(captcha_key)
347
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
348
+ sleep(1)
349
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
350
+ sleep(1)
351
+
352
+ begin
353
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
354
+ wait.until do
355
+ begin
356
+ alert = @driver.switch_to.alert
357
+ alert.accept
358
+ sleep(1)
359
+ true
360
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
361
+ false
362
+ end
363
+ end
364
+ rescue Selenium::WebDriver::Error::TimeoutError
365
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
366
+ begin
367
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
368
+ wait.until do
369
+ begin
370
+ alert = @driver.switch_to.alert
371
+ alert.accept
372
+ sleep(1)
373
+ true
374
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
375
+ false
376
+ end
377
+ end
378
+ rescue Selenium::WebDriver::Error::TimeoutError
379
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
380
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
381
+ system('taskkill /F /IM chrome.exe')
382
+ @driver.quit if @driver
383
+ end
384
+ end
385
+ puts '-[√] 브라우저 필요 설정 1차 시도.......'.green
386
+ @driver.get('chrome://settings/security')
387
+ sleep(2)
388
+ mouse_move_percentage(0.3,0.02)
389
+ sleep(0.5)
390
+ left_click
336
391
  sleep(1)
337
- Clipboard.copy(captcha_key)
338
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
392
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
393
+ 7.times do
394
+ key_stroke('tab') # 'tab' 키를 입력
395
+ sleep(0.5) # 0.5초 대기
396
+ end
397
+ key_stroke('enter')
339
398
  sleep(1)
340
- @driver.find_element(:xpath, '//*[@id="connect"]').click
399
+
400
+ @driver.get('chrome://password-manager/settings')
401
+ sleep(2)
402
+ mouse_move_percentage(0.3,0.02)
403
+ sleep(0.5)
404
+ left_click
341
405
  sleep(1)
342
-
343
- begin
344
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
345
- wait.until do
346
- begin
347
- alert = @driver.switch_to.alert
348
- alert.accept
349
- sleep(1)
350
- true
351
- rescue Selenium::WebDriver::Error::NoSuchAlertError
352
- false
353
- end
354
- end
355
- rescue Selenium::WebDriver::Error::TimeoutError
356
- puts "alert이 없으므로 버튼 클릭"
357
- @driver.find_element(:xpath, '//*[@id="connect"]').click
358
- begin
359
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
360
- wait.until do
361
- begin
362
- alert = @driver.switch_to.alert
363
- alert.accept
364
- sleep(1)
365
- true
366
- rescue Selenium::WebDriver::Error::NoSuchAlertError
367
- false
368
- end
369
- end
370
- puts "두 번째 alert 처리 완료"
371
- rescue Selenium::WebDriver::Error::TimeoutError
372
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
373
- system('taskkill /F /IM chrome.exe')
374
- @driver.quit if @driver
375
- end
406
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
407
+ 4.times do
408
+ key_stroke('tab') # 'tab' 키를 입력
409
+ sleep(0.5) # 0.5초 대기
376
410
  end
411
+ key_stroke('enter')
412
+ sleep(1)
413
+ key_stroke('tab')
414
+ sleep(1)
415
+ key_stroke('enter')
416
+ sleep(1)
417
+
418
+ rescue
419
+ begin
420
+ sleep(1)
421
+
422
+ # 요소 찾기 타임아웃을 10초로 설정
423
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
424
+ #요소가 나타날 때까지 60초 동안 기다립니다.
425
+ wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
426
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
427
+ sleep(1)
428
+ begin
429
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
430
+ rescue
431
+ end
432
+
433
+ Clipboard.copy(captcha_key)
434
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
435
+ sleep(1)
436
+ begin
437
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
438
+ sleep(1)
439
+
440
+ begin
441
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
442
+ wait.until do
443
+ begin
444
+ alert = @driver.switch_to.alert
445
+ alert.accept
446
+ sleep(1)
447
+ true
448
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
449
+ false
450
+ end
451
+ end
452
+ rescue Selenium::WebDriver::Error::TimeoutError
453
+
454
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
455
+ begin
456
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
457
+ wait.until do
458
+ begin
459
+ alert = @driver.switch_to.alert
460
+ alert.accept
461
+ sleep(1)
462
+ true
463
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
464
+ false
465
+ end
466
+ end
467
+
468
+ rescue Selenium::WebDriver::Error::TimeoutError
469
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
470
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
471
+ system('taskkill /F /IM chrome.exe')
472
+ @driver.quit if @driver
473
+ end
474
+ end
475
+
377
476
  puts '-[√] 브라우저 필요 설정 1차 시도.......'.green
378
477
  @driver.get('chrome://settings/security')
379
478
  sleep(2)
@@ -396,183 +495,103 @@ class Naver
396
495
  left_click
397
496
  sleep(1)
398
497
  # 루비에서 'tab' 키를 0.5초마다 7번 누르기
399
- 3.times do
498
+ 4.times do
400
499
  key_stroke('tab') # 'tab' 키를 입력
401
500
  sleep(0.5) # 0.5초 대기
402
501
  end
403
502
  key_stroke('enter')
404
- sleep(1)
405
-
406
- rescue
407
- begin
408
- puts '-[√] 캡챠 연결 설정 2차 시도.......'.green
409
- sleep(1)
410
- #@driver.switch_to.window(@driver.window_handles[0])
411
-
412
-
413
- # 요소 찾기 타임아웃을 10초로 설정
414
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
415
- #요소가 나타날 때까지 60초 동안 기다립니다.
416
- wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
417
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
418
- sleep(1)
419
- begin
420
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
421
- rescue
422
-
423
- puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
424
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
425
-
426
- end
427
-
428
- Clipboard.copy(captcha_key)
429
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
430
- sleep(1)
431
- begin
432
- @driver.find_element(:xpath, '//*[@class="default-btn"]').click
433
- sleep(1)
434
-
435
- begin
436
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
437
- wait.until do
438
- begin
439
- alert = @driver.switch_to.alert
440
- alert.accept
441
- sleep(1)
442
- true
443
- rescue Selenium::WebDriver::Error::NoSuchAlertError
444
- false
445
- end
446
- end
447
- rescue Selenium::WebDriver::Error::TimeoutError
448
- puts "alert이 없으므로 버튼 클릭"
449
- @driver.find_element(:xpath, '//*[@class="default-btn"]').click
450
- begin
451
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
452
- wait.until do
453
- begin
454
- alert = @driver.switch_to.alert
455
- alert.accept
456
- sleep(1)
457
- true
458
- rescue Selenium::WebDriver::Error::NoSuchAlertError
459
- false
460
- end
461
- end
462
- puts "두 번째 alert 처리 완료"
463
- rescue Selenium::WebDriver::Error::TimeoutError
464
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
465
- system('taskkill /F /IM chrome.exe')
466
- @driver.quit if @driver
467
- end
468
- end
469
-
470
- rescue => e
471
- @driver.window_handles.each do |handle|
472
- @driver.switch_to.window(handle)
473
- begin
474
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
475
- @driver.close
476
- rescue Selenium::WebDriver::Error::WebDriverError => e
477
- puts "크롬 브라우저 종료: #{e.message}"
478
- end
479
- end
480
- return 0
481
- @driver.quit
482
- end
483
- puts '-[√] 브라우저 필요 설정 2차 시도.......'.green
484
- @driver.get('chrome://settings/security')
485
- sleep(2)
486
- mouse_move_percentage(0.3,0.02)
487
- sleep(0.5)
488
- left_click
489
- sleep(1)
490
- # 루비에서 'tab' 키를 0.5초마다 7번 누르기
491
- 6.times do
492
- key_stroke('tab') # 'tab' 키를 입력
493
- sleep(0.5) # 0.5초 대기
494
- end
495
- key_stroke('enter')
496
- sleep(1)
497
-
498
- @driver.get('chrome://password-manager/settings')
499
- sleep(2)
500
- mouse_move_percentage(0.3,0.02)
501
- sleep(0.5)
502
- left_click
503
- sleep(1)
504
- # 루비에서 'tab' 키를 0.5초마다 7번 누르기
505
- 3.times do
506
- key_stroke('tab') # 'tab' 키를 입력
507
- sleep(0.5) # 0.5초 대기
508
- end
509
- key_stroke('enter')
510
- sleep(1)
511
-
512
- rescue => e
513
- puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
514
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
515
- @driver.window_handles.each do |handle|
516
- @driver.switch_to.window(handle)
517
- begin
518
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
519
- @driver.close
520
- rescue Selenium::WebDriver::Error::WebDriverError => e
521
- puts "크롬 브라우저 종료: #{e.message}"
522
- end
523
- end
524
- return 0
525
- @driver.quit
526
- end
527
-
528
- end
529
-
530
- rescue => e
531
- puts '-[√] 로딩 지연 접속 실패.......'.red
532
- @driver.window_handles.each do |handle|
533
- @driver.switch_to.window(handle)
534
- begin
535
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
536
- @driver.close
537
- rescue Selenium::WebDriver::Error::WebDriverError => e
538
- puts "Failed to close tab: #{e.message}"
539
- end
540
- end
541
- @driver.quit
542
- return 0
543
- end
544
-
545
- else
546
- # @driver.switch_to.default_content
547
- end
503
+ sleep(1)
504
+ key_stroke('tab')
505
+ sleep(1)
506
+ key_stroke('enter')
507
+ sleep(1)
548
508
 
549
- begin
509
+ rescue => e
510
+ @driver.window_handles.each do |handle|
511
+ @driver.switch_to.window(handle)
512
+ begin
513
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
514
+ @driver.close
515
+ rescue Selenium::WebDriver::Error::WebDriverError => e
516
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
517
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
518
+ end
519
+ end
520
+ return 0
521
+ @driver.quit
522
+ end
523
+
524
+
525
+ rescue => e
526
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
527
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
528
+ @driver.window_handles.each do |handle|
529
+ @driver.switch_to.window(handle)
530
+ begin
531
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
532
+ @driver.close
533
+ rescue Selenium::WebDriver::Error::WebDriverError => e
534
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
535
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
536
+ end
537
+ end
538
+ return 0
539
+ @driver.quit
540
+ end
541
+
542
+ end
550
543
 
544
+ rescue => e
545
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
546
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
547
+ @driver.window_handles.each do |handle|
548
+ @driver.switch_to.window(handle)
549
+ begin
550
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
551
+ @driver.close
552
+ rescue Selenium::WebDriver::Error::WebDriverError => e
553
+ puts "Failed to close tab: #{e.message}"
554
+ end
555
+ end
556
+ @driver.quit
557
+ return 0
558
+ end
551
559
 
560
+
561
+
562
+ else
563
+ # @driver.switch_to.default_content
564
+ end
552
565
 
553
- @driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
554
-
555
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
556
- #요소가 나타날 때까지 3초 동안 기다립니다.
557
- wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
566
+ begin
567
+
568
+
569
+
570
+ @driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
571
+ sleep(1)
572
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
573
+ #요소가 나타날 때까지 3초 동안 기다립니다.
574
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
575
+ sleep(1)
576
+ @driver.manage.window.maximize
577
+
578
+ rescue => e
579
+ puts '-[√] 연결 실패.......'.red
580
+ @driver.window_handles.each do |handle|
581
+ @driver.switch_to.window(handle)
582
+ begin
583
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
584
+ @driver.close
585
+ rescue Selenium::WebDriver::Error::WebDriverError => e
586
+ puts "Failed to close tab: #{e.message}"
587
+ end
588
+ end
589
+ @driver.quit
590
+ return 0
591
+ end
592
+ end
558
593
 
559
-
560
594
 
561
- rescue => e
562
- puts '-[√] 로그인 실패.......'.red
563
- @driver.window_handles.each do |handle|
564
- @driver.switch_to.window(handle)
565
- begin
566
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
567
- @driver.close
568
- rescue Selenium::WebDriver::Error::WebDriverError => e
569
- puts "Failed to close tab: #{e.message}"
570
- end
571
- end
572
- @driver.quit
573
- return 0
574
- end
575
- end
576
595
 
577
596
 
578
597
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posting_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.137
4
+ version: 0.0.173
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-07 00:00:00.000000000 Z
11
+ date: 2025-04-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: posting app
14
14
  email: mymin26@naver.com