njongto_duo 0.0.35 → 0.0.39

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/njongto_duo.rb +103 -45
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2415a9c469aa090ebc15f8e85c4d10f6b7eb89ccfa874420ae71f449fcbf4d2e
4
- data.tar.gz: 07256eb887f0bece4f4c19c5416afd826d140b76599a753e36583a99827b0da6
3
+ metadata.gz: 89b6150bc526341028fab40a143ac6772730f2bfe940fb6bcce5435680cc8f86
4
+ data.tar.gz: 6f0ad9b7ec8158abfd2323b1a194e90148aab5958ddeba1171fd7fd1973e69ac
5
5
  SHA512:
6
- metadata.gz: c7c6f557f56adb7ff383f2031821a43c06fad7fba35c6c3fb83d260d0b7f1b6057e349807902b599237099265fcce500b7a219ef62a038e98ce85c44129f3d80
7
- data.tar.gz: 4214def14fc8de42e98c90d167f0917e2ce224e18fa7affcd4bc60c81e28a62454c6addce3864fb8efa11e560988678d9068b835aa0922daf0c8e96a419e3749
6
+ metadata.gz: 18df24e2fb5c7aafced5e42197027aeb76fd3f3f5b57904a03040df59b74f45d95ce81c3f925a73a0a4f387370c2f0391cb502f98321ae3562fe65befd240905
7
+ data.tar.gz: 9d5ca60c6e1f4adaceb7773f714343cea3830a0bcc495513efa9e0a6a639d77bf4069acb7584e07f1d8f74fc31810ae0cba5cedc93a978b5c010d6027d91d55d
data/lib/njongto_duo.rb CHANGED
@@ -42,6 +42,8 @@ class Naver
42
42
  begin
43
43
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
44
44
  options = Selenium::WebDriver::Chrome::Options.new
45
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
46
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
45
47
  options.page_load_strategy = :normal
46
48
  options.timeouts = {page_load: 20_000}
47
49
  options.page_load_strategy = 'none'
@@ -57,13 +59,8 @@ class Naver
57
59
  begin
58
60
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
59
61
  options = Selenium::WebDriver::Chrome::Options.new
60
- # profile = Selenium::WebDriver::Chrome::Profile.new
61
- # profile['network.proxy.type'] = 1
62
- # profile['network.proxy.http'] = proxy.split(':')[0]
63
- # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
64
- # options = Selenium::WebDriver::Chrome::Options.new
65
- # options.profile = profile
66
- options = Selenium::WebDriver::Chrome::Options.new
62
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
63
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
67
64
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
68
65
  options.page_load_strategy = :normal
69
66
  options.timeouts = {page_load: 20_000}
@@ -79,6 +76,8 @@ class Naver
79
76
  begin
80
77
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
81
78
  options = Selenium::WebDriver::Chrome::Options.new
79
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
80
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
82
81
  options.page_load_strategy = :normal
83
82
  options.timeouts = {page_load: 20_000}
84
83
  options.page_load_strategy = 'none'
@@ -126,39 +125,57 @@ class Naver
126
125
  sleep(1)
127
126
 
128
127
  begin
129
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
128
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
129
+ #요소가 나타날 때까지 3초 동안 기다립니다.
130
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
131
+ sleep(1.5)
132
+ check_cookie_login = 1
133
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
134
+ sleep(2.5)
135
+ rescue
136
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
130
137
  #요소가 나타날 때까지 3초 동안 기다립니다.
131
138
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
132
139
  sleep(1.5)
133
140
  @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
134
141
  check_cookie_login = 0
135
142
  sleep(1)
136
- rescue
137
- check_cookie_login = 1
138
- puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
139
- sleep(2.5)
140
143
  end
141
144
 
142
145
  if check_cookie_login == 0
143
146
  puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
144
147
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
145
148
  sleep(3)
