nblog_zon 0.0.57 → 0.0.60

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/nblog_zon.rb +109 -36
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f883cfb6feb032257a884a264ce6de500ce9ea5e13d1155ec32219912e583073
4
- data.tar.gz: 531cb52369f023df98704026570728dc7b8d54242fd33209b07c8d2e4600c9e4
3
+ metadata.gz: a18c1e0a45ef0145827cdb82cd82c72d7240c7a038f7992789fa053ac4adbc90
4
+ data.tar.gz: 412558bdfcc5935ede3aeca7b808dc9e2495277de92400030ba405d8374be1e5
5
5
  SHA512:
6
- metadata.gz: 6a52cf5f6154c481eab2915cd4967f83dd9d32a59964506e97b0925cc2a13bea5298f56c04c19005db9cbefd1242e0df23afb2fe35829ba3a4124d3c95950207
7
- data.tar.gz: 3e9546fe5d327cced57f51d77f8ab0c3986c53ed2efb4c56cd2b6a9d90da08e5fce0e5bc1b3fcb57aab7fae77951d97e5ae7b4a72985e33420260d32a5d81c0a
6
+ metadata.gz: 1d64196feb00e0eb45110c94fd3ae3e442b408b6999601bc0c3bcd180a01311f1cf3cb5de59d7757d08e46e2cbe293829b5c15025b3cc238e06a040cd5484cb3
7
+ data.tar.gz: 9994e0fd34e52e701dd565536c3bcb5f9ea0d373747542caaaad843cce5e3c432091cb2db2801cccc1c70a8596c4db58bbdeb9fb779e9a6c4bf5b7a334cd3fd5
data/lib/nblog_zon.rb CHANGED
@@ -221,6 +221,8 @@ class Naver
221
221
  begin
222
222
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
223
223
  options = Selenium::WebDriver::Chrome::Options.new
224
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
225
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
224
226
  options.page_load_strategy = :normal
225
227
  options.timeouts = {page_load: 20_000}
226
228
  options.page_load_strategy = 'none'
@@ -236,13 +238,8 @@ class Naver
236
238
  begin
237
239
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
238
240
  options = Selenium::WebDriver::Chrome::Options.new
239
- # profile = Selenium::WebDriver::Chrome::Profile.new
240
- # profile['network.proxy.type'] = 1
241
- # profile['network.proxy.http'] = proxy.split(':')[0]
242
- # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
243
- # options = Selenium::WebDriver::Chrome::Options.new
244
- # options.profile = profile
245
- options = Selenium::WebDriver::Chrome::Options.new
241
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
242
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
246
243
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
247
244
  options.page_load_strategy = :normal
248
245
  options.timeouts = {page_load: 20_000}
@@ -258,6 +255,8 @@ class Naver
258
255
  begin
259
256
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
260
257
  options = Selenium::WebDriver::Chrome::Options.new
258
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
259
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
261
260
  options.page_load_strategy = :normal
262
261
  options.timeouts = {page_load: 20_000}
263
262
  options.page_load_strategy = 'none'
@@ -306,55 +305,80 @@ class Naver
306
305
  sleep(1)
307
306
 
308
307
  begin
309
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
308
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
309
+ #요소가 나타날 때까지 3초 동안 기다립니다.
310
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
311
+ sleep(1.5)
312
+ check_cookie_login = 1
313
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
314
+ sleep(2.5)
315
+ rescue
316
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
310
317
  #요소가 나타날 때까지 3초 동안 기다립니다.
311
318
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
312
319
  sleep(1.5)
313
320
  @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
314
321
  check_cookie_login = 0
315
322
  sleep(1)
316
- rescue
317
- check_cookie_login = 1
318
- puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
319
- sleep(2.5)
320
323
  end
321
324
 
322
325
  if check_cookie_login == 0
323
326
  puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
324
327
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
325
328
  sleep(3)
