duo_blog_cafe_comment 0.0.33 → 0.0.39

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/duo_blog_cafe_comment.rb +155 -59
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7193298753e6e33d23865ab1394c64dfc49b2454298a9682ce99af0560b6026c
4
- data.tar.gz: 1b744c0037128597f3810aced569a0a410497d748815304027bd856fcde29e61
3
+ metadata.gz: 6898383e56ecfff90040a9a2a4979486003698e7635cba0107880fba64a635ff
4
+ data.tar.gz: 90bf4ac3602715f1e514a822322aea9d53c0008cf1ddd5553abc536897771d87
5
5
  SHA512:
6
- metadata.gz: 3308ffc287e8fb0c5ad1f2ca83fef5376386d9af878a927f60a3b76cfad5400baf2eab606049af257dc7c9cd879b09d4e2ea4fbe296daab29f429ad84e3a431c
7
- data.tar.gz: 11254145d57a9ca20c53043ea7a59062270ee587156612de267c3fc05c6ef17b9071b28edc2245de1dd4ac0bebb2d29756b8fc697c642eaaee70d3442ec178c0
6
+ metadata.gz: 9a0e9cba35c29cf928b90c54330680910362bcc58a1d57111fa36bcf8d478e8b917888bc494f26d108b7802f3b99b473b649645accacd36e587a250f2a6f918c
7
+ data.tar.gz: 150dfcb5f9e69533eb3d9bea4c315c1ac30665a88d9d659eb295b011eb90ddf3142a1200cf813db22c6cae0495b41a550b2fe637e9d844c56ee0bdae5c64a6bf
@@ -277,40 +277,77 @@ class Naver
277
277
 
278
278
  @driver.get(board_url)
279
279
  begin
280
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
281
- # 요소가 나타날 때까지 기다립니다.
282
- wait.until { @driver.find_element(:xpath, '//*[@class="tit-info-on"]') }
283
- @driver.find_element(:xpath, '//*[@class="tit-info-on"]').click
284
- rescue => e
285
- puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
286
- @driver.window_handles.each do |handle|
287
- @driver.switch_to.window(handle)
280
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
281
+ # 요소가 나타날 때까지 기다립니다.
282
+ wait.until { @driver.find_element(:xpath, '//*[@aria-controls="tab_cafe"]') }
283
+ @driver.find_element(:xpath, '//*[@aria-controls="tab_cafe"]').click
284
+ rescue
288
285
  begin
289
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
290
- @driver.close
291
- rescue Selenium::WebDriver::Error::WebDriverError => e
292
- puts "Failed to close tab: #{e.message}"
293
- end
294
- end
295
- return 0
296
- @driver.quit
297
- end
286
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
287
+ # 요소가 나타날 때까지 기다립니다.
288
+ wait.until { @driver.find_element(:xpath, '//*[@class="gm-tcol-t"]') }
289
+ @driver.find_element(:xpath, '//*[@class="gm-tcol-t"]').click
290
+ rescue
291
+ begin
292
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
293
+ # 요소가 나타날 때까지 기다립니다.
294
+ wait.until { @driver.find_element(:xpath, '//*[@class="tit-info-on"]') }
295
+ @driver.find_element(:xpath, '//*[@class="tit-info-on"]').click
296
+ rescue => e
297
+ puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
298
+ @driver.window_handles.each do |handle|
299
+ @driver.switch_to.window(handle)
300
+ begin
301
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
302
+ @driver.close
303
+ rescue Selenium::WebDriver::Error::WebDriverError => e
304
+ puts "Failed to close tab: #{e.message}"
305
+ end
306
+ end
307
+ return 0
308
+ @driver.quit
309
+ end
310
+ end
311
+
312
+ end
313
+
298
314
 
299
315
  ################################################################################ 프로그램에 설정한 이미지랑 글까지 등록
300
316
  if option['닉네임변경'] == 'true'
