duo_board_crawling 0.0.1 → 0.0.3

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/duo_board_crawling.rb +283 -94
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0221039c415553029e3a0a2c40138e9a5a593fafc4ebdf47ce12578b4880bb45'
4
- data.tar.gz: 26d593172800b66bb14125ad634104ef3e96278635306c3dd967bccd6419f600
3
+ metadata.gz: 904a9527fdf6cb0b691e10ce4486ac6b8bbc3a6f0d7f73080591405f53942b2d
4
+ data.tar.gz: 105d441ac41b402809b64e75446633fb43226b2931c7c670d1129ca70a9ed15e
5
5
  SHA512:
6
- metadata.gz: 27d170119e512bf954688270498901fac5bddaa4115f942871168f053e2d20f1e7d9fd88a031a2c1a6a99756fc8d925f451e7fd784fe5bec9d548fc2f906f568
7
- data.tar.gz: 11ee098566a76d472ccef1c83eee371c6e4e3bf0bec459cc2a72f7d588675360fed2f1e6dcf9017767626bb2e63a59f9362111a0f4a57245bb3f935669bdd6b2
6
+ metadata.gz: 03baa99afce7df4a4acc96baa636e329e0d1cd13708605c22b93dc33fb98d8ed44b4b805d300f6a5d673070464c82158392e0d8b137828c700417df9cfdfbbab
7
+ data.tar.gz: 35b4ce364536ee9b789b398c22b6b98566dad7de0864dd7e54ec32c11da42cef551054c9c16869628eaa5abe39b559ecb5fe4552dd653615ce55b8663cf377b9
@@ -1,31 +1,24 @@
1
1
  require 'glimmer-dsl-libui'
2
2
  require 'selenium-webdriver'
3
3
  require 'webdrivers'
4
- require 'iconv'
5
- require 'nokogiri'
6
- require 'open-uri'
7
4
  require 'http'
8
5
  require 'json'
9
- require 'down'
10
- require 'rmagick'
11
- require 'fileutils'
12
- require 'rest-client'
13
6
  require 'open3'
14
- require 'clipboard'
15
- require 'crack'
7
+ require 'nokogiri'
8
+ require 'open-uri'
9
+ require 'fileutils'
16
10
  require 'uri'
17
- require 'cgi'
18
- require 'digest'
19
- require 'auto_click'
20
11
  require 'rainbow/refinement'
21
12
  require 'watir'
13
+ require 'clipboard'
22
14
  require 'timeout'
23
- include AutoClickMethods
15
+ require 'win32ole'
24
16
  using Rainbow
25
17
 
26
18
 
27
19
 
28
20
 
21
+
29
22
  class Naver
30
23
  def initialize
31
24
 
@@ -230,16 +223,17 @@ class Naver
230
223
  wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
231
224
  sleep(1.5)
232
225
  @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
233
- puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.yellow
234
- puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.yellow
226
+ puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.red
227
+ puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.red
235
228
  sleep(1.5)
236
- mouse_move_percentage(0.3,0.02)
237
- sleep(0.5)
238
- left_click
229
+ shell = WIN32OLE.new('WScript.Shell')
230
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
231
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
239
232
  sleep(1)
240
- key_stroke('tab')
233
+ shell.SendKeys("{TAB}")
241
234
  sleep(0.5)
242
- key_stroke('enter')
235
+ shell.SendKeys("{ENTER}")
236
+
243
237
  check_cookie_login = 0
244
238
  sleep(1)
245
239
  rescue
@@ -249,58 +243,66 @@ class Naver
249
243
  end
250
244
 
251
245
  if check_cookie_login == 0
252
- sleep(10)
246
+
253
247
  begin
254
248
 
255
249
  begin
