cafe_basics 0.0.33 → 0.0.36
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.
- checksums.yaml +4 -4
- data/lib/cafe_basics.rb +104 -36
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3a75f8f3ad8d9583e6cc78b40d87e20545f7be7a1a663a80b8edd2115490f5
|
4
|
+
data.tar.gz: 0e56ba81d26c14152b828fee1bba01ee804a27d9fd208907d33216381dcbe4e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2339dfe09a5eff4855164f81748d7019783f24ca7d082933b84a85851336829b1cbeee94511bc7825177e273298be69efe51bae166798c8fc9498e5e9b2f2bc7
|
7
|
+
data.tar.gz: f731ca9880b9a38258bc337af9cb30996ef876eb206620b703e3ec37eb9468349795e6b75839f38de4d264aa6ebb5cde3c28abeffd153d2abc6431823df054e6
|
data/lib/cafe_basics.rb
CHANGED
@@ -226,6 +226,8 @@ class Naver
|
|
226
226
|
begin
|
227
227
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
228
228
|
options = Selenium::WebDriver::Chrome::Options.new
|
229
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
230
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
229
231
|
options.page_load_strategy = :normal
|
230
232
|
options.timeouts = {page_load: 20_000}
|
231
233
|
options.page_load_strategy = 'none'
|
@@ -241,13 +243,8 @@ class Naver
|
|
241
243
|
begin
|
242
244
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
243
245
|
options = Selenium::WebDriver::Chrome::Options.new
|
244
|
-
#
|
245
|
-
|
246
|
-
# profile['network.proxy.http'] = proxy.split(':')[0]
|
247
|
-
# profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
|
248
|
-
# options = Selenium::WebDriver::Chrome::Options.new
|
249
|
-
# options.profile = profile
|
250
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
246
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
247
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
251
248
|
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
252
249
|
options.page_load_strategy = :normal
|
253
250
|
options.timeouts = {page_load: 20_000}
|
@@ -263,6 +260,8 @@ class Naver
|
|
263
260
|
begin
|
264
261
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
265
262
|
options = Selenium::WebDriver::Chrome::Options.new
|
263
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
264
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
266
265
|
options.page_load_strategy = :normal
|
267
266
|
options.timeouts = {page_load: 20_000}
|
268
267
|
options.page_load_strategy = 'none'
|
@@ -310,39 +309,57 @@ class Naver
|
|
310
309
|
sleep(1)
|
311
310
|
|
312
311
|
begin
|
313
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
312
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
313
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
314
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
315
|
+
sleep(1.5)
|
316
|
+
check_cookie_login = 1
|
317
|
+
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
318
|
+
sleep(2.5)
|
319
|
+
rescue
|
320
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
314
321
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
315
322
|
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
|
316
323
|
sleep(1.5)
|
317
324
|
@driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
|
318
325
|
check_cookie_login = 0
|
319
326
|
sleep(1)
|
320
|
-
rescue
|
321
|
-
check_cookie_login = 1
|
322
|
-
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
323
|
-
sleep(2.5)
|
324
327
|
end
|
325
328
|
|
326
329
|
if check_cookie_login == 0
|
327
330
|
puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
|
328
331
|
# @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
|
329
332
|
sleep(3)
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
333
|
+
begin
|
334
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
335
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
336
|
+
wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
|
337
|
+
sleep(1.5)
|
338
|
+
@driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
|
339
|
+
sleep(1.5)
|
340
|
+
@driver.find_element(:xpath, '//*[@id="id"]').click
|
341
|
+
Clipboard.copy(user_id)
|
342
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
343
|
+
sleep(1.5)
|
344
|
+
@driver.find_element(:xpath, '//*[@id="pw"]').click
|
345
|
+
Clipboard.copy(user_pw)
|
346
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
347
|
+
sleep(1.5)
|
348
|
+
@driver.find_element(:xpath, '//*[@id="log.login"]').click
|
349
|
+
sleep(2.5)
|
350
|
+
rescue => e
|
351
|
+
puts '-[√] 로딩 지연 접속 실패.......'.red
|
352
|
+
@driver.window_handles.each do |handle|
|
353
|
+
@driver.switch_to.window(handle)
|
354
|
+
begin
|
355
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
356
|
+
@driver.close
|
357
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
358
|
+
puts "Failed to close tab: #{e.message}"
|
359
|
+
end
|
360
|
+
end
|
361
|
+
return 0
|
362
|
+
end
|
346
363
|
|
347
364
|
else
|
348
365
|
# @driver.switch_to.default_content
|
@@ -354,11 +371,18 @@ class Naver
|
|
354
371
|
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
355
372
|
|
356
373
|
rescue => e
|
357
|
-
puts '-[√] 로그인
|
358
|
-
|
359
|
-
|
374
|
+
puts '-[√] 로그인 실패.......'.red
|
375
|
+
@driver.window_handles.each do |handle|
|
376
|
+
@driver.switch_to.window(handle)
|
377
|
+
begin
|
378
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
379
|
+
@driver.close
|
380
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
381
|
+
puts "Failed to close tab: #{e.message}"
|
382
|
+
end
|
383
|
+
end
|
360
384
|
return 0
|
361
|
-
end
|
385
|
+
end
|
362
386
|
end
|
363
387
|
|
364
388
|
def create_id
|
@@ -664,8 +688,27 @@ class Naver
|
|
664
688
|
|
665
689
|
|
666
690
|
|
667
|
-
|
691
|
+
|
692
|
+
begin
|
693
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
694
|
+
#요소가 나타날 때까지 60초 동안 기다립니다.
|
695
|
+
wait.until { @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div/div[2]/div/textarea') }
|
696
|
+
sleep(1)
|
668
697
|
@driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div/div[2]/div/textarea').send_keys(title)
|
698
|
+
sleep(1)
|
699
|
+
rescue => e
|
700
|
+
puts '-[√] 제목 입력 필드 로딩 지연 접속 실패.......'.red
|
701
|
+
@driver.window_handles.each do |handle|
|
702
|
+
@driver.switch_to.window(handle)
|
703
|
+
begin
|
704
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
705
|
+
@driver.close
|
706
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
707
|
+
puts "Failed to close tab: #{e.message}"
|
708
|
+
end
|
709
|
+
end
|
710
|
+
return 0
|
711
|
+
end
|
669
712
|
|
670
713
|
|
671
714
|
|
@@ -675,8 +718,25 @@ class Naver
|
|
675
718
|
sleep(2)
|
676
719
|
|
677
720
|
sleep(2)
|
678
|
-
|
679
|
-
|
721
|
+
begin
|
722
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
723
|
+
#요소가 나타날 때까지 60초 동안 기다립니다.
|
724
|
+
wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-bold"]/button[@data-type="toggle" and @data-name="bold"]') }
|
725
|
+
@driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
|
726
|
+
@driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
|
727
|
+
rescue => e
|
728
|
+
puts '-[√] 글 입력 필드 로딩 지연 접속 실패.......'.red
|
729
|
+
@driver.window_handles.each do |handle|
|
730
|
+
@driver.switch_to.window(handle)
|
731
|
+
begin
|
732
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
733
|
+
@driver.close
|
734
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
735
|
+
puts "Failed to close tab: #{e.message}"
|
736
|
+
end
|
737
|
+
end
|
738
|
+
return 0
|
739
|
+
end
|
680
740
|
sleep(2)
|
681
741
|
@driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
|
682
742
|
sleep(1)
|
@@ -1593,7 +1653,15 @@ class Naver
|
|
1593
1653
|
|
1594
1654
|
|
1595
1655
|
begin
|
1596
|
-
@driver.
|
1656
|
+
@driver.window_handles.each do |handle|
|
1657
|
+
@driver.switch_to.window(handle)
|
1658
|
+
begin
|
1659
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1660
|
+
@driver.close
|
1661
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1662
|
+
puts "Failed to close tab: #{e.message}"
|
1663
|
+
end
|
1664
|
+
end
|
1597
1665
|
rescue
|
1598
1666
|
|
1599
1667
|
end
|