posting_zon 0.0.57 → 0.0.61

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 +87 -45
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f26df1f291327db84506395ca1b2211ee8f10dcaa15c4a0c79be64f33f3acdd9
4
- data.tar.gz: 14a131501a1e618ee6fd6294457a2ec18b79747567f4451762b34d2d9b833c29
3
+ metadata.gz: 6f49d944350357c2ea579a545b8d8104db8a9ce38f0bf0dae274c74d6ff19978
4
+ data.tar.gz: fc1f6462bc84986656579b9527b9c36624335f4d531bc2a3e79e5a4dcd18d9a9
5
5
  SHA512:
6
- metadata.gz: 1eb1bff47a15e373efff2efc242c4e6bf6ea2a68e2d887b77752ec165bca1be9faf8ef18b36ada1e6731956955300422b9faeea79c9044be02b248a7f521a1f4
7
- data.tar.gz: 843846ce0d4a86ec9031215832f4bd4398d3f96363b876ac00a56c329498c5a308c5dc8ecd928391e0c80f3be3dae712678c9f5ef5297d573844d6898380577d
6
+ metadata.gz: 4192acbe758204213c7f57c44a21a5dfc2f216295f3ba1e27c979db2c394f8dafef3022fc752ed6bdc2c66ec2f6a97b698a6cb202a56bb021c54c26c7e894f3e
7
+ data.tar.gz: 92e4fb419bfc45b4c73fe86f662eb9d0fb0216a0cf4c99bf2b80afb516373fad130543c4706e3ecdd37dfa69a17dcfdadde92b2ac99eaf9d715e510061a314ba
data/lib/posting_zon.rb CHANGED
@@ -31,6 +31,7 @@ class Naver
31
31
  def chrome_start(proxy)
32
32
  if proxy == ''
33
33
  begin
34
+
34
35
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
35
36
  options = Selenium::WebDriver::Chrome::Options.new
36
37
  options.add_extension('./crx/free.crx')
@@ -54,7 +55,6 @@ class Naver
54
55
  options.add_argument("--disable-logging")
55
56
  options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
56
57
  options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
57
- options.add_argument('--disable-blink-features=AutomationControlled') # JavaScript로 navigator.webdriver 숨기기
58
58
 
59
59
  # 'capabilities'과 'options' 배열로 설정
60
60
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -62,6 +62,7 @@ class Naver
62
62
 
63
63
  # Selenium 4에서는 'capabilities'만 사용하는 방식
64
64
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
65
+
65
66
 
66
67
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
67
68
 
@@ -97,8 +98,7 @@ class Naver
97
98
  options.add_argument("--disable-logging")
98
99
  options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
99
100
  options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
100
- # JavaScript로 navigator.webdriver 숨기기
101
- options.add_argument('--disable-blink-features=AutomationControlled')
101
+
102
102
 
103
103
  # 'capabilities'과 'options' 배열로 설정
104
104
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
@@ -155,35 +155,45 @@ class Naver
155
155
 
156
156
  def login(proxy)
157
157
  chrome_start(proxy)
158
-
158
+
159
159
  @driver.get('about:blank')
160
160
  sleep(2)
161
+
162
+ # 열린 모든 탭 핸들 확인
161
163
  all_windows = @driver.window_handles
162
-
163
- # 원하는 탭을 확인하고, 닫기
164
+ puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
165
+
166
+ # 빈 탭만 남기고 나머지 탭 닫기
164
167
  all_windows.each do |window|
165
- @driver.switch_to.window(window)
166
-
167
- # 해당 탭이 'chrome-extension://'으로 시작하는지 확인
168
- if @driver.current_url.start_with?('chrome-extension://')
169
- puts "확장 프로그램 발견: #{@driver.current_url}"
170
- @driver.close
171
- sleep(1)
172
- break
168
+ @driver.switch_to.window(window)
169
+ current_url = @driver.current_url
170
+ puts "탭 URL: #{current_url}" # URL 출력
171
+
172
+ # 'chrome-extension://'로 시작하는 확장 프로그램 탭을 제외하고 닫기
173
+ if current_url.start_with?('chrome-extension://')
174
+ puts "확장 프로그램 탭을 닫지 않음: #{current_url}"
175
+ else
176
+ @driver.close # 빈 탭 등 다른 탭은 닫기
177
+ puts "빈 탭 또는 확장 프로그램이 아닌 탭을 닫았습니다."
178
+ end
173
179
  end
