duo_cafe_comment 0.0.17 → 0.0.27
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_cafe_comment.rb +149 -48
- 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: 3610af8bb3f93781a818ea26806b7ee3158df83f7ba4c28421930569b29b7698
|
4
|
+
data.tar.gz: 37b03366b2857facd4f7628c01b161efa8478d18417c4d9c25f4d8811b11600e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e3f3d84d953009aa71d973020629d2f23a62554c2a87981dec1e704ff2c3a91fdd6a7356aa1ff115f0806b3f420d8286f2700bba569cbee9030e1c4b949c496
|
7
|
+
data.tar.gz: 290e6f3a4c13e0016731c638a9cfb7f59d9da3cb2e27c5d339e01725cb40a973c91205ac4545ba04f969e02d70ab6905bd63db3337b1e3680451a0e4ca68b933
|
data/lib/duo_cafe_comment.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
|
-
|
3
|
+
require 'webdrivers'
|
4
4
|
require 'iconv'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'http'
|
@@ -21,17 +21,43 @@ include AutoClickMethods
|
|
21
21
|
using Rainbow
|
22
22
|
include Glimmer
|
23
23
|
|
24
|
+
|
24
25
|
class Naver
|
25
26
|
def initialize
|
26
27
|
@seed = 1
|
28
|
+
|
29
|
+
begin
|
30
|
+
# webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
|
31
|
+
|
32
|
+
# Webdrivers가 드라이버를 다운로드할 경로를 설정
|
33
|
+
Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
|
34
|
+
Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
|
35
|
+
# 크롬드라이버 자동 업데이트 시도
|
36
|
+
Webdrivers::Chromedriver.update
|
37
|
+
puts "chromedriver 자동 다운로드 성공"
|
38
|
+
rescue => e
|
39
|
+
puts "chromedriver 자동 다운로드 실패: #{e.message}"
|
40
|
+
puts "폴더내 크롬드라이버를 사용합니다."
|
41
|
+
puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
|
42
|
+
puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
|
43
|
+
chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
|
44
|
+
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
45
|
+
end
|
46
|
+
|
27
47
|
end
|
48
|
+
|
49
|
+
|
28
50
|
def chrome_setup(user_id, proxy)
|
29
51
|
naver_cookie_dir = "C:/naver_cookie"
|
30
52
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
31
53
|
if proxy == ''
|
32
|
-
|
54
|
+
|
55
|
+
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --no-first-run --no-default-browser-check --disable-sync})
|
56
|
+
|
33
57
|
else
|
34
|
-
|
58
|
+
|
59
|
+
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync})
|
60
|
+
|
35
61
|
end
|
36
62
|
end
|
37
63
|
def chrome_start(proxy, user_id)
|
@@ -39,10 +65,12 @@ class Naver
|
|
39
65
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
40
66
|
if proxy == ''
|
41
67
|
begin
|
42
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
43
68
|
options = Selenium::WebDriver::Chrome::Options.new
|
44
69
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
45
|
-
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
70
|
+
#options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
71
|
+
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
72
|
+
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
73
|
+
options.add_argument('--no-default-browser-check')
|
46
74
|
options.page_load_strategy = :normal
|
47
75
|
options.timeouts = {page_load: 20_000}
|
48
76
|
options.page_load_strategy = 'none'
|
@@ -64,10 +92,13 @@ class Naver
|
|
64
92
|
end
|
65
93
|
else
|
66
94
|
begin
|
67
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
95
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
68
96
|
options = Selenium::WebDriver::Chrome::Options.new
|
69
97
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
70
98
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
99
|
+
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
100
|
+
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
101
|
+
options.add_argument('--no-default-browser-check')
|
71
102
|
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
72
103
|
options.page_load_strategy = :normal
|
73
104
|
options.timeouts = {page_load: 20_000}
|
@@ -88,10 +119,13 @@ class Naver
|
|
88
119
|
puts e
|
89
120
|
puts 'proxy error...'
|
90
121
|
begin
|
91
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
122
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
92
123
|
options = Selenium::WebDriver::Chrome::Options.new
|
93
124
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
94
125
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
126
|
+
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
127
|
+
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
128
|
+
options.add_argument('--no-default-browser-check')
|
95
129
|
options.page_load_strategy = :normal
|
96
130
|
options.timeouts = {page_load: 20_000}
|
97
131
|
options.page_load_strategy = 'none'
|
@@ -244,38 +278,78 @@ class Naver
|
|
244
278
|
begin
|
245
279
|
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
246
280
|
# 요소가 나타날 때까지 기다립니다.
|
247
|
-
wait.until { @driver.find_element(:xpath, '//*[@
|
248
|
-
@driver.find_element(:xpath, '//*[@
|
249
|
-
rescue
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
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
|
+
|
262
311
|
end
|
312
|
+
|
313
|
+
|
263
314
|
|
264
315
|
################################################################################ 프로그램에 설정한 이미지랑 글까지 등록
|
265
316
|
if option['닉네임변경'] == 'true'
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
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
|
271
351
|
|
272
|
-
|
273
|
-
wait.until { @driver.find_element(:link_text, '프로필 변경하기') }
|
274
|
-
# "프로필 변경하기" 링크 찾기
|
275
|
-
element = @driver.find_element(:link_text, '프로필 변경하기')
|
276
|
-
# Action을 이용하여 컨트롤 키를 누르고 클릭
|
277
|
-
@driver.action.key_down(:control).click(element).key_up(:control).perform
|
278
|
-
sleep(1)
|
352
|
+
|
279
353
|
|
280
354
|
# 두 번째 탭으로 전환
|
281
355
|
@driver.switch_to.window(@driver.window_handles[1])
|
@@ -284,7 +358,7 @@ class Naver
|
|
284
358
|
wait.until { @driver.find_element(:xpath, '//*[@class="btn_delete"]') }
|
285
359
|
@driver.find_element(:xpath, '//*[@class="btn_delete"]').click
|
286
360
|
sleep(1)
|
287
|
-
@driver.find_element(:xpath, '
|
361
|
+
@driver.find_element(:xpath, '/html/body/div/div/div[2]/div[2]/div[1]/div[1]/textarea').click
|
288
362
|
@nickname = nickname
|
289
363
|
@driver.find_element(:xpath, '//*[@id="app"]/div/div[2]/div[2]/div[1]/div[1]/textarea').send_keys(nickname)
|
290
364
|
sleep(1)
|
@@ -318,12 +392,19 @@ class Naver
|
|
318
392
|
|
319
393
|
|
320
394
|
begin
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
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
|
327
408
|
|
328
409
|
# 한 페이지에 게시글이 15개씩 있다고 가정
|
329
410
|
articles_per_page = 15
|
@@ -362,7 +443,13 @@ class Naver
|
|
362
443
|
current_page += 1
|
363
444
|
end
|
364
445
|
# 수집한 URL 출력
|
365
|
-
|
446
|
+
|
447
|
+
if @in_iframe
|
448
|
+
@driver.switch_to.default_content
|
449
|
+
@in_iframe = false
|
450
|
+
puts "프레임에서 default_content로 자동 복귀"
|
451
|
+
end
|
452
|
+
|
366
453
|
puts "수집한 URL들: #{collected_urls}"
|
367
454
|
|
368
455
|
|
@@ -810,11 +897,19 @@ class Naver
|
|
810
897
|
sleep(1)
|
811
898
|
|
812
899
|
begin
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
900
|
+
begin
|
901
|
+
# 아이프레임 요소가 나타날 때까지 기다립니다.
|
902
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
|
903
|
+
wait.until { @driver.find_element(:xpath, '//*[@id="cafe_content"]') } # 아이프레임 선택
|
904
|
+
sleep(1)
|
905
|
+
rescue
|
906
|
+
# 아이프레임 요소가 나타날 때까지 기다립니다.
|
907
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 아이프레임 선택
|
908
|
+
wait.until { @driver.find_element(:xpath, '//*[@id="cafe_main"]') } # 아이프레임 선택
|
909
|
+
sleep(1)
|
910
|
+
@driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="cafe_main"]')) # 아이프레임 선택
|
911
|
+
@in_iframe = true
|
912
|
+
end
|
818
913
|
|
819
914
|
|
820
915
|
# 한 페이지에 게시글이 15개씩 있다고 가정
|
@@ -857,7 +952,13 @@ class Naver
|
|
857
952
|
current_page += 1
|
858
953
|
end
|
859
954
|
# 수집한 URL 출력
|
860
|
-
|
955
|
+
|
956
|
+
if @in_iframe
|
957
|
+
@driver.switch_to.default_content
|
958
|
+
@in_iframe = false
|
959
|
+
puts "프레임에서 default_content로 자동 복귀"
|
960
|
+
end
|
961
|
+
|
861
962
|
puts "수집한 URL들: #{collected_urls}"
|
862
963
|
|
863
964
|
|
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.
|
4
|
+
version: 0.0.27
|
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-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.
|
40
|
-
signing_key:
|
37
|
+
rubygems_version: 3.6.7
|
41
38
|
specification_version: 4
|
42
39
|
summary: file to clipboard
|
43
40
|
test_files: []
|