duo_cafe_comment 0.0.23 → 0.0.30

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_cafe_comment.rb +162 -59
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30534cad6a47ad9347c4af24b7c4e99d65131ffda83f8b09264265babe89fc63
4
- data.tar.gz: 5582b2fa31a244917e0500727c832e6596f46286a33d20910634a5d03e2ba917
3
+ metadata.gz: 2cf15e640188b756aeac369083c1a469949827105bca8d60be4034079b326707
4
+ data.tar.gz: 226e35212db0d13a2bf7d7df00f79cadec6ad25ad3cacdd981ee02aa051ec94e
5
5
  SHA512:
6
- metadata.gz: f5635f657728b9ff7326c233daf2c67a00c961aeff6af54737fa91247f48015f19849fd610500cba441c20de71b7503b7d8397b40fbc48542dd4471eb2420860
7
- data.tar.gz: 01101f5d3bf5f386ef99bd5faac7f90d18eb74525287e7c917b97dbfb5b7acbc15eaa75ca413f98398907b8699a0cb95eb779866158db34795e246ca4049da0b
6
+ metadata.gz: de49b65415cc1796cc536004be96c2b44d513405610b1a3151e311fdc7e637a8caee40e32e5f370b23a72803dd53f9de0fee95d72ff22b385947997edc224c5a
7
+ data.tar.gz: 4af472a80a2a24d30201257f39e46c8649a14538800c4b055cc345bc9c1ea40712a62aad2cf759a78b6fcb45f5b6e3ef64e36e8588c65f265111a7382586dcf7
@@ -278,38 +278,78 @@ class Naver
278
278
  begin
279
279
  wait = Selenium::WebDriver::Wait.new(:timeout => 10)
280
280
  # 요소가 나타날 때까지 기다립니다.
281
- wait.until { @driver.find_element(:xpath, '//*[@class="tit-info-on"]') }
282
- @driver.find_element(:xpath, '//*[@class="tit-info-on"]').click
283
- rescue => e
284
- puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
285
- @driver.window_handles.each do |handle|
286
- @driver.switch_to.window(handle)
287
- begin
288
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
289
- @driver.close
290
- rescue Selenium::WebDriver::Error::WebDriverError => e
291
- puts "Failed to close tab: #{e.message}"
292
- end
293
- end
294
- return 0
295
- @driver.quit
281
+ wait.until { @driver.find_element(:xpath, '//*[@aria-controls="tab_cafe"]') }
282
+ @driver.find_element(:xpath, '//*[@aria-controls="tab_cafe"]').click
283
+ rescue
284
+ begin
285
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
286
+ # 요소가 나타날 때까지 기다립니다.
287
+ wait.until { @driver.find_element(:xpath, '//*[@class="gm-tcol-t"]') }
288
+ @driver.find_element(:xpath, '//*[@class="gm-tcol-t"]').click
289
+ rescue
290
+ begin
291
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
292
+ # 요소가 나타날 때까지 기다립니다.
293
+ wait.until { @driver.find_element(:xpath, '//*[@class="tit-info-on"]') }
294
+ @driver.find_element(:xpath, '//*[@class="tit-info-on"]').click
295
+ rescue => e
296
+ puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
297
+ @driver.window_handles.each do |handle|
298
+ @driver.switch_to.window(handle)
299
+ begin
300
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
301
+ @driver.close
302
+ rescue Selenium::WebDriver::Error::WebDriverError => e
303
+ puts "Failed to close tab: #{e.message}"
304
+ end
305
+ end
306
+ return 0
307
+ @driver.quit
308
+ end
309
+ end
310
+
296
311
  end
312
+
313
+
297
314
 
298
315
  ################################################################################ 프로그램에 설정한 이미지랑 글까지 등록
299
316
  if option['닉네임변경'] == 'true'
300
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
301
- # 요소가 나타날 때까지 기다립니다.
302
- wait.until { @driver.find_element(:xpath, '//*[@class="tit-action"]') }
303
- @driver.find_element(:xpath, '//*[@class="tit-action"]').click
304
- 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
330
+
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
305
351
 
306
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
307
- wait.until { @driver.find_element(:link_text, '프로필 변경하기') }
308
- # "프로필 변경하기" 링크 찾기
309
- element = @driver.find_element(:link_text, '프로필 변경하기')
310
- # Action을 이용하여 컨트롤 키를 누르고 클릭
311
- @driver.action.key_down(:control).click(element).key_up(:control).perform
312
- sleep(1)
352
+
313
353
 
314
354
  # 두 번째 탭으로 전환
315
355
  @driver.switch_to.window(@driver.window_handles[1])
@@ -318,7 +358,7 @@ class Naver
318
358
  wait.until { @driver.find_element(:xpath, '//*[@class="btn_delete"]') }
319
359
  @driver.find_element(:xpath, '//*[@class="btn_delete"]').click
320
360
  sleep(1)
321
- @driver.find_element(:xpath, '//*[@id="app"]/div/div[2]/div[2]/div[1]/div[1]/textarea').click
361
+ @driver.find_element(:xpath, '/html/body/div/div/div[2]/div[2]/div[1]/div[1]/textarea').click
322
362
  @nickname = nickname
323
363
  @driver.find_element(:xpath, '//*[@id="app"]/div/div[2]/div[2]/div[1]/div[1]/textarea').send_keys(nickname)
324
364
  sleep(1)
@@ -352,12 +392,30 @@ class Naver
352
392
 
353
393
 
354
394
  begin
355
- # 아이프레임 요소가 나타날 때까지 기다립니다.
356
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
357
- wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
358
- sleep(1)
359
- @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
395
+ begin
396
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
397
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
398
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_content"]') } # 아이프레임 선택
399
+ sleep(1)
400
+ rescue
401
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
402
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
403
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
404
+ sleep(1)
405
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
406
+ @in_iframe = true
407
+ end
360
408
 
409
+ begin
410
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
411
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
412
+ wait.until { @driver.find_element(:xpath, '//*[@class="FormInputCheck"]') }
413
+ sleep(1)
414
+ @driver.find_element(:xpath, '//*[@class="FormInputCheck"]').click
415
+ sleep(2)
416
+ rescue
417
+
418
+ end
361
419
 
362
420
  # 한 페이지에 게시글이 15개씩 있다고 가정
363
421
  articles_per_page = 15
@@ -384,19 +442,36 @@ class Naver
384
442
  # 페이지 넘기기: 다음 페이지로 이동 (class="prev-next" 아래의 페이지 링크 클릭)
385
443
 
386
444
  begin
387
- next_page_button = @driver.find_element(:xpath, "//div[@class='prev-next']/a[contains(text(), 'Next')]")
388
- next_page_button.click
389
- sleep(2) # 페이지가 로드되도록 대기
390
- rescue Selenium::WebDriver::Error::NoSuchElementError
391
- puts "더 이상 페이지가 없습니다."
392
- break # 이상 페이지가 없다면 종료
445
+ next_page_number = (current_page + 1).to_s
446
+
447
+ # 페이지 번호 버튼들 찾기
448
+ pagination_buttons = @driver.find_elements(:css, 'div.Pagination button.btn.number')
449
+
450
+ # 텍스트가 다음 페이지 숫자와 같은 버튼 찾기
451
+ next_button = pagination_buttons.find { |btn| btn.text == next_page_number }
452
+
453
+ if next_button
454
+ next_button.click
455
+ sleep(2) # 페이지가 로드되도록 대기
456
+ current_page += 1
457
+ else
458
+ puts "다음 페이지 버튼을 찾을 수 없습니다. 현재 페이지: #{current_page}"
459
+ break
460
+ end
461
+
462
+ rescue => e
463
+ puts "페이지 넘김 중 오류 발생: #{e.message}"
464
+ break
393
465
  end
466
+ end
467
+ # 수집한 URL 출력
394
468
 
395
- # 페이지 번호 갱신
396
- current_page += 1
469
+ if @in_iframe
470
+ @driver.switch_to.default_content
471
+ @in_iframe = false
472
+ puts "프레임에서 default_content로 자동 복귀"
397
473
  end
398
- # 수집한 URL 출력
399
- @driver.switch_to.default_content() # 아이프레임 해제
474
+
400
475
  puts "수집한 URL들: #{collected_urls}"
401
476
 
402
477
 
@@ -844,11 +919,22 @@ class Naver
844
919
  sleep(1)
845
920
 
846
921
  begin
847
- # 아이프레임 요소가 나타날 때까지 기다립니다.
848
- wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
849
- wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
850
- sleep(1)
851
- @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
922
+ begin
923
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
924
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
925
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_content"]') } # 아이프레임 선택
926
+ sleep(1)
927
+ rescue
928
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
929
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
930
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
931
+ sleep(1)
932
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
933
+ @in_iframe = true
934
+ end
935
+
936
+
937
+
852
938
 
853
939
 
854
940
  # 한 페이지에 게시글이 15개씩 있다고 가정
@@ -879,19 +965,36 @@ class Naver
879
965
  # 페이지 넘기기: 다음 페이지로 이동 (class="prev-next" 아래의 페이지 링크 클릭)
880
966
 
881
967
  begin
882
- next_page_button = @driver.find_element(:xpath, "//div[@class='prev-next']/a[contains(text(), 'Next')]")
883
- next_page_button.click
884
- sleep(2) # 페이지가 로드되도록 대기
885
- rescue Selenium::WebDriver::Error::NoSuchElementError
886
- puts "더 이상 페이지가 없습니다."
887
- break # 더 이상 페이지가 없다면 종료
888
- end
968
+ next_page_number = (current_page + 1).to_s
889
969
 
890
- # 페이지 번호 갱신
891
- current_page += 1
970
+ # 페이지 번호 버튼들 찾기
971
+ pagination_buttons = @driver.find_elements(:css, 'div.Pagination button.btn.number')
972
+
973
+ # 텍스트가 다음 페이지 숫자와 같은 버튼 찾기
974
+ next_button = pagination_buttons.find { |btn| btn.text == next_page_number }
975
+
976
+ if next_button
977
+ next_button.click
978
+ sleep(2) # 페이지가 로드되도록 대기
979
+ current_page += 1
980
+ else
981
+ puts "다음 페이지 버튼을 찾을 수 없습니다. 현재 페이지: #{current_page}"
982
+ break
983
+ end
984
+
985
+ rescue => e
986
+ puts "페이지 넘김 중 오류 발생: #{e.message}"
987
+ break
988
+ end
892
989
  end
893
990
  # 수집한 URL 출력
894
- @driver.switch_to.default_content() # 아이프레임 해제
991
+
992
+ if @in_iframe
993
+ @driver.switch_to.default_content
994
+ @in_iframe = false
995
+ puts "프레임에서 default_content로 자동 복귀"
996
+ end
997
+
895
998
  puts "수집한 URL들: #{collected_urls}"
896
999
 
897
1000
 
@@ -2231,7 +2334,7 @@ class Wordpress
2231
2334
  }
2232
2335
 
2233
2336
  text_column('게시판/글URL LIST'){
2234
-
2337
+ editable true
2235
2338
  }
2236
2339
 
2237
2340
  cell_rows @data['게시판설정']['게시판']
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duo_cafe_comment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-07 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: []