326
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
327
- #요소가 나타날 때까지 3초 동안 기다립니다.
328
- wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
329
- sleep(1.5)
330
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
331
- sleep(1.5)
332
- @driver.find_element(:xpath, '//*[@id="id"]').click
333
- Clipboard.copy(user_id)
334
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
335
- sleep(1.5)
336
- @driver.find_element(:xpath, '//*[@id="pw"]').click
337
- Clipboard.copy(user_pw)
338
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
339
- sleep(1.5)
340
- @driver.find_element(:xpath, '//*[@id="log.login"]').click
341
- sleep(2.5)
329
+ begin
330
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
331
+ #요소가 나타날 때까지 3초 동안 기다립니다.
332
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
333
+ sleep(1.5)
334
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
335
+ sleep(1.5)
336
+ @driver.find_element(:xpath, '//*[@id="id"]').click
337
+ Clipboard.copy(user_id)
338
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
339
+ sleep(1.5)
340
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
341
+ Clipboard.copy(user_pw)
342
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
343
+ sleep(1.5)
344
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
345
+ sleep(2.5)
346
+ rescue => e
347
+ puts '-[√] 로딩 지연 접속 실패.......'.red
348
+ @driver.window_handles.each do |handle|
349
+ @driver.switch_to.window(handle)
350
+ begin
351
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
352
+ @driver.close
353
+ rescue Selenium::WebDriver::Error::WebDriverError => e
354
+ puts "Failed to close tab: #{e.message}"
355
+ end
356
+ end
357
+ return 0
358
+ end
342
359
 
343
360
  else
344
361
  # @driver.switch_to.default_content
345
362
  end
346
363
 
347
364
  begin
348
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
365
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
349
366
  #요소가 나타날 때까지 3초 동안 기다립니다.
350
367
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
351
368
 
352
369
  rescue => e
353
- puts '-[√] 로그인 실패!!.......'.red
354
- puts e
355
- @driver.close
370
+ puts '-[√] 로그인 실패.......'.red
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
356
380
  return 0
357
- end
381
+ end
358
382
  end
359
383
 
360
384
  def create_id
@@ -654,7 +678,25 @@ class Naver
654
678
  end
655
679
 
656
680
 
681
+ begin
657
682
  #제목 입력
683
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
684
+ #요소가 나타날 때까지 60초 동안 기다립니다.
685
+ wait.until { @driver.find_element(:xpath, '//*[@draggable="false"]') }
686
+ rescue => e
687
+ puts '-[√] 글 입력 필드 로딩 지연 접속 실패.......'.red
688
+ @driver.window_handles.each do |handle|
689
+ @driver.switch_to.window(handle)
690
+ begin
691
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
692
+ @driver.close
693
+ rescue Selenium::WebDriver::Error::WebDriverError => e
694
+ puts "Failed to close tab: #{e.message}"
695
+ end
696
+ end
697
+ return 0
698
+ end
699
+
658
700
  ele = @driver.find_element(:xpath, '//*[@draggable="false"]')
659
701
  @driver.action.click(ele).perform
660
702
  sleep(0.5)
@@ -1539,8 +1581,30 @@ class Naver
1539
1581
  end
1540
1582
 
1541
1583
 
1542
- @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]').click #1차 등록버튼
1543
- sleep(3)
1584
+ begin
1585
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
1586
+ #요소가 나타날 때까지 3초 동안 기다립니다.
1587
+ wait.until { @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]') }
1588
+ sleep(1.5)
1589
+ @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]').click #1차 등록버튼
1590
+ sleep(3)
1591
+ rescue => e
1592
+ puts '-[√] 로딩 지연 접속 실패.......'.red
1593
+ @driver.window_handles.each do |handle|
1594
+ @driver.switch_to.window(handle)
1595
+ begin
1596
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1597
+ @driver.close
1598
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1599
+ puts "Failed to close tab: #{e.message}"
1600
+ end
1601
+ end
1602
+ return 0
1603
+ end
1604
+
1605
+
1606
+
1607
+
1544
1608
  category = option['category']
1545
1609
  begin
1546
1610
  p category
@@ -1689,11 +1753,20 @@ class Naver
1689
1753
  end
1690
1754
 
1691
1755
  begin
1692
- @driver.close
1756
+ @driver.window_handles.each do |handle|
1757
+ @driver.switch_to.window(handle)
1758
+ begin
1759
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1760
+ @driver.close
1761
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1762
+ puts "Failed to close tab: #{e.message}"
1763
+ end
1764
+ end
1693
1765
  rescue
1694
1766
 
1695
1767
  end
1696
1768
 
1769
+
1697
1770
 
1698
1771
  end
1699
1772
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57
4
+ version: 0.0.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon