posting_zon 3.96.999 → 3.99.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_zon.rb +78 -29
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7109711520cbbb3eba2417f47ef9adea620dd40e0d0cc11756437668616c47de
4
- data.tar.gz: 894a122a25ee6a1bd2ba05ebedef80a780a0c6a63c4b61a62c026a9312b80163
3
+ metadata.gz: d6bc4eaefb7c70684f115c07f4216be732d92861a27933009851ee310abd4e5a
4
+ data.tar.gz: 1e7ca98c48b2a05f4132446fbebd8b4b0505e53561eb67d08196e06624a81066
5
5
  SHA512:
6
- metadata.gz: bae14d6890fafcb8fbe10e19542c7f07461bc9a96fe76e1134097700d31bc5b0a87e09fbcedb49d674615c71ea2ca4da75cb691dba3d11c3e14ba50caf16e326
7
- data.tar.gz: 196b55cde5a223b4b2586d7aacb0378f338c63b7f6dc8bd0df0b7cb92abaa677a1024ddbaa3b5232d12e1e4a830da62d8c47bca29d1e8b740080eac45ae21770
6
+ metadata.gz: 9cfbcdb2d8e35fac90ac8177726fe84e04a422faeedad6c41123970645c3909e2a07fa3f171371c0100b4d4f9b2b84acbe1207faa01d983d3244cb6dfb069934
7
+ data.tar.gz: 19d70e607b41a9581896c8e29008ec9311ef6667ade138dcbba08f8f8b36a77560593a97c40c97d3da431cf2af67dde72454a117b0f5df0d652920cd8a413fe1
data/lib/posting_zon.rb CHANGED
@@ -29,8 +29,37 @@ using Rainbow
29
29
 
30
30
  class Naver
31
31
  def initialize
32
+ kill_selenium_chrome #기존 창 모두 닫는 명령
33
+ sleep(1)
32
34
  end
33
35
 
36
+ def kill_selenium_chrome #기존 창 모두 닫는 코드
37
+ wmi = WIN32OLE.connect("winmgmts://")
38
+ chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
39
+
40
+ chrome_procs.each do |proc|
41
+ cmd = proc.CommandLine
42
+ if cmd && cmd.include?("user-data-dir=C:/board_cookie")
43
+ puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
44
+ begin
45
+ proc.Terminate
46
+ rescue
47
+ #puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
48
+ end
49
+ end
50
+ end
51
+
52
+ # chromedriver도 같이 종료
53
+ chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
54
+ chromedrivers.each do |proc|
55
+ puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
56
+ begin
57
+ proc.Terminate
58
+ rescue
59
+ #puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
60
+ end
61
+ end
62
+ end
34
63
 
35
64
  def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
36
65
  board_cookie_dir = "C:/board_cookie"
@@ -11806,45 +11835,65 @@ end
11806
11835
 
11807
11836
 
11808
11837
  begin
11809
- wait = Selenium::WebDriver::Wait.new(timeout: 2)
11810
- alert = wait.until { @driver.switch_to.alert }
11811
- alert_text = alert.text
11812
- alert.accept
11813
-
11838
+
11814
11839
  banned_word = nil
11815
11840
 
11816
- # 1. 금지단어('감자') 형식
11817
- if alert_text =~ /금지단어\('(.+?)'\)/
11818
- banned_word = $1
11841
+ begin
11842
+ wait = Selenium::WebDriver::Wait.new(timeout: 2)
11843
+ alert = wait.until { @driver.switch_to.alert }
11844
+ alert_text = alert.text
11845
+ alert.accept
11846
+
11847
+ # alert 메시지에서 금지단어 추출
11848
+ if alert_text =~ /금지단어\('(.+?)'\)/
11849
+ banned_word = $1
11850
+ elsif alert_text =~ /내용에\s+(.+?)\s+단어 사용이 제한/
11851
+ banned_word = $1
11852
+ elsif alert_text =~ /"(.+?)"\s*는/
11853
+ banned_word = $1
11854
+ elsif alert_text =~ /"(.+?)"/
11855
+ banned_word = $1
11856
+ elsif alert_text =~ /'(.+?)'/
11857
+ banned_word = $1
11858
+ end
11859
+
11819
11860
 
11820
- # 2. 내용에 감자 단어 사용이 제한되어 있습니다 형식
11821
- elsif alert_text =~ /내용에\s+(.+?)\s+단어 사용이 제한/
11822
- banned_word = $1
11861
+ rescue
11862
+ begin
11863
+ wait = Selenium::WebDriver::Wait.new(timeout: 2)
11864
+ error_box = wait.until { @driver.find_element(css: '.pop-title-message') }
11823
11865
 
11824
- # 3. "금지단어"는..형식
11825
- elsif alert_text =~ /"(.+?)"\s*는/
11826
- banned_word = $1
11827
- end
11866
+ # 예: <div class="pop-title-message"><div>"마케팅"</div>사용할 수 없는 단어입니다</div>pop-title-message
11867
+ text = error_box.text.strip
11828
11868
 
11829
- if banned_word
11830
- puts "금지단어 발견: [#{banned_word}]".red
11831
- puts "[#{banned_word}] 금지단어 제거 후 재 시도 진행!!".red
11832
- title.gsub!(banned_word, '')
11833
- content.gsub!(banned_word, '')
11834
-
11835
- retry_count += 1
11836
- if retry_count >= max_retries
11837
- puts "최대 재시도 횟수 초과, 중단합니다.".red
11838
- break
11869
+ if text =~ /"(.+?)"/
11870
+ banned_word = $1
11871
+ end
11872
+ rescue
11873
+ end
11839
11874
  end
11840
- # 루프 계속 (다음 시도)
11841
- next
11875
+
11876
+
11877
+
11878
+ if banned_word
11879
+ puts "금지단어 발견: [#{banned_word}]".red
11880
+ puts "[#{banned_word}] 금지단어 제거 후 재 시도 진행!!".red
11881
+ title.gsub!(banned_word, '')
11882
+ content.gsub!(banned_word, '')
11883
+
11884
+ retry_count += 1
11885
+ if retry_count >= max_retries
11886
+ puts "최대 재시도 횟수 초과, 중단합니다.".red
11887
+ break
11888
+ end
11889
+ # 루프 계속 (다음 시도)
11890
+ next
11842
11891
  else
11843
- break # 금지단어 형식이 아니면 루프 종료
11892
+ break # 금지단어 형식이 아니면 루프 종료
11844
11893
  end
11845
11894
 
11846
11895
  rescue
11847
- break # alert 자체가 없으면 루프 종료
11896
+ break # alert 자체가 없으면 루프 종료
11848
11897
  end
11849
11898
 
11850
11899
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posting_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.96.999
4
+ version: 3.99.999
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-28 00:00:00.000000000 Z
10
+ date: 2025-05-29 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: posting app
13
13
  email: mymin26@naver.com