180
+
181
+ # 빈 탭을 남긴 후, 빈 탭으로 다시 전환
182
+ all_windows = @driver.window_handles # 남은 탭 리스트 갱신
183
+ if all_windows.size == 1
184
+ @driver.switch_to.window(all_windows.first) # 남은 빈 탭으로 전환
185
+ puts "빈 탭으로 전환됨."
186
+ else
187
+ puts "빈 탭을 찾을 수 없습니다."
174
188
  end
175
-
176
-
177
- all_windows = @driver.window_handles # 모든 탭을 다시 초기화
178
- @driver.switch_to.window(all_windows.last) # 마지막 탭으로 전환
179
- sleep(1)
180
-
181
- all_windows = @driver.window_handles # 다시 탭 목록 초기화
189
+
182
190
  sleep(1)
183
-
191
+
192
+ # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
184
193
  @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
185
194
  sleep(1)
186
- end
195
+ end
196
+
187
197
 
188
198
 
189
199
 
@@ -371,7 +381,7 @@ sleep(2)
371
381
  else
372
382
 
373
383
  begin
374
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 최대 20초 대기
384
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
375
385
  wait.until { @driver.execute_script("return document.readyState") == "complete" }
376
386
  @driver.get(signup_url)
377
387
  sleep(1)
@@ -2579,7 +2589,7 @@ login_url = option['login_url'].to_s
2579
2589
  else
2580
2590
 
2581
2591
  begin
2582
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 최대 20초 대기
2592
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
2583
2593
  wait.until { @driver.execute_script("return document.readyState") == "complete" }
2584
2594
  @driver.get(login_url)
2585
2595
  sleep(1)
@@ -3775,7 +3785,7 @@ login_url = option['login_url'].to_s
3775
3785
 
3776
3786
 
3777
3787
  ##################
3778
- cc_check_url = option['cc_check_url'].to_json
3788
+ cc_check_url = option['cc_check_url'].to_s
3779
3789
 
3780
3790
 
3781
3791
  begin
@@ -3784,7 +3794,7 @@ begin
3784
3794
  else
3785
3795
 
3786
3796
  begin
3787
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 최대 20초 대기
3797
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3788
3798
  wait.until { @driver.execute_script("return document.readyState") == "complete" }
3789
3799
  @driver.get(cc_check_url)
3790
3800
  sleep(1)
@@ -4023,22 +4033,15 @@ end
4023
4033
 
4024
4034
 
4025
4035
 
4026
-
4027
-
4028
-
4029
-
4030
- #######
4031
- post_url = option['post_url'].to_s
4036
+ login_url = option['login_url'].to_s
4032
4037
 
4033
4038
  begin
4034
4039
  if post_url == '' or post_url == '게시판 글쓰기 url'
4035
4040
 
4036
4041
  else
4037
- puts '-[√] 글쓰기 페이지 URL 이동.......'.magenta
4038
-
4039
-
4042
+
4040
4043
  begin
4041
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 최대 20초 대기
4044
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
4042
4045
  wait.until { @driver.execute_script("return document.readyState") == "complete" }
4043
4046
  @driver.get(post_url)
4044
4047
  sleep(1)
@@ -4105,7 +4108,16 @@ post_url = option['post_url'].to_s
4105
4108
  puts '-[√] 글쓰기 버튼 code 3.......'.green
4106
4109
  sleep(3.7)
4107
4110
  rescue
4108
-
4111
+ begin
4112
+ el_post_btn = @driver.find_element(:xpath, '//*[@class="gRight"]')
4113
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
4114
+ sleep(1)
4115
+ @driver.find_element(:xpath, '//*[@class="gRight"]').click
4116
+ puts '-[√] 글쓰기 버튼 code 3.......'.green
4117
+ sleep(3.7)
4118
+ rescue
4119
+
4120
+ end
4109
4121
  end
