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.
- checksums.yaml +4 -4
- data/lib/posting_zon.rb +78 -29
- 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: d6bc4eaefb7c70684f115c07f4216be732d92861a27933009851ee310abd4e5a
|
4
|
+
data.tar.gz: 1e7ca98c48b2a05f4132446fbebd8b4b0505e53561eb67d08196e06624a81066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
11817
|
-
|
11818
|
-
|
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
|
-
|
11821
|
-
|
11822
|
-
|
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
|
-
|
11825
|
-
|
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
|
-
|
11830
|
-
|
11831
|
-
|
11832
|
-
|
11833
|
-
|
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
|
-
|
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
|
-
|
11892
|
+
break # 금지단어 형식이 아니면 루프 종료
|
11844
11893
|
end
|
11845
11894
|
|
11846
11895
|
rescue
|
11847
|
-
|
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.
|
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-
|
10
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: posting app
|
13
13
|
email: mymin26@naver.com
|