301
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
302
- # 요소가 나타날 때까지 기다립니다.
303
- wait.until { @driver.find_element(:xpath, '//*[@class="tit-action"]') }
304
- @driver.find_element(:xpath, '//*[@class="tit-action"]').click
305
- sleep(1)
317
+ begin
318
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
319
+ # 요소가 나타날 때까지 기다립니다.
320
+ wait.until { @driver.find_element(:xpath, '//button[@aria-controls="tab_my"]') }
321
+ @driver.find_element(:xpath, '//button[@aria-controls="tab_my"]').click
322
+ sleep(1)
323
+ rescue
324
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
325
+ # 요소가 나타날 때까지 기다립니다.
326
+ wait.until { @driver.find_element(:xpath, '//*[@class="tit-action"]') }
327
+ @driver.find_element(:xpath, '//*[@class="tit-action"]').click
328
+ sleep(1)
329
+ end
306
330
 
307
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
308
- wait.until { @driver.find_element(:link_text, '프로필 변경하기') }
309
- # "프로필 변경하기" 링크 찾기
310
- element = @driver.find_element(:link_text, '프로필 변경하기')
311
- # Action을 이용하여 컨트롤 키를 누르고 클릭
312
- @driver.action.key_down(:control).click(element).key_up(:control).perform
313
- sleep(1)
331
+
332
+
333
+
334
+ begin
335
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
336
+ wait.until { @driver.find_element(:xpath, '//button[@title="내 프로필 변경하기"]') }
337
+ # "프로필 변경하기" 링크 찾기
338
+ element = @driver.find_element(:xpath, '//button[@title="내 프로필 변경하기"]')
339
+ # Action을 이용하여 컨트롤 키를 누르고 클릭
340
+ @driver.action.key_down(:control).click(element).key_up(:control).perform
341
+ sleep(1)
342
+ rescue
343
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
344
+ wait.until { @driver.find_element(:xpath, '//div[@class="prfl_thmb"]/a[@class="lab_thmb"]') }
345
+ # "프로필 변경하기" 링크 찾기
346
+ element = @driver.find_element(:xpath, '//div[@class="prfl_thmb"]/a[@class="lab_thmb"]')
347
+ # Action을 이용하여 컨트롤 키를 누르고 클릭
348
+ @driver.action.key_down(:control).click(element).key_up(:control).perform
349
+ sleep(1)
350
+ end
314
351
 
315
352
  # 두 번째 탭으로 전환
316
353
  @driver.switch_to.window(@driver.window_handles[1])
@@ -353,12 +390,30 @@ class Naver
353
390
 
354
391
 
355
392
  begin
356
- # 아이프레임 요소가 나타날 때까지 기다립니다.
357
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
358
- wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
359
- sleep(1)
360
- @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
393
+ begin
394
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
395
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
396
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_content"]') } # 아이프레임 선택
397
+ sleep(1)
398
+ rescue
399
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
400
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
401
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
402
+ sleep(1)
403
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
404
+ @in_iframe = true
405
+ end
361
406
 
407
+ begin
408
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
409
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
410
+ wait.until { @driver.find_element(:xpath, '//*[@class="FormInputCheck"]') }
411
+ sleep(1)
412
+ @driver.find_element(:xpath, '//*[@class="FormInputCheck"]').click
413
+ sleep(2)
414
+ rescue
415
+
416
+ end
362
417
 
363
418
  # 한 페이지에 게시글이 15개씩 있다고 가정
364
419
  articles_per_page = 15
@@ -385,19 +440,36 @@ class Naver
385
440
  # 페이지 넘기기: 다음 페이지로 이동 (class="prev-next" 아래의 페이지 링크 클릭)
386
441
 
387
442
  begin
388
- next_page_button = @driver.find_element(:xpath, "//div[@class='prev-next']/a[contains(text(), 'Next')]")
389
- next_page_button.click
390
- sleep(2) # 페이지가 로드되도록 대기
391
- rescue Selenium::WebDriver::Error::NoSuchElementError
392
- puts "더 이상 페이지가 없습니다."
393
- break # 이상 페이지가 없다면 종료
443
+ next_page_number = (current_page + 1).to_s
444
+
445
+ # 페이지 번호 버튼들 찾기
446
+ pagination_buttons = @driver.find_elements(:css, 'div.Pagination button.btn.number')
447
+
448
+ # 텍스트가 다음 페이지 숫자와 같은 버튼 찾기
449
+ next_button = pagination_buttons.find { |btn| btn.text == next_page_number }
450
+
451
+ if next_button
452
+ next_button.click
453
+ sleep(2) # 페이지가 로드되도록 대기
454
+ current_page += 1
455
+ else
456
+ puts "다음 페이지 버튼을 찾을 수 없습니다. 현재 페이지: #{current_page}"
457
+ break
458
+ end
459
+
460
+ rescue => e
461
+ puts "페이지 넘김 중 오류 발생: #{e.message}"
462
+ break
394
463
  end