4110
4122
  end
4111
4123
  end
@@ -5095,7 +5107,12 @@ begin
5095
5107
  @driver.find_element(:xpath, '//*[@name="nick_name"]').send_keys(user_id)
5096
5108
  sleep(1)
5097
5109
  rescue
5098
-
5110
+ begin
5111
+ @driver.find_element(:xpath, '//*[@name="write_name"]').send_keys(user_id)
5112
+ sleep(1)
5113
+ rescue
5114
+
5115
+ end
5099
5116
  end
5100
5117
  end
5101
5118
  end
@@ -5785,16 +5802,18 @@ begin
5785
5802
  puts '-[√] 제목 code 37.......'.yellow
5786
5803
 
5787
5804
 
5805
+
5806
+
5788
5807
  rescue => e
5789
5808
  puts '-[√] 제목 입력 항목 코드 탐색 실패!!.......'.red
5790
5809
  puts '-[√] 다음 작업 준비 중으로 1~60 초 정도 기다려주세요.......'.red
5791
-
5810
+
5792
5811
  @driver.window_handles.each do |handle|
5793
- @driver.switch_to.window(handle)
5812
+ @driver.switch_to.window(handle)
5794
5813
  begin
5795
5814
  # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
5796
5815
  @driver.close
5797
-
5816
+
5798
5817
  rescue Selenium::WebDriver::Error::WebDriverError => e
5799
5818
  puts "크롬 브라우저 종료: #{e.message}"
5800
5819
  end
@@ -5802,8 +5821,10 @@ begin
5802
5821
  return 0
5803
5822
  @driver.quit
5804
5823
  end
5824
+
5805
5825
 
5806
5826
 
5827
+
5807
5828
  end
5808
5829
 
5809
5830
  end
@@ -6028,6 +6049,7 @@ begin
6028
6049
  html_bb = @driver.find_element(:xpath, '//*[@id="moreMisc-1"]')
6029
6050
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", html_bb)
6030
6051
  sleep(1)
6052
+
6031
6053
  @driver.find_element(:xpath, '//*[@id="moreMisc-1"]').click
6032
6054
  sleep(1)
6033
6055
  @driver.find_element(:xpath, '//*[@id="html-1"]').click
@@ -8627,8 +8649,28 @@ rescue
8627
8649
  sleep(5)
8628
8650
 
8629
8651
  rescue
8652
+ begin
8653
+ ss_button = @driver.find_element(:xpath, "//button[contains(text(), '글쓰기')]")
8654
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", ss_button)
8655
+ sleep(1)
8656
+
8657
+ @driver.find_element(:xpath, "//button[contains(text(), '글쓰기')]").click
8658
+ puts '-[√] 등록을 27번 코드로 시도하였습니다.......'.magenta
8659
+ sleep(5)
8660
+
8661
+ rescue
8662
+ begin
8663
+ ss_button = @driver.find_element(:xpath, '//*[@class="Button button-rounded black button-normal"]')
8664
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", ss_button)
8665
+ sleep(1)
8666
+
8667
+ @driver.find_element(:xpath, '//*[@class="Button button-rounded black button-normal"]').click
8668
+ puts '-[√] 등록을 28번 코드로 시도하였습니다.......'.magenta
8669
+ sleep(5)
8670
+
8671
+ rescue
8630
8672
 
8631
-
8673
+
8632
8674
  ########─────────────────────────────▼▼▼▼▼▼▼ 등록버튼 2차 시도 ▼▼▼▼▼▼▼──────────────────────────────#######
8633
8675
  begin
8634
8676
  puts '-[√] 등록 버튼 코드 탐색에 실패하였습니다.......'.magenta
@@ -8826,8 +8868,8 @@ rescue
8826
8868
 
8827
8869
 
8828
8870
 
8829
-
8830
-
8871
+ end
8872
+ end
8831
8873
  end
8832
8874
  end
8833
8875
  end
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.57
4
+ version: 0.0.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
11
+ date: 2025-02-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: posting app
14
14
  email: mymin26@naver.com