146
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
147
- #요소가 나타날 때까지 3초 동안 기다립니다.
148
- wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
149
- sleep(1.5)
150
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
151
- sleep(1.5)
152
- @driver.find_element(:xpath, '//*[@id="id"]').click
153
- Clipboard.copy(user_id)
154
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
155
- sleep(1.5)
156
- @driver.find_element(:xpath, '//*[@id="pw"]').click
157
- Clipboard.copy(user_pw)
158
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
159
- sleep(1.5)
160
- @driver.find_element(:xpath, '//*[@id="log.login"]').click
161
- sleep(2.5)
149
+ begin
150
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
151
+ #요소가 나타날 때까지 3초 동안 기다립니다.
152
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
153
+ sleep(1.5)
154
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
155
+ sleep(1.5)
156
+ @driver.find_element(:xpath, '//*[@id="id"]').click
157
+ Clipboard.copy(user_id)
158
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
159
+ sleep(1.5)
160
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
161
+ Clipboard.copy(user_pw)
162
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
163
+ sleep(1.5)
164
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
165
+ sleep(2.5)
166
+ rescue => e
167
+ puts '-[√] 로딩 지연 접속 실패.......'.red
168
+ @driver.window_handles.each do |handle|
169
+ @driver.switch_to.window(handle)
170
+ begin
171
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
172
+ @driver.close
173
+ rescue Selenium::WebDriver::Error::WebDriverError => e
174
+ puts "Failed to close tab: #{e.message}"
175
+ end
176
+ end
177
+ return 0
178
+ end
162
179
 
163
180
  else
164
181
  # @driver.switch_to.default_content
@@ -170,11 +187,18 @@ class Naver
170
187
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
171
188
 
172
189
  rescue => e
173
- puts '-[√] 로그인 실패!!.......'.red
174
- puts e
175
- @driver.close
190
+ puts '-[√] 로그인 실패.......'.red
191
+ @driver.window_handles.each do |handle|
192
+ @driver.switch_to.window(handle)
193
+ begin
194
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
195
+ @driver.close
196
+ rescue Selenium::WebDriver::Error::WebDriverError => e
197
+ puts "Failed to close tab: #{e.message}"
198
+ end
199
+ end
176
200
  return 0
177
- end
201
+ end
178
202
  end
179
203
 
180
204
  def create_id
@@ -210,11 +234,19 @@ class Naver
210
234
  puts'[기능 발동!!] 오픈톡 유형 감지 확인.......'.green
211
235
  puts'[Step.04] 제목 입력.......'.yellow
212
236
  @driver.find_element(:xpath, '//*[@placeholder="제목"]').send_keys(title)
213
- rescue
237
+ rescue => e
214
238
  puts '[Error] 제목 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
215
- @driver.close
216
- return 0
217
- end
239
+ @driver.window_handles.each do |handle|
240
+ @driver.switch_to.window(handle)
241
+ begin
242
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
243
+ @driver.close
244
+ rescue Selenium::WebDriver::Error::WebDriverError => e
245
+ puts "Failed to close tab: #{e.message}"
246
+ end
247
+ end
248
+ return 0
249
+ end
218
250
  end
219
251
 
220
252
  #내용 입력
@@ -233,11 +265,19 @@ class Naver
233
265
  @driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]')
234
266
  puts'[Step.05] 내용 입력.......'.yellow
235
267
  @driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]').click
236
- rescue
268
+ rescue => e
237
269
  puts '[Error] 내용 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
238
- @driver.close
239
- return 0
240
- end
270
+ @driver.window_handles.each do |handle|
271
+ @driver.switch_to.window(handle)
272
+ begin
273
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
274
+ @driver.close
275
+ rescue Selenium::WebDriver::Error::WebDriverError => e
276
+ puts "Failed to close tab: #{e.message}"
277
+ end
278
+ end
279
+ return 0
280
+ end
241
281
  end
242
282
 
243
283
  puts content
@@ -309,16 +349,34 @@ class Naver
309
349
  puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
310
350
  @driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]').click
311
351
  puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
312
- rescue
352
+ rescue => e
313
353
  puts '[Error] 등록 버튼을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
314
- @driver.close
315
- return 0
316
- end
354
+ @driver.window_handles.each do |handle|
355
+ @driver.switch_to.window(handle)
356
+ begin
357
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
358
+ @driver.close
359
+ rescue Selenium::WebDriver::Error::WebDriverError => e
360
+ puts "Failed to close tab: #{e.message}"
361
+ end
362
+ end
363
+ return 0
364
+ end
365
+
366
+
317
367
  end
318
368
  sleep(5)
319
369
  begin
320
370
  puts'[MISSION SUCCESS !! // 미션 성공 !!] 브라우저 종료.......'.green
321
- @driver.close
371
+ @driver.window_handles.each do |handle|
372
+ @driver.switch_to.window(handle)
373
+ begin
374
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
375
+ @driver.close
376
+ rescue Selenium::WebDriver::Error::WebDriverError => e
377
+ puts "Failed to close tab: #{e.message}"
378
+ end
379
+ end
322
380
  rescue
323
381
 
324
382
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njongto_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon