zon_blog_comment 0.0.30 → 0.0.31

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/zon_blog_comment.rb +66 -15
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 996ffe614c8c44d4ef162f0e428e70ecfdb31f02473debf7d3d46669345a9505
4
- data.tar.gz: a20731fa0f6ab4f4f5f182a48881b41e756773b19108bf6255c3007a547b2f3c
3
+ metadata.gz: babb183b540394e4bcca1e63da73c4c3ab4ec449e269b8b04bf13abf33162200
4
+ data.tar.gz: 7c176b8a3eff6e31a7dc5687df89a7e4409f0a6fb095f924f0cea7797538a839
5
5
  SHA512:
6
- metadata.gz: 6ac3883ec2fb3ff48c837bf446818ef333aa7b87a7c8170138bbb3e92f23639d6f2472a40fedd2fbef08a993e73b64ddd393d64e72a0baab0d6527fea7e95305
7
- data.tar.gz: 540ec95f9dd49a83b136494725117693aeb035212c27ae4bc587871fb1f09984322953377d0ff35f74cae467d7047d229e2f666eb2acb02761d6f43bb22e0b6a
6
+ metadata.gz: c1c20099b8538a693e5db9a5ba3be59a91576ae831c490588f2c0516e09a5de4c58abfb4725c5c7e27731208b108aa8a28ac97e5405dbd97828954096a1e37d0
7
+ data.tar.gz: 9fe93a2291b36a7ca6ab5abd52ce900ec30ac730bd3e79b842f461838ebfae9e33117090538475ba6df952aef24920aedfb390d31907feac9883d6dc37734634
@@ -459,8 +459,32 @@ class Naver
459
459
  sleep(1)
460
460
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
461
461
  sleep(1)
462
- @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
463
- sleep(2)
462
+ begin
463
+ @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
464
+ sleep(2)
465
+ rescue
466
+ begin
467
+ @driver.find_element(:xpath, '//*[@class="off itemfont _doNclick _param(false|blog|)"]').click
468
+ sleep(2)
469
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
470
+ wait.until { @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]') }
471
+ @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
472
+ sleep(2)
473
+ rescue => e
474
+ @driver.window_handles.each do |handle|
475
+ @driver.switch_to.window(handle)
476
+ begin
477
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
478
+ puts 'id="toplistSpanBlind" 요소를 찾지 못했습니다.'
479
+ @driver.close
480
+ rescue Selenium::WebDriver::Error::WebDriverError => e
481
+ puts "Failed to close tab: #{e.message}"
482
+ end
483
+ end
484
+ @driver.quit
485
+ end
486
+ end
487
+
464
488
 
465
489
  begin
466
490
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
@@ -479,22 +503,49 @@ class Naver
479
503
  sleep(2)
480
504
  element.send_keys(:return)
481
505
  sleep(1)
482
- rescue
506
+ rescue => e
507
+ @driver.window_handles.each do |handle|
508
+ @driver.switch_to.window(handle)
509
+ begin
510
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
511
+ puts 'class="aline" 요소를 찾지 못했습니다.'
512
+ @driver.close
513
+ rescue Selenium::WebDriver::Error::WebDriverError => e
514
+ puts "Failed to close tab: #{e.message}"
515
+ end
516
+ end
517
+ @driver.quit
483
518
  end
484
519
  end
485
520
 
486
-
487
- # WebDriverWait과 expected_conditions 가져오기
488
- wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 10초 대기
521
+ begin
522
+ # WebDriverWait과 expected_conditions 가져오기
523
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 10초 대기
524
+
525
+ # 요소가 화면에 보일 때까지 대기 후 바로 클릭
526
+ wait.until {
527
+ el = @driver.find_element(:xpath, '//div[@id="changeListCount"]//a[@data-value="30"]')
528
+ el.displayed? # 요소가 화면에 보이는지 확인
529
+ }
530
+ # 요소 클릭
531
+ @driver.find_element(:xpath, '//div[@id="changeListCount"]//a[@data-value="30"]').click
532
+ sleep(1)
533
+ rescue => e
534
+ @driver.window_handles.each do |handle|
535
+ @driver.switch_to.window(handle)
536
+ begin
537
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
538
+ puts 'data-value="30" 요소를 찾지 못했습니다.'
539
+ @driver.close
540
+ rescue Selenium::WebDriver::Error::WebDriverError => e
541
+ puts "Failed to close tab: #{e.message}"
542
+ end
543
+ end
544
+ @driver.quit
545
+ end
546
+
547
+
489
548
 
490
- # 요소가 화면에 보일 때까지 대기 후 바로 클릭
491
- wait.until {
492
- el = @driver.find_element(:xpath, '//div[@id="changeListCount"]//a[@data-value="30"]')
493
- el.displayed? # 요소가 화면에 보이는지 확인
494
- }
495
- # 요소 클릭
496
- @driver.find_element(:xpath, '//div[@id="changeListCount"]//a[@data-value="30"]').click
497
- sleep(1)
498
549
 
499
550
 
500
551
  @driver.switch_to.default_content
@@ -504,7 +555,7 @@ class Naver
504
555
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
505
556
  sleep(1)
506
557
 
507
- # 수집된 URL을 저장할 배열
558
+ # 수집된 URL을 저장할 배열
508
559
  collected_urls = []
509
560
 
510
561
  # 현재 페이지에서 수집할 링크 개수
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zon_blog_comment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon