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.
- checksums.yaml +4 -4
- data/lib/duo_blog_cafe_comment.rb +155 -59
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6898383e56ecfff90040a9a2a4979486003698e7635cba0107880fba64a635ff
|
4
|
+
data.tar.gz: 90bf4ac3602715f1e514a822322aea9d53c0008cf1ddd5553abc536897771d87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
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
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
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
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
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
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
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
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
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
|
-
|
467
|
+
if @in_iframe
|
468
|
+
@driver.switch_to.default_content
|
469
|
+
@in_iframe = false
|
470
|
+
puts "프레임에서 default_content로 자동 복귀"
|
398
471
|
end
|
399
|
-
|
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
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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.
|
40
|
-
signing_key:
|
37
|
+
rubygems_version: 3.6.7
|
41
38
|
specification_version: 4
|
42
39
|
summary: file to clipboard
|
43
40
|
test_files: []
|