posting_duo 3.101.999 → 3.102.999

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 +219 -66
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae4fd84ffdf6c4512dfe76630a84be559b6156f6ff1960540b5a9ecefe9a16cc
4
- data.tar.gz: d95fd450c5d5fec6d3ef96e4259098a3ed3ffcf179da5cac2fb19f2e81a5395f
3
+ metadata.gz: 2c19292517569a61f84a094753f72e65933388db458972fa027ffc4938fd1bc5
4
+ data.tar.gz: bfcb7d95f6a9fbc858305ecb4f4b56bbdd4229a75c1273d669cc8f88f0caa8da
5
5
  SHA512:
6
- metadata.gz: bb037bb48a57d10225d2a10f84f412c89ea19f395b05ac77461a1d5c5bc7e59683302827dc43d002d8d3afa3ea32ec27966b26f4c09e83c8ca02e12fba864099
7
- data.tar.gz: 54ecbe4220fa3fe89ccc434a9084076c8fa4e40626b868f9011c1b0a5851ae7c57af5aec6d08611cebe37bd22861282cce8ad0d6e8c7cd92061f56fca50e15f3
6
+ metadata.gz: 2b1cfd80c03d0d343da034916329ea91aceed2f43e9c483f32bcbe59f9679b30d612e336bf5c42e6f2bc1581754973fd9f9ad74623ada2bf8004af072f16fd7e
7
+ data.tar.gz: 2362dc80236f4f7f0e729e9513718add293c80b53ed902b2ad3bc8dad988f5c7095aac1691bfb6b37b648e51c41720c4bc4d96144842c4ab9efe340186ede5d1
data/lib/posting_duo.rb CHANGED
@@ -29,9 +29,32 @@ using Rainbow
29
29
 
30
30
  class Naver
31
31
  def initialize
32
+ kill_selenium_chrome #기존 창 모두 닫는 명령
33
+ sleep(1)
32
34
  end
35
+
36
+
37
+ def kill_selenium_chrome #기존 창 모두 닫는 코드
38
+ wmi = WIN32OLE.connect("winmgmts://")
39
+ chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
40
+
41
+ chrome_procs.each do |proc|
42
+ cmd = proc.CommandLine
43
+ if cmd && cmd.include?("user-data-dir=C:/board_cookie")
44
+ puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
45
+ begin
46
+ proc.Terminate
47
+ rescue
48
+ #puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
49
+ end
50
+ end
51
+ end
52
+ sleep(1)
53
+
54
+ end
55
+
56
+
33
57
 
34
-
35
58
  def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
36
59
  board_cookie_dir = "C:/board_cookie"
37
60
  FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
@@ -223,37 +246,36 @@ class Naver
223
246
  sleep(1)
224
247
 
225
248
  chrome_start(proxy, board_cookie_dir)
249
+
226
250
 
227
- # 열린 모든 탭 핸들 확인
251
+ target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
252
+
228
253
  all_windows = @driver.window_handles
229
- #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
230
254
 
231
- # 원하는 URL
232
- target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
255
+ # target_url로 열린 탭들만 필터링
256
+ target_tabs = all_windows.select do |win|
257
+ @driver.switch_to.window(win)
258
+ @driver.current_url == target_url
259
+ end
233
260
 
234
- # 탭을 순회하면서
235
- all_windows.each do |window|
236
- @driver.switch_to.window(window)
237
- current_url = @driver.current_url
238
- #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
239
-
240
- # 원하는 URL이 아니면 탭을 닫기
241
- if current_url != target_url
242
- begin
243
- @driver.close # 다른 탭을 닫기
244
- rescue Selenium::WebDriver::Error::WebDriverError => e
245
- #puts "탭을 닫는 데 오류 발생: #{e.message}"
246
- end
261
+ # 남길 탭: target_url 탭 중 가장 마지막 (없으면 빈 배열)
262
+ tabs_to_keep = target_tabs.empty? ? [] : [target_tabs.last]
263
+
264
+ # 닫을 탭 = 전체에서 남길 탭 제외
265
+ tabs_to_close = all_windows - tabs_to_keep
266
+
267
+ tabs_to_close.each do |win|
268
+ begin
269
+ @driver.switch_to.window(win)
270
+ @driver.close
271
+ rescue Selenium::WebDriver::Error::WebDriverError => e
272
+ # 닫기 실패해도 무시
247
273
  end
248
274
  end
249
275
 
