duo_blog_cafe_comment 0.0.32 → 0.0.37

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 +142 -65
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1549bef29eb812bdb4b0ce9a5b7abee2d9683767c26cce7defb762a9fa787026
4
- data.tar.gz: 877087449f0095c2ede208694b2970ab196abe411c26ce0f887fcb958b2f76b1
3
+ metadata.gz: e21fccc9307baa64613e778c80d18d8137ab0821fb6827cd29b909f8912aa492
4
+ data.tar.gz: 98a4eb3b3946b5b6ff9e90b43a40302fe7a66f93fd2ec2945e938f654fcc08b6
5
5
  SHA512:
6
- metadata.gz: d0bf70c2d6430627433c372831a33b6beb5ade511bcbd6279d4db97f772187b33d265000df9649994c302056d3907a78e4763b75313b162c9b24f9cf9769fd0f
7
- data.tar.gz: ed8ea994c222366ba81508131ea83c99157faf6787afa8de27fe50f0dff3dcd7142e01968046bb3f1aba6b9ca64d3d4e25ea1c5208b1611393a27e81cb7f5651
6
+ metadata.gz: 4c6ad21e7c37d7b80f16466e9743ce1ca586cdd72c7de638e631edd17c277cff9d13d590b4f521ad90d4467ad822181fd9d44750745cffa9d82f9372ba8e3378
7
+ data.tar.gz: b54a10df56230c15382e7ec8f98dc893e9c024c67640e764268e81586dd04662c68ea94d2eec1d3f54110c6ab5936832a77dfa5acf3033493303e755bb380027
@@ -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,11 +390,19 @@ 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
 
362
407
 
363
408
  # 한 페이지에 게시글이 15개씩 있다고 가정
@@ -397,7 +442,13 @@ class Naver
397
442
  current_page += 1
398
443
  end
399
444
  # 수집한 URL 출력
400
- @driver.switch_to.default_content() # 아이프레임 해제
445
+
446
+ if @in_iframe
447
+ @driver.switch_to.default_content
448
+ @in_iframe = false
449
+ puts "프레임에서 default_content로 자동 복귀"
450
+ end
451
+
401
452
  puts "수집한 URL들: #{collected_urls}"
402
453
 
403
454
 
@@ -845,11 +896,19 @@ class Naver
845
896
  sleep(1)
846
897
 
847
898
  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"]')) # 아이프레임 선택
899
+ begin
900
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
901
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
902
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_content"]') } # 아이프레임 선택
903
+ sleep(1)
904
+ rescue
905
+ # 아이프레임 요소가 나타날 때까지 기다립니다.
906
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
907
+ wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
908
+ sleep(1)
909
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
910
+ @in_iframe = true
911
+ end
853
912
 
854
913
 
855
914
  # 한 페이지에 게시글이 15개씩 있다고 가정
@@ -892,7 +951,12 @@ class Naver
892
951
  current_page += 1
893
952
  end
894
953
  # 수집한 URL 출력
895
- @driver.switch_to.default_content() # 아이프레임 해제
954
+
955
+ if @in_iframe
956
+ @driver.switch_to.default_content
957
+ @in_iframe = false
958
+ puts "프레임에서 default_content로 자동 복귀"
959
+ end
896
960
  puts "수집한 URL들: #{collected_urls}"
897
961
 
898
962
 
@@ -1296,29 +1360,42 @@ class Naver
1296
1360
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
1297
1361
  sleep(1)
1298
1362
  begin
1299
- @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
1300
- sleep(2)
1301
- rescue
1302
- begin
1303
- @driver.find_element(:xpath, '//*[@class="off itemfont _doNclick _param(false|blog|)"]').click
1304
- sleep(2)
1305
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1306
- wait.until { @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]') }
1307
- @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
1308
- sleep(2)
1309
- rescue => e
1310
- @driver.window_handles.each do |handle|
1311
- @driver.switch_to.window(handle)
1312
- begin
1313
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1314
- puts 'id="toplistSpanBlind" 요소를 찾지 못했습니다.'
1315
- @driver.close
1316
- rescue Selenium::WebDriver::Error::WebDriverError => e
1317
- puts "Failed to close tab: #{e.message}"
1318
- end
1319
- end
1320
- @driver.quit
1321
- end
1363
+ @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
1364
+ sleep(2)
1365
+ rescue
1366
+ begin
1367
+ @driver.find_element(:xpath, '//*[@class="off itemfont _doNclick _param(false|blog|)"]').click
1368
+ sleep(2)
1369
+ begin
1370
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1371
+ wait.until { @driver.find_element(:xpath, '//*[@id="category0"]') }
1372
+ element = @driver.find_element(:xpath, '//*[@id="category0"]')
1373
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
1374
+ sleep(2)
1375
+ @driver.find_element(:xpath, '//*[@id="category0"]').click
1376
+ sleep(2)
1377
+ rescue
1378
+ end
1379
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1380
+ wait.until { @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]') }
1381
+ element = @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]')
1382
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
1383
+ sleep(2)
1384
+ @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
1385
+ sleep(1)
1386
+ rescue => e
1387
+ @driver.window_handles.each do |handle|
1388
+ @driver.switch_to.window(handle)
1389
+ begin
1390
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1391
+ puts 'id="toplistSpanBlind" 요소를 찾지 못했습니다.'
1392
+ @driver.close
1393
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1394
+ puts "Failed to close tab: #{e.message}"
1395
+ end
1396
+ end
1397
+ @driver.quit
1398
+ end
1322
1399
  end
1323
1400
 
1324
1401
 
@@ -1391,7 +1468,7 @@ class Naver
1391
1468
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
1392
1469
  sleep(1)
1393
1470
 
1394
- # 수집된 URL을 저장할 배열
1471
+ # 수집된 URL을 저장할 배열
1395
1472
  collected_urls = []
1396
1473
 
1397
1474
  # 현재 페이지에서 수집할 링크 개수
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.32
4
+ version: 0.0.37
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-14 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: []