464
+ end
465
+ # 수집한 URL 출력
395
466
 
396
- # 페이지 번호 갱신
397
- current_page += 1
467
+ if @in_iframe
468
+ @driver.switch_to.default_content
469
+ @in_iframe = false
470
+ puts "프레임에서 default_content로 자동 복귀"
398
471
  end
399
- # 수집한 URL 출력
400
- @driver.switch_to.default_content() # 아이프레임 해제
472
+
401
473
  puts "수집한 URL들: #{collected_urls}"
402
474
 
403
475
 
@@ -845,11 +917,19 @@ class Naver
845
917
  sleep(1)
846
918
 
847
919
  begin
848
- # 아이프레임 요소가 나타날 때까지 기다립니다.
849
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
850
- wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
851
- sleep(1)
852
- @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
920
+ begin
921
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
922
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
923
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_content"]') } # 아이프레임 선택
924
+ sleep(1)
925
+ rescue
926
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
927
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
928
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
929
+ sleep(1)
930
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
931
+ @in_iframe = true
932
+ end
853
933
 
854
934
 
855
935
  # 한 페이지에 게시글이 15개씩 있다고 가정
@@ -880,19 +960,35 @@ class Naver
880
960
  # 페이지 넘기기: 다음 페이지로 이동 (class="prev-next" 아래의 페이지 링크 클릭)
881
961
 
882
962
  begin
883
- next_page_button = @driver.find_element(:xpath, "//div[@class='prev-next']/a[contains(text(), 'Next')]")
884
- next_page_button.click
885
- sleep(2) # 페이지가 로드되도록 대기
886
- rescue Selenium::WebDriver::Error::NoSuchElementError
887
- puts "더 이상 페이지가 없습니다."
888
- break # 더 이상 페이지가 없다면 종료
889
- end
963
+ next_page_number = (current_page + 1).to_s
890
964
 
891
- # 페이지 번호 갱신
892
- current_page += 1
965
+ # 페이지 번호 버튼들 찾기
966
+ pagination_buttons = @driver.find_elements(:css, 'div.Pagination button.btn.number')
967
+
968
+ # 텍스트가 다음 페이지 숫자와 같은 버튼 찾기
969
+ next_button = pagination_buttons.find { |btn| btn.text == next_page_number }
970
+
971
+ if next_button
972
+ next_button.click
973
+ sleep(2) # 페이지가 로드되도록 대기
974
+ current_page += 1
975
+ else
976
+ puts "다음 페이지 버튼을 찾을 수 없습니다. 현재 페이지: #{current_page}"
977
+ break
978
+ end
979
+
980
+ rescue => e
981
+ puts "페이지 넘김 중 오류 발생: #{e.message}"
982
+ break
983
+ end
893
984
  end
894
985
  # 수집한 URL 출력
895
- @driver.switch_to.default_content() # 아이프레임 해제
986
+
987
+ if @in_iframe
988
+ @driver.switch_to.default_content
989
+ @in_iframe = false
990
+ puts "프레임에서 default_content로 자동 복귀"
991
+ end
896
992
  puts "수집한 URL들: #{collected_urls}"
897
993
 
898
994
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duo_blog_cafe_comment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-26 00:00:00.000000000 Z
10
+ date: 2025-04-16 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: File to Clipboard gem
14
13
  email: mymin26@naver.com
@@ -21,7 +20,6 @@ homepage: ''
21
20
  licenses:
22
21
  - zon
23
22
  metadata: {}
24
- post_install_message:
25
23
  rdoc_options: []
26
24
  require_paths:
27
25
  - lib
@@ -36,8 +34,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
38
36
  requirements: []
39
- rubygems_version: 3.3.7
40
- signing_key:
37
+ rubygems_version: 3.6.7
41
38
  specification_version: 4
42
39
  summary: file to clipboard
43
40
  test_files: []