cafe_basics 0.0.32 → 0.0.35

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/cafe_basics.rb +103 -34
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fcdb4c34e5496f836951e76190096f36257b2f2f4159126dc45eac6e8fdf79e
4
- data.tar.gz: 0d0ca80b13f393e2ebbdba90098e86ce77fd9af897413230b3907b19a3cd868a
3
+ metadata.gz: 86e784a5d4c830f83dcce8fa7f2a974fdf3ac25e9de10220c7cef74956766fa6
4
+ data.tar.gz: d95d50e38c8798a7b629d07427bc6b197314a473a80b716f9233e211bf793751
5
5
  SHA512:
6
- metadata.gz: 62324a38a3d5452c556189c51cbe2da4dc68d09be622ffd4c174c4fe2c1f61158d4a91e637dec82c35671c0eca15430f09a6c8a1b672fbda639f4b1c49eb6564
7
- data.tar.gz: 86d1aff31c0374ff05e08ac7515845de33053e5ef5185f43c13d9e0917befe7dcbb953d95df14c55b1c9d3a5136f9e25c8caa768303f18aca08cff56138df8b8
6
+ metadata.gz: d4809c210cc9cfa202df29fd8f5f62c27d06e7c06fcf3b645f6b5510c6d42079b73a9966d6adcad0c456c7a01274b18e2b81942fc5dbd974c20c0cb73200659e
7
+ data.tar.gz: 0b205c7896c73baeddf8eed17ca5db33081bf57f1bdf593b7bc8a0f89f58d5ab8089a1522c5863b774164773dbf1cc6ebfb80f750d0622e6c7203dc03ee45145
data/lib/cafe_basics.rb CHANGED
@@ -233,9 +233,9 @@ class Naver
233
233
  options.add_argument('--disable-gpu')
234
234
  options.add_argument('--remote-debugging-port=9222')
235
235
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
236
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
236
+ @driver = Selenium::WebDriver.for(:chrome, options: options)
237
237
  rescue
238
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
238
+ @driver = Selenium::WebDriver.for(:chrome, options: options)
239
239
  end
240
240
  else
241
241
  begin
@@ -256,7 +256,7 @@ class Naver
256
256
  options.add_argument('--disable-gpu')
257
257
  options.add_argument('--remote-debugging-port=9222')
258
258
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
259
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
259
+ @driver = Selenium::WebDriver.for(:chrome, options: options)
260
260
  rescue => e
261
261
  puts e
262
262
  puts 'proxy error...'
@@ -270,9 +270,9 @@ class Naver
270
270
  options.add_argument('--disable-gpu')
271
271
  options.add_argument('--remote-debugging-port=9222')
272
272
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
273
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
273
+ @driver = Selenium::WebDriver.for(:chrome, options: options)
274
274
  rescue
275
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
275
+ @driver = Selenium::WebDriver.for(:chrome, options: options)
276
276
  end
277
277
  end
278
278
  end
@@ -310,39 +310,57 @@ class Naver
310
310
  sleep(1)
311
311
 
312
312
  begin
313
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
313
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
314
+ #요소가 나타날 때까지 3초 동안 기다립니다.
315
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
316
+ sleep(1.5)
317
+ check_cookie_login = 1
318
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
319
+ sleep(2.5)
320
+ rescue
321
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
314
322
  #요소가 나타날 때까지 3초 동안 기다립니다.
315
323
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
316
324
  sleep(1.5)
317
325
  @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
318
326
  check_cookie_login = 0
319
327
  sleep(1)
320
- rescue
321
- check_cookie_login = 1
322
- puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
323
- sleep(2.5)
324
328
  end
325
329
 
326
330
  if check_cookie_login == 0
327
331
  puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
328
332
  # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
329
333
  sleep(3)