256
- # 열린 모든 핸들 확인
257
- all_windows = @driver.window_handles
258
- puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
259
-
260
- # 탭을 순회하면서
261
- all_windows.each do |window|
262
- @driver.switch_to.window(window)
263
- current_url = @driver.current_url
264
- puts "탭 URL: #{current_url}" # 각 탭 URL 출력
265
-
266
- # 확장 프로그램 탭인지 확인
267
- if current_url.include?('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
268
- begin
269
- @driver.close # 확장 프로그램 탭을 닫기
270
-
271
- rescue Selenium::WebDriver::Error::WebDriverError => e
250
+ # 최대 20초 동안 확장 프로그램 탭이 열릴 때까지 대기
251
+ extension_url = 'chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html'
252
+ max_wait_time = 20
253
+ waited = 0
254
+ found = false
255
+
256
+ while waited < max_wait_time
257
+ all_windows = @driver.window_handles
258
+ all_windows.each do |window|
259
+ @driver.switch_to.window(window)
260
+ current_url = @driver.current_url
261
+ if current_url.include?(extension_url)
262
+ found = true
263
+ break
272
264
  end
273
- else
274
265
  end
275
- end
276
-
277
- # 남아 있는 탭으로 전환
278
- all_windows = @driver.window_handles # 남은 탭 리스트 갱신
279
- if all_windows.size > 0
280
- @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
281
- else
266
+ break if found
267
+
268
+ sleep(3)
269
+ waited += 1
282
270
  end
283
271
 
284
- sleep(1)
272
+ if found
273
+ # 확장 프로그램 탭을 제외한 나머지 탭 닫기
274
+ all_windows = @driver.window_handles
275
+ all_windows.each do |window|
276
+ @driver.switch_to.window(window)
277
+ current_url = @driver.current_url
278
+ if !current_url.include?(extension_url)
279
+ sleep(2)
280
+ @driver.close
281
+ sleep(2)
282
+ end
283
+ end
284
+
285
+ # 확장 프로그램 탭으로 전환
286
+ remaining_windows = @driver.window_handles
287
+ if remaining_windows.size > 0
288
+ @driver.switch_to.window(remaining_windows.first)
289
+ end
290
+ else
291
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
292
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
293
+ end
285
294
 
286
295
  rescue => e
296
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
297
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
287
298
  @driver.quit if @driver
288
299
  end
289
300
 
290
301
 
291
-
292
-
293
-
294
- # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
295
- @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
296
- sleep(1)
297
-
298
-
299
302
 
300
303
 
301
304
 
302
305
  begin
303
- puts '-[√] 캡챠 연결 설정 1차 시도.......'.green
304
306
  # 요소 찾기 타임아웃을 10초로 설정
305
307
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
306
308
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -326,7 +328,6 @@ class Naver
326
328
  end
327
329
  end
328
330
  rescue Selenium::WebDriver::Error::TimeoutError
329
- puts "alert이 없으므로 버튼 클릭"
330
331
  @driver.find_element(:xpath, '//*[@id="connect"]').click
331
332
  begin
332
333
  wait = Selenium::WebDriver::Wait.new(:timeout => 10)
@@ -340,9 +341,9 @@ class Naver
340
341
  false
341
342
  end
342
343
  end
343
- puts "두 번째 alert 처리 완료"
344
344
  rescue Selenium::WebDriver::Error::TimeoutError
345
- puts " 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
345
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
346
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
346
347
  system('taskkill /F /IM chrome.exe')
347
348
  @driver.quit if @driver
348
349
  end
@@ -351,11 +352,8 @@ class Naver
351
352
 
352
353
  rescue
353
354
  begin
354
- puts '-[√] 캡챠 연결 설정 2차 시도.......'.green
355
355
  sleep(1)
356
- #@driver.switch_to.window(@driver.window_handles[0])
357
-
358
-
356
+
359
357
  # 요소 찾기 타임아웃을 10초로 설정
360
358
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
361
359
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -365,10 +363,6 @@ class Naver
365
363
  begin
366
364
  @driver.find_element(:xpath, '//*[@name="apiKey"]').click
367
365
  rescue
368
-
369
- puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
370
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
371
-
372
366
  end
373
367
 
374
368
  Clipboard.copy(captcha_key)
@@ -391,7 +385,7 @@ class Naver
391
385
  end
392
386
  end
393
387
  rescue Selenium::WebDriver::Error::TimeoutError
394
- puts "alert이 없으므로 버튼 클릭"
388
+
395
389
  @driver.find_element(:xpath, '//*[@class="default-btn"]').click
396
390
  begin
397
391
  wait = Selenium::WebDriver::Wait.new(:timeout => 10)
@@ -405,9 +399,10 @@ class Naver
405
399
  false
406
400
  end
407
401
  end
408
- puts "두 번째 alert 처리 완료"
402
+
409
403
  rescue Selenium::WebDriver::Error::TimeoutError
410
- puts " 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
404
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
405
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
411
406
  system('taskkill /F /IM chrome.exe')
412
407
  @driver.quit if @driver
413
408
  end
@@ -420,7 +415,8 @@ class Naver
420
415
  # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
421
416
  @driver.close
422
417
  rescue Selenium::WebDriver::Error::WebDriverError => e
423
- puts "크롬 브라우저 종료: #{e.message}"
418
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
419
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
424
420
  end
425
421
  end
426
422
  return 0
@@ -429,15 +425,16 @@ class Naver
429
425
 
430
426
 
431
427
  rescue => e
432
- puts '-[√] 로딩 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
433
- puts '-[√] 다음 작업 준비로 1초~60초 내외 시간이 소요됩니다.......'.red
428
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
429
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 다시 시작해주세요.".red
434
430
  @driver.window_handles.each do |handle|
435
431
  @driver.switch_to.window(handle)
436
432
  begin
437
433
  # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
438
434
  @driver.close
439
435
  rescue Selenium::WebDriver::Error::WebDriverError => e
440
- puts "크롬 브라우저 종료: #{e.message}"
436
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
437
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
441
438
  end
442
439
  end
443
440
  return 0
@@ -447,7 +444,8 @@ class Naver
447
444
  end
448
445
 
449
446
  rescue => e
450
- puts '-[√] 로딩 지연 접속 실패.......'.red
447
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
448
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
451
449
  @driver.window_handles.each do |handle|
452
450
  @driver.switch_to.window(handle)
453
451
  begin
@@ -460,6 +458,86 @@ class Naver
460
458
  @driver.quit
461
459
  return 0
462
460
  end
461
+
462
+ begin
463
+ @driver.get('https://chromewebstore.google.com/detail/%EC%9B%B9-%ED%94%84%EB%A1%9D%EC%8B%9C/lcbpobjekkgofogdbjjhgefgmmncfada')
464
+ sleep(1)
465
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
466
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
467
+ sleep(1.5)
468
+ @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
469
+ sleep(1.5)
470
+ shell = WIN32OLE.new('WScript.Shell')
471
+ begin
472
+ # 첫 번째 창 이름 시도
473
+ shell.AppActivate("웹 프록시 - Chrome 웹 스토어")
474
+ shell.AppActivate("웹 프록시 - Chrome 웹 스토어")
475
+ rescue
476
+ # 첫 번째 창이 없으면 두 번째 창 이름으로 시도
477
+ shell.AppActivate("Web proxy")
478
+ shell.AppActivate("Web proxy")
479
+ end
480
+ sleep(1)
481
+ shell.SendKeys("{TAB}")
482
+ sleep(0.5)
483
+ # Enter 키 입력
484
+ shell.SendKeys("{ENTER}")
485
+
486
+
487
+
488
+
489
+
490
+ begin
491
+ target_url = 'https://extaddon.site/web-proxy/chrome/'
492
+ max_wait_time = 20
493
+ waited = 0
494
+ target_window = nil
495
+
496
+ # 최대 20초 대기
497
+ while waited < max_wait_time
498
+ all_windows = @driver.window_handles
499
+ all_windows.each do |window|
500
+ @driver.switch_to.window(window)
501
+ current_url = @driver.current_url
502
+ if current_url.include?(target_url)
503
+ target_window = window
504
+ break
505
+ end
506
+ end
507
+ break if target_window
508
+
509
+ sleep(3)
510
+ waited += 1
511
+ end
512
+
513
+ if target_window
514
+ @driver.switch_to.window(target_window)
515
+ sleep(2)
516
+ @driver.close
517
+ sleep(2)
518
+ else
519
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
520
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
521
+ end
522
+
523
+ # 닫은 후 남아있는 탭 중 첫 번째 탭으로 포커스 이동
524
+ remaining_windows = @driver.window_handles
525
+ @driver.switch_to.window(remaining_windows.first) if remaining_windows.any?
526
+
527
+ rescue => e
528
+ puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
529
+ puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
530
+ @driver.quit if @driver
531
+ end
532
+
533
+
534
+ puts "[Step.03] 작업 브라우저가 완벽하게 세팅 되었습니다.".red
535
+ puts "[※Tip!!] 작업 브라우저 세팅은 매번 하지않고 초기에만 진행합니다.".red
536
+
537
+ rescue Selenium::WebDriver::Error::WebDriverError => e
538
+ puts "크롬 브라우저 종료: #{e.message}"
539
+ end
540
+
463
541
 
464
542
  else
465
543
  # @driver.switch_to.default_content
@@ -470,12 +548,18 @@ class Naver
470
548
 
471
549
 
472
550
  @driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
473
-
551
+ sleep(1)
474
552
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
475
553
  #요소가 나타날 때까지 3초 동안 기다립니다.
476
554
  wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
477
555
 
478
-
556
+ sleep(1)
557
+ shell = WIN32OLE.new('WScript.Shell')#크롬창에 타겟주고 확장프로그램 열기
558
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
559
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
560
+ sleep(1)
561
+ shell.SendKeys('^+7')# Ctrl + Shift + 7 단축키 입력 시뮬레이션
562
+ sleep(1)
479
563
 
480
564
  rescue => e
481
565
  puts '-[√] 연결 실패.......'.red
@@ -493,9 +577,10 @@ class Naver
493
577
  end
494
578
  end
495
579
 
580
+
496
581
 
497
582
  sleep(1)
498
- def update(keyword_input, counter, option, captcha_key, sleep_delay)
583
+ def update(keyword_input, counter, option, captcha_key, sleep_delay, proxy_list)
499
584
  puts 'start...'.yellow
500
585
  @keyword_input = keyword_input
501
586
  @counter = counter
@@ -600,7 +685,6 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
600
685
  end
601
686
  # 캡챠 발생시──────────────────────────────────────────────────────────────
602
687
 
603
-
604
688
  # elements를 찾는 xpath 수정: href에 "/bbs/board.php?"가 포함된 링크만 추출
605
689
  elements = @driver.find_elements(xpath: '//div[@class="MjjYud"]//a[contains(@href, "/bbs/board.php?")]')
606
690
  sleep(1)
@@ -650,6 +734,28 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
650
734
  puts "href를 찾을 수 없습니다: #{e.message}".red
651
735
  end
652
736
  end
737
+
738
+
739
+ if option['프록시'] == 'true'
740
+
741
+ shuffled_proxies = proxy_list.shuffle
742
+ proxy_ip = shuffled_proxies.first
743
+ puts "프록시 변경 IP: #{proxy_ip}".green
744
+
745
+ @driver.switch_to.window(@driver.window_handles[1])
746
+ @driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
747
+ sleep(1)
748
+ #Clipboard.copy(proxy_ip)
749
+ @driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
750
+ sleep(0.5)
751
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
752
+ sleep(1)
753
+ @driver.switch_to.window(@driver.window_handles[0])
754
+
755
+ else
756
+ end
757
+
758
+
653
759
  sleep(sleep_delay)
654
760
  # 수집 목표 개수에 도달했으면 종료
655
761
  break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
@@ -812,6 +918,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
812
918
  puts "href를 찾을 수 없습니다: #{e.message}".red
813
919
  end
814
920
  end
921
+
922
+ if option['프록시'] == 'true'
923
+
924
+ shuffled_proxies = proxy_list.shuffle
925
+ proxy_ip = shuffled_proxies.first
926
+ puts "프록시 변경 IP: #{proxy_ip}".green
927
+
928
+ @driver.switch_to.window(@driver.window_handles[1])
929
+ @driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
930
+ sleep(1)
931
+ #Clipboard.copy(proxy_ip)
932
+ @driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
933
+ sleep(0.5)
934
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
935
+ sleep(1)
936
+ @driver.switch_to.window(@driver.window_handles[0])
937
+
938
+ else
939
+ end
940
+
815
941
  sleep(sleep_delay)
816
942
  # 수집 목표 개수에 도달했으면 종료
817
943
  break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
@@ -985,6 +1111,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
985
1111
  puts "href를 찾을 수 없습니다: #{e.message}".red
986
1112
  end
987
1113
  end
1114
+
1115
+ if option['프록시'] == 'true'
1116
+
1117
+ shuffled_proxies = proxy_list.shuffle
1118
+ proxy_ip = shuffled_proxies.first
1119
+ puts "프록시 변경 IP: #{proxy_ip}".green
1120
+
1121
+ @driver.switch_to.window(@driver.window_handles[1])
1122
+ @driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
1123
+ sleep(1)
1124
+ #Clipboard.copy(proxy_ip)
1125
+ @driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
1126
+ sleep(0.5)
1127
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1128
+ sleep(1)
1129
+ @driver.switch_to.window(@driver.window_handles[0])
1130
+
1131
+ else
1132
+ end
1133
+
988
1134
  sleep(sleep_delay)
989
1135
  # 수집 목표 개수에 도달했으면 종료
990
1136
  break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
@@ -1154,6 +1300,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
1154
1300
  puts "href를 찾을 수 없습니다: #{e.message}".red
1155
1301
  end
1156
1302
  end
1303
+
1304
+ if option['프록시'] == 'true'
1305
+
1306
+ shuffled_proxies = proxy_list.shuffle
1307
+ proxy_ip = shuffled_proxies.first
1308
+ puts "프록시 변경 IP: #{proxy_ip}".green
1309
+
1310
+ @driver.switch_to.window(@driver.window_handles[1])
1311
+ @driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
1312
+ sleep(1)
1313
+ #Clipboard.copy(proxy_ip)
1314
+ @driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
1315
+ sleep(0.5)
1316
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1317
+ sleep(1)
1318
+ @driver.switch_to.window(@driver.window_handles[0])
1319
+
1320
+ else
1321
+ end
1322
+
1157
1323
  sleep(sleep_delay)
1158
1324
  # 수집 목표 개수에 도달했으면 종료
1159
1325
  break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
@@ -1317,6 +1483,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
1317
1483
  puts "href를 찾을 수 없습니다: #{e.message}".red
1318
1484
  end
1319
1485
  end
1486
+
1487
+ if option['프록시'] == 'true'
1488
+
1489
+ shuffled_proxies = proxy_list.shuffle
1490
+ proxy_ip = shuffled_proxies.first
1491
+ puts "프록시 변경 IP: #{proxy_ip}".green
1492
+
1493
+ @driver.switch_to.window(@driver.window_handles[1])
1494
+ @driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
1495
+ sleep(1)
1496
+ #Clipboard.copy(proxy_ip)
1497
+ @driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
1498
+ sleep(0.5)
1499
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1500
+ sleep(1)
1501
+ @driver.switch_to.window(@driver.window_handles[0])
1502
+
1503
+ else
1504
+ end
1505
+
1320
1506
  sleep(sleep_delay)
1321
1507
  # 수집 목표 개수에 도달했으면 종료
1322
1508
  break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
@@ -2743,7 +2929,6 @@ end
2743
2929
  end
2744
2930
 
2745
2931
 
2746
-
2747
2932
  class Wordpress
2748
2933
  include Glimmer
2749
2934
 
@@ -2845,6 +3030,8 @@ class Wordpress
2845
3030
 
2846
3031
 
2847
3032
 
3033
+
3034
+
2848
3035
  def start
2849
3036
  black_users = Array.new
2850
3037
  @my_ip = 'init'
@@ -3053,17 +3240,27 @@ class Wordpress
3053
3240
  option['중복금지'] = 'false'
3054
3241
  end
3055
3242
 
3056
- @data['table'][index][-1] = 30
3243
+ @data['table'][index][-1] = 65
3244
+ @data['table'] << []
3245
+ @data['table'].pop
3246
+
3247
+
3248
+ if @data['포스트설정']['프록시'].checked?
3249
+ option['프록시'] = 'true'
3250
+ proxy_list = @data['포스트설정']['프록시리스트']
3251
+
3252
+ else
3253
+ option['프록시'] = 'false'
3254
+ end
3255
+
3256
+ @data['table'][index][-1] = 65
3057
3257
  @data['table'] << []
3058
3258
  @data['table'].pop
3059
3259
 
3060
- # 옵션 출력 확인
3061
- #p option
3062
-
3063
3260
 
3064
3261
 
3065
3262
  #puts 'start...'
3066
- naver.update(keyword_input, counter, option, captcha_key, sleep_delay)
3263
+ naver.update(keyword_input, counter, option, captcha_key, sleep_delay, proxy_list)
3067
3264
 
3068
3265
  @data['table'][index][3] = @data['table'][index][3].to_i + 1
3069
3266
  @data['table'][index][-1] = 100
@@ -3174,8 +3371,8 @@ class Wordpress
3174
3371
  end
3175
3372
 
3176
3373
  if i.class == Array
3177
- i[4] = i[4].to_i
3178
- i[5] = i[5].to_i
3374
+ i[1] = i[1].to_i
3375
+ #i[5] = i[5].to_i
3179
3376
  @data[key] << i
3180
3377
  @data[key] << i
3181
3378
  @data[key].pop
@@ -3219,14 +3416,6 @@ class Wordpress
3219
3416
  @data['table'].pop
3220
3417
  end
3221
3418
 
3222
- while true
3223
- if @data['키워드설정']['키워드'].length == 0
3224
- break
3225
- end
3226
-
3227
- @data['키워드설정']['키워드'].pop
3228
- end
3229
-
3230
3419
 
3231
3420
 
3232
3421
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duo_board_crawling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
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-08 00:00:00.000000000 Z
11
+ date: 2025-04-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com