posting_zon 0.0.137 → 0.0.170
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.
- checksums.yaml +4 -4
- data/lib/posting_zon.rb +318 -364
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9adb2546a6d6ad09ddd5af2db7931311677d11e20ce8f4eb07d23e86e67c82ec
|
4
|
+
data.tar.gz: ca3ebb4c79b7ff56f073fd1ccea29f0dad1056d15d572b0fddbf22d5ad33b045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cefcc222df0379cdffb9b01805934048c62724f83f417f5989d43211a54debbf47e3ff1f738e19a9135327e519cb5cf7a072528da0b200903df2faf0f297718
|
7
|
+
data.tar.gz: 99bc126302fab004c083ec4f0883edf949411083caa5e058461327df4b1ff8ec85d536f2c98264d34b4588f0d7ef7f71ad46a042b40eac03ed54fd0a8fb5dba7
|
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
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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,368 +211,322 @@ class Naver
|
|
211
211
|
|
212
212
|
chrome_start(proxy, board_cookie_dir)
|
213
213
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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
236
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
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
244
|
|
245
245
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
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
|
277
278
|
|
278
|
-
|
279
|
-
|
280
|
-
|
279
|
+
if check_cookie_login == 0
|
280
|
+
|
281
|
+
begin
|
281
282
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
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
|
+
|
317
335
|
|
336
|
+
|
318
337
|
|
319
|
-
|
320
|
-
|
321
|
-
# 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
|
322
|
-
@driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
|
323
|
-
sleep(1)
|
324
|
-
|
325
338
|
|
326
|
-
|
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
|
+
|
386
|
+
|
387
|
+
rescue
|
388
|
+
begin
|
389
|
+
sleep(1)
|
390
|
+
|
391
|
+
# 요소 찾기 타임아웃을 10초로 설정
|
392
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
393
|
+
#요소가 나타날 때까지 60초 동안 기다립니다.
|
394
|
+
wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
|
395
|
+
@driver.find_element(:xpath, '//*[@name="apiKey"]').click
|
396
|
+
sleep(1)
|
397
|
+
begin
|
398
|
+
@driver.find_element(:xpath, '//*[@name="apiKey"]').click
|
399
|
+
rescue
|
400
|
+
end
|
401
|
+
|
402
|
+
Clipboard.copy(captcha_key)
|
403
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
404
|
+
sleep(1)
|
405
|
+
begin
|
406
|
+
@driver.find_element(:xpath, '//*[@class="default-btn"]').click
|
407
|
+
sleep(1)
|
408
|
+
|
409
|
+
begin
|
410
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
411
|
+
wait.until do
|
412
|
+
begin
|
413
|
+
alert = @driver.switch_to.alert
|
414
|
+
alert.accept
|
415
|
+
sleep(1)
|
416
|
+
true
|
417
|
+
rescue Selenium::WebDriver::Error::NoSuchAlertError
|
418
|
+
false
|
419
|
+
end
|
420
|
+
end
|
421
|
+
rescue Selenium::WebDriver::Error::TimeoutError
|
422
|
+
|
423
|
+
@driver.find_element(:xpath, '//*[@class="default-btn"]').click
|
424
|
+
begin
|
425
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
426
|
+
wait.until do
|
427
|
+
begin
|
428
|
+
alert = @driver.switch_to.alert
|
429
|
+
alert.accept
|
430
|
+
sleep(1)
|
431
|
+
true
|
432
|
+
rescue Selenium::WebDriver::Error::NoSuchAlertError
|
433
|
+
false
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
rescue Selenium::WebDriver::Error::TimeoutError
|
438
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
439
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
440
|
+
system('taskkill /F /IM chrome.exe')
|
441
|
+
@driver.quit if @driver
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
rescue => e
|
446
|
+
@driver.window_handles.each do |handle|
|
447
|
+
@driver.switch_to.window(handle)
|
448
|
+
begin
|
449
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
450
|
+
@driver.close
|
451
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
452
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
453
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
454
|
+
end
|
455
|
+
end
|
456
|
+
return 0
|
457
|
+
@driver.quit
|
458
|
+
end
|
459
|
+
|
460
|
+
|
461
|
+
rescue => e
|
462
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
463
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
464
|
+
@driver.window_handles.each do |handle|
|
465
|
+
@driver.switch_to.window(handle)
|
466
|
+
begin
|
467
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
468
|
+
@driver.close
|
469
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
470
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
471
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
472
|
+
end
|
473
|
+
end
|
474
|
+
return 0
|
475
|
+
@driver.quit
|
476
|
+
end
|
477
|
+
|
478
|
+
end
|
327
479
|
|
480
|
+
rescue => e
|
481
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
482
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
483
|
+
@driver.window_handles.each do |handle|
|
484
|
+
@driver.switch_to.window(handle)
|
485
|
+
begin
|
486
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
487
|
+
@driver.close
|
488
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
489
|
+
puts "Failed to close tab: #{e.message}"
|
490
|
+
end
|
491
|
+
end
|
492
|
+
@driver.quit
|
493
|
+
return 0
|
494
|
+
end
|
328
495
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
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
|
336
|
-
sleep(1)
|
337
|
-
Clipboard.copy(captcha_key)
|
338
|
-
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
339
|
-
sleep(1)
|
340
|
-
@driver.find_element(:xpath, '//*[@id="connect"]').click
|
341
|
-
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
|
376
|
-
end
|
377
|
-
puts '-[√] 브라우저 필요 설정 1차 시도.......'.green
|
378
|
-
@driver.get('chrome://settings/security')
|
379
|
-
sleep(2)
|
380
|
-
mouse_move_percentage(0.3,0.02)
|
381
|
-
sleep(0.5)
|
382
|
-
left_click
|
383
|
-
sleep(1)
|
384
|
-
# 루비에서 'tab' 키를 0.5초마다 7번 누르기
|
385
|
-
7.times do
|
386
|
-
key_stroke('tab') # 'tab' 키를 입력
|
387
|
-
sleep(0.5) # 0.5초 대기
|
388
|
-
end
|
389
|
-
key_stroke('enter')
|
390
|
-
sleep(1)
|
391
|
-
|
392
|
-
@driver.get('chrome://password-manager/settings')
|
393
|
-
sleep(2)
|
394
|
-
mouse_move_percentage(0.3,0.02)
|
395
|
-
sleep(0.5)
|
396
|
-
left_click
|
397
|
-
sleep(1)
|
398
|
-
# 루비에서 'tab' 키를 0.5초마다 7번 누르기
|
399
|
-
3.times do
|
400
|
-
key_stroke('tab') # 'tab' 키를 입력
|
401
|
-
sleep(0.5) # 0.5초 대기
|
402
|
-
end
|
403
|
-
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
|
496
|
+
|
497
|
+
|
498
|
+
else
|
499
|
+
# @driver.switch_to.default_content
|
500
|
+
end
|
548
501
|
|
549
|
-
|
502
|
+
begin
|
550
503
|
|
551
504
|
|
552
505
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
506
|
+
@driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
|
507
|
+
sleep(1)
|
508
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
509
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
510
|
+
wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
|
511
|
+
sleep(1)
|
512
|
+
@driver.manage.window.maximize
|
558
513
|
|
559
|
-
|
514
|
+
rescue => e
|
515
|
+
puts '-[√] 연결 실패.......'.red
|
516
|
+
@driver.window_handles.each do |handle|
|
517
|
+
@driver.switch_to.window(handle)
|
518
|
+
begin
|
519
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
520
|
+
@driver.close
|
521
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
522
|
+
puts "Failed to close tab: #{e.message}"
|
523
|
+
end
|
524
|
+
end
|
525
|
+
@driver.quit
|
526
|
+
return 0
|
527
|
+
end
|
528
|
+
end
|
560
529
|
|
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
530
|
|
577
531
|
|
578
532
|
|
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.
|
4
|
+
version: 0.0.170
|
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-
|
11
|
+
date: 2025-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: posting app
|
14
14
|
email: mymin26@naver.com
|