nblog_duo 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_duo.rb +109 -37
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00304b92c797f9419cbf20fc71412f9f666c91ee6ff9460fe343b8c43ccc0d0e
4
- data.tar.gz: cdfffbae2c30420c4525448cbb9e7e6eb58b2cc3be0ea611270800b949755c0f
3
+ metadata.gz: 59f2448f52a70dbb854dc4f34d2282a7676b7eed64030239c65fae6d80b114d3
4
+ data.tar.gz: f844ef2952a82cf4584e6d873a6e63702679eb838e9b63181a434550d6089268
5
5
  SHA512:
6
- metadata.gz: 51cfde362b5f66b14d59be23d006f29575a2b4ced4d6a5242b91de0a3e51ced48dc8e11d7f939b4b125d074d5fbf162276a3e8cf48d524e50b1c6f94d5b1507c
7
- data.tar.gz: 9a56c75d1e0e4da08f6b4374feabefeaf7121ac449df7d6f4778c8a6f3cdb5fa0e6d7c07bfda46286fceaec413d173327ade3c0dfc00b5bf52d34a48c6aea4a4
6
+ metadata.gz: 2286d81efb61dba52e269996ccb6fae70363e4d18991f1be9ba2ba2d0389d0601f2f96803e6f5b28d7d03d5f651f7679067c1bb2a87bbd11802d5233fd2f913b
7
+ data.tar.gz: d03bb504243384604bc1e695be078abf774daeb824bb6ac95915cac1e720749685f7249855e2f45abdfd1b0fb4cf32861eebb32add22ad87f4aa51be5501fde4
data/lib/nblog_duo.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'
@@ -305,55 +304,80 @@ class Naver
305
304
  sleep(1)
306
305
 
307
306
  begin
308
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
307
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
308
+ #요소가 나타날 때까지 3초 동안 기다립니다.
309
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
310
+ sleep(1.5)
311
+ check_cookie_login = 1
312
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
313
+ sleep(2.5)
314
+ rescue
315
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
309
316
  #요소가 나타날 때까지 3초 동안 기다립니다.
310
317
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
311
318
  sleep(1.5)
312
319
  @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
313
320
  check_cookie_login = 0
314
321
  sleep(1)
315
- rescue
316
- check_cookie_login = 1
317
- puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
318
- sleep(2.5)
319
322
  end
320
323
 
321
324
  if check_cookie_login == 0
322
325
  puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
323
326
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
324
327
  sleep(3)
325
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
326
- #요소가 나타날 때까지 3초 동안 기다립니다.
327
- wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
328
- sleep(1.5)
329
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
330
- sleep(1.5)
331
- @driver.find_element(:xpath, '//*[@id="id"]').click
332
- Clipboard.copy(user_id)
333
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
334
- sleep(1.5)
335
- @driver.find_element(:xpath, '//*[@id="pw"]').click
336
- Clipboard.copy(user_pw)
337
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
338
- sleep(1.5)
339
- @driver.find_element(:xpath, '//*[@id="log.login"]').click
340
- sleep(2.5)
328
+ begin
329
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
330
+ #요소가 나타날 때까지 3초 동안 기다립니다.
331
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
332
+ sleep(1.5)
333
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
334
+ sleep(1.5)
335
+ @driver.find_element(:xpath, '//*[@id="id"]').click
336
+ Clipboard.copy(user_id)
337
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
338
+ sleep(1.5)
339
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
340
+ Clipboard.copy(user_pw)
341
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
342
+ sleep(1.5)
343
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
344
+ sleep(2.5)
345
+ rescue => e
346
+ puts '-[√] 로딩 지연 접속 실패.......'.red
347
+ @driver.window_handles.each do |handle|
348
+ @driver.switch_to.window(handle)
349
+ begin
350
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
351
+ @driver.close
352
+ rescue Selenium::WebDriver::Error::WebDriverError => e
353
+ puts "Failed to close tab: #{e.message}"
354
+ end
355
+ end
356
+ return 0
357
+ end
341
358
 
342
359
  else
343
360
  # @driver.switch_to.default_content
344
361
  end
345
362
 
346
363
  begin
347
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
364
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
348
365
  #요소가 나타날 때까지 3초 동안 기다립니다.
349
366
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
350
367
 
351
368
  rescue => e
352
- puts '-[√] 로그인 실패!!.......'.red
353
- puts e
354
- @driver.close
369
+ puts '-[√] 로그인 실패.......'.red
370
+ @driver.window_handles.each do |handle|
371
+ @driver.switch_to.window(handle)
372
+ begin
373
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
374
+ @driver.close
375
+ rescue Selenium::WebDriver::Error::WebDriverError => e
376
+ puts "Failed to close tab: #{e.message}"
377
+ end
378
+ end
355
379
  return 0
356
- end
380
+ end
357
381
  end
358
382
 
359
383
  def create_id
@@ -652,8 +676,25 @@ class Naver
652
676
  rescue
653
677
  end
654
678
 
655
-
679
+ begin
656
680
  #제목 입력
681
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
682
+ #요소가 나타날 때까지 60초 동안 기다립니다.
683
+ wait.until { @driver.find_element(:xpath, '//*[@draggable="false"]') }
684
+ rescue => e
685
+ puts '-[√] 글 입력 필드 로딩 지연 접속 실패.......'.red
686
+ @driver.window_handles.each do |handle|
687
+ @driver.switch_to.window(handle)
688
+ begin
689
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
690
+ @driver.close
691
+ rescue Selenium::WebDriver::Error::WebDriverError => e
692
+ puts "Failed to close tab: #{e.message}"
693
+ end
694
+ end
695
+ return 0
696
+ end
697
+
657
698
  ele = @driver.find_element(:xpath, '//*[@draggable="false"]')
658
699
  @driver.action.click(ele).perform
659
700
  sleep(0.5)
@@ -1538,8 +1579,30 @@ class Naver
1538
1579
  end
1539
1580
 
1540
1581
 
1541
- @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]').click #1차 등록버튼
1542
- sleep(3)
1582
+ begin
1583
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
1584
+ #요소가 나타날 때까지 3초 동안 기다립니다.
1585
+ wait.until { @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]') }
1586
+ sleep(1.5)
1587
+ @driver.find_element(:xpath, '//*[@data-focus-lock="publishLayer"]').click #1차 등록버튼
1588
+ sleep(3)
1589
+ rescue => e
1590
+ puts '-[√] 로딩 지연 접속 실패.......'.red
1591
+ @driver.window_handles.each do |handle|
1592
+ @driver.switch_to.window(handle)
1593
+ begin
1594
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1595
+ @driver.close
1596
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1597
+ puts "Failed to close tab: #{e.message}"
1598
+ end
1599
+ end
1600
+ return 0
1601
+ end
1602
+
1603
+
1604
+
1605
+
1543
1606
  category = option['category']
1544
1607
  begin
1545
1608
  p category
@@ -1687,11 +1750,20 @@ class Naver
1687
1750
  end
1688
1751
 
1689
1752
  begin
1690
- @driver.close
1753
+ @driver.window_handles.each do |handle|
1754
+ @driver.switch_to.window(handle)
1755
+ begin
1756
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1757
+ @driver.close
1758
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1759
+ puts "Failed to close tab: #{e.message}"
1760
+ end
1761
+ end
1691
1762
  rescue
1692
1763
 
1693
1764
  end
1694
1765
 
1766
+
1695
1767
 
1696
1768
  end
1697
1769
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_duo
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