330
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
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)
334
+ begin
335
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
336
+ #요소가 나타날 때까지 3초 동안 기다립니다.
337
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
338
+ sleep(1.5)
339
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
340
+ sleep(1.5)
341
+ @driver.find_element(:xpath, '//*[@id="id"]').click
342
+ Clipboard.copy(user_id)
343
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
344
+ sleep(1.5)
345
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
346
+ Clipboard.copy(user_pw)
347
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
348
+ sleep(1.5)
349
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
350
+ sleep(2.5)
351
+ rescue => e
352
+ puts '-[√] 로딩 지연 접속 실패.......'.red
353
+ @driver.window_handles.each do |handle|
354
+ @driver.switch_to.window(handle)
355
+ begin
356
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
357
+ @driver.close
358
+ rescue Selenium::WebDriver::Error::WebDriverError => e
359
+ puts "Failed to close tab: #{e.message}"
360
+ end
361
+ end
362
+ return 0
363
+ end
346
364
 
347
365
  else
348
366
  # @driver.switch_to.default_content
@@ -354,11 +372,18 @@ class Naver
354
372
  wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
355
373
 
356
374
  rescue => e
357
- puts '-[√] 로그인 실패!!.......'.red
358
- puts e
359
- @driver.close
375
+ puts '-[√] 로그인 실패.......'.red
376
+ @driver.window_handles.each do |handle|
377
+ @driver.switch_to.window(handle)
378
+ begin
379
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
380
+ @driver.close
381
+ rescue Selenium::WebDriver::Error::WebDriverError => e
382
+ puts "Failed to close tab: #{e.message}"
383
+ end
384
+ end
360
385
  return 0
361
- end
386
+ end
362
387
  end
363
388
 
364
389
  def create_id
@@ -664,8 +689,27 @@ class Naver
664
689
 
665
690
 
666
691
 
667
- sleep(1)
692
+
693
+ begin
694
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
695
+ #요소가 나타날 때까지 60초 동안 기다립니다.
696
+ wait.until { @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div/div[2]/div/textarea') }
697
+ sleep(1)
668
698
  @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div/div[2]/div/textarea').send_keys(title)
699
+ sleep(1)
700
+ rescue => e
701
+ puts '-[√] 제목 입력 필드 로딩 지연 접속 실패.......'.red
702
+ @driver.window_handles.each do |handle|
703
+ @driver.switch_to.window(handle)
704
+ begin
705
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
706
+ @driver.close
707
+ rescue Selenium::WebDriver::Error::WebDriverError => e
708
+ puts "Failed to close tab: #{e.message}"
709
+ end
710
+ end
711
+ return 0
712
+ end
669
713
 
670
714
 
671
715
 
@@ -675,8 +719,25 @@ class Naver
675
719
  sleep(2)
676
720
 
677
721
  sleep(2)
678
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
679
- @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
722
+ begin
723
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
724
+ #요소가 나타날 때까지 60초 동안 기다립니다.
725
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-bold"]/button[@data-type="toggle" and @data-name="bold"]') }
726
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
727
+ @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
728
+ rescue => e
729
+ puts '-[√] 글 입력 필드 로딩 지연 접속 실패.......'.red
730
+ @driver.window_handles.each do |handle|
731
+ @driver.switch_to.window(handle)
732
+ begin
733
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
734
+ @driver.close
735
+ rescue Selenium::WebDriver::Error::WebDriverError => e
736
+ puts "Failed to close tab: #{e.message}"
737
+ end
738
+ end
739
+ return 0
740
+ end
680
741
  sleep(2)
681
742
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
682
743
  sleep(1)
@@ -1593,7 +1654,15 @@ class Naver
1593
1654
 
1594
1655
 
1595
1656
  begin
1596
- @driver.close
1657
+ @driver.window_handles.each do |handle|
1658
+ @driver.switch_to.window(handle)
1659
+ begin
1660
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1661
+ @driver.close
1662
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1663
+ puts "Failed to close tab: #{e.message}"
1664
+ end
1665
+ end
1597
1666
  rescue
1598
1667
 
1599
1668
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.35
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-05 00:00:00.000000000 Z
11
+ date: 2025-02-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com