250
- # 남아 있는 탭으로 전환
251
- all_windows = @driver.window_handles # 남은 탭 리스트 갱신
252
- if all_windows.size > 0
253
- @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
254
- else
255
- #puts "남은 탭이 없습니다."
256
- end
276
+ # 남아있는 탭으로 포커스 이동 (남은 게 있으면)
277
+ remaining_windows = @driver.window_handles
278
+ @driver.switch_to.window(remaining_windows.first) if remaining_windows.any?
257
279
 
258
280
 
259
281
 
@@ -775,22 +797,65 @@ def update(user_id, user_pw, title, content, option, post_url, signup_url, login
775
797
  sleep(1)
776
798
  rescue
777
799
  begin
778
- # 타임아웃을 77초로 설정
779
- wait = Selenium::WebDriver::Wait.new(:timeout => 150)
780
- # 요소가 나타날 때까지 100초 동안 기다립니다.
781
- wait.until { @driver.find_elements(:xpath, '//*[@class="spacer"]').size == 0 }
782
- sleep(1)
783
-
784
- #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
785
- puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
786
- sleep(5)
787
- rescue => e
788
- puts '-[√] 캡챠 해제 실패(캡챠는 사람이 풀기에 간혹 실수로 실패가 될수있습니다.).......'.red
789
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
790
- puts e
791
- @driver.close
792
- return 0
793
- end
800
+ # 타임아웃을 77초로 설정
801
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
802
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
803
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
804
+ sleep(1)
805
+
806
+ #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
807
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
808
+ sleep(7)
809
+ begin
810
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
811
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
812
+
813
+ original_tab = @driver.window_handle
814
+
815
+ @driver.switch_to.new_window(:tab)
816
+ new_tab = @driver.window_handle # 새 탭 핸들 저장
817
+
818
+ @driver.get('chrome://extensions/')
819
+ sleep(3)
820
+
821
+ # 마우스 및 키보드 입력 시도
822
+ mouse_move_percentage(0.35, 0.02)
823
+ sleep(0.5)
824
+ left_click
825
+ sleep(1)
826
+ key_stroke('enter')
827
+ sleep(1)
828
+ 6.times do
829
+ key_stroke('tab')
830
+ sleep(0.5)
831
+ end
832
+ key_stroke('enter')
833
+ sleep(1)
834
+
835
+
836
+
837
+ # 원래 탭으로 전환
838
+ @driver.switch_to.window(original_tab)
839
+ @driver.navigate.refresh
840
+ sleep(10)
841
+ @driver.switch_to.window(new_tab)
842
+ sleep(1)
843
+ # 마우스 및 키보드 입력 시도
844
+ mouse_move_percentage(0.35, 0.02)
845
+ sleep(0.5)
846
+ left_click
847
+ sleep(1)
848
+ key_stroke('enter')
849
+ sleep(1)
850
+ @driver.close
851
+ sleep(1)
852
+ @driver.switch_to.window(original_tab)
853
+ sleep(1)
854
+ rescue
855
+ end
856
+
857
+ rescue
858
+ end
794
859
  end
795
860
  rescue
796
861
  begin
@@ -3752,12 +3817,60 @@ login_url = option['login_url'].to_s
3752
3817
  # 타임아웃을 77초로 설정
3753
3818
  wait = Selenium::WebDriver::Wait.new(:timeout => 150)
3754
3819
  # 요소가 나타날 때까지 100초 동안 기다립니다.
3755
- wait.until { @driver.find_elements(:xpath, '//*[@class="spacer"]').size == 0 }
3820
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
3756
3821
  sleep(1)
3757
3822
 
3758
3823
  #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
3759
3824
  puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
3760
- sleep(5)
3825
+ sleep(7)
3826
+ begin
3827
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
3828
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
3829
+
3830
+ original_tab = @driver.window_handle
3831
+
3832
+ @driver.switch_to.new_window(:tab)
3833
+ new_tab = @driver.window_handle # 새 탭 핸들 저장
3834
+
3835
+ @driver.get('chrome://extensions/')
3836
+ sleep(3)
3837
+
3838
+ # 마우스 및 키보드 입력 시도
3839
+ mouse_move_percentage(0.35, 0.02)
3840
+ sleep(0.5)
3841
+ left_click
3842
+ sleep(1)
3843
+ key_stroke('enter')
3844
+ sleep(1)
3845
+ 6.times do
3846
+ key_stroke('tab')
3847
+ sleep(0.5)
3848
+ end
3849
+ key_stroke('enter')
3850
+ sleep(1)
3851
+
3852
+
3853
+
3854
+ # 원래 탭으로 전환
3855
+ @driver.switch_to.window(original_tab)
3856
+ @driver.navigate.refresh
3857
+ sleep(10)
3858
+ @driver.switch_to.window(new_tab)
3859
+ sleep(1)
3860
+ # 마우스 및 키보드 입력 시도
3861
+ mouse_move_percentage(0.35, 0.02)
3862
+ sleep(0.5)
3863
+ left_click
3864
+ sleep(1)
3865
+ key_stroke('enter')
3866
+ sleep(1)
3867
+ @driver.close
3868
+ sleep(1)
3869
+ @driver.switch_to.window(original_tab)
3870
+ sleep(1)
3871
+ rescue
3872
+ end
3873
+
3761
3874
  rescue
3762
3875
  end
3763
3876
  end
@@ -3849,6 +3962,8 @@ login_url = option['login_url'].to_s
3849
3962
  end
3850
3963
  ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
3851
3964
 
3965
+
3966
+
3852
3967
 
3853
3968
  begin
3854
3969
  # 요소 찾기 타임아웃을 10초로 설정
@@ -4990,10 +5105,11 @@ login_url = option['login_url'].to_s
4990
5105
 
4991
5106
 
4992
5107
 
4993
-
4994
5108
  rescue => e
4995
5109
  #puts '-[√] 로그인 PASS.......'.cyan
5110
+
4996
5111
  puts e
5112
+
4997
5113
  end
4998
5114
 
4999
5115
 
@@ -5555,34 +5671,71 @@ post_url = option['post_url'].to_s
5555
5671
  sleep(1)
5556
5672
  rescue
5557
5673
  begin
5558
- # 타임아웃을 77초로 설정
5559
- wait = Selenium::WebDriver::Wait.new(:timeout => 150)
5560
- # 요소가 나타날 때까지 100초 동안 기다립니다.
5561
- wait.until { @driver.find_elements(:xpath, '//*[@class="spacer"]').size == 0 }
5562
- sleep(1)
5563
-
5564
- #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
5565
- puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
5566
- sleep(5)
5567
- rescue => e
5568
- puts '-[√] 캡챠 해제 실패(캡챠는 사람이 풀기에 간혹 실수로 실패가 될수있습니다.).......'.red
5569
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
5570
- puts e
5571
- @driver.close
5572
- return 0
5573
- end
5574
- end
5575
- rescue
5576
-
5577
- end
5578
- end
5579
- ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
5674
+ # 타임아웃을 77초로 설정
5675
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
5676
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
5677
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
5678
+ sleep(1)
5679
+
5680
+ #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
5681
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
5682
+ sleep(7)
5683
+ begin
5684
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
5685
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
5580
5686
 
5687
+ original_tab = @driver.window_handle
5581
5688
 
5689
+ @driver.switch_to.new_window(:tab)
5690
+ new_tab = @driver.window_handle # 새 탭 핸들 저장
5582
5691
 
5692
+ @driver.get('chrome://extensions/')
5693
+ sleep(3)
5583
5694
 
5695
+ # 마우스 및 키보드 입력 시도
5696
+ mouse_move_percentage(0.35, 0.02)
5697
+ sleep(0.5)
5698
+ left_click
5699
+ sleep(1)
5700
+ key_stroke('enter')
5701
+ sleep(1)
5702
+ 6.times do
5703
+ key_stroke('tab')
5704
+ sleep(0.5)
5705
+ end
5706
+ key_stroke('enter')
5707
+ sleep(1)
5584
5708
 
5709
+
5585
5710
 
5711
+ # 원래 탭으로 전환
5712
+ @driver.switch_to.window(original_tab)
5713
+ @driver.navigate.refresh
5714
+ sleep(10)
5715
+ @driver.switch_to.window(new_tab)
5716
+ sleep(1)
5717
+ # 마우스 및 키보드 입력 시도
5718
+ mouse_move_percentage(0.35, 0.02)
5719
+ sleep(0.5)
5720
+ left_click
5721
+ sleep(1)
5722
+ key_stroke('enter')
5723
+ sleep(1)
5724
+ @driver.close
5725
+ sleep(1)
5726
+ @driver.switch_to.window(original_tab)
5727
+ sleep(1)
5728
+ rescue
5729
+ end
5730
+
5731
+ rescue
5732
+ end
5733
+ end
5734
+ rescue
5735
+
5736
+ end
5737
+ end
5738
+ ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
5586
5739
 
5587
5740
 
5588
5741
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posting_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.101.999
4
+ version: 3.102.999
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-12 00:00:00.000000000 Z
10
+ date: 2025-06-13 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com