duo_blog_cafe_comment 0.0.3 → 0.0.5
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 +197 -122
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 536442eac0684107e2106b2d84e29cdbc107a3400ad1bf99d650355128a03695
|
4
|
+
data.tar.gz: ce2fbaaef96ba316a14019e1676c3289a4fdbd99b38765fcf8720122db6f54ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b9107fdda5f850f3139e385b7436e185263b21a73c82fb513d53efedbe1103b053921d3cd36526a1b8e1de1ad2207d7288d27ec77a86e6593d59626f185642
|
7
|
+
data.tar.gz: d29b6cdf3c5b73130abb0b4bd14b300eb0eeeb29fb5a18150207e16c6afff903bbfd49017df9670527841fc7c5a71a53d16d094f7949f9235077e4b61e6c3eb5
|
@@ -41,6 +41,8 @@ class Naver
|
|
41
41
|
begin
|
42
42
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
43
43
|
options = Selenium::WebDriver::Chrome::Options.new
|
44
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
45
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
44
46
|
options.page_load_strategy = :normal
|
45
47
|
options.timeouts = {page_load: 20_000}
|
46
48
|
options.page_load_strategy = 'none'
|
@@ -48,21 +50,16 @@ class Naver
|
|
48
50
|
options.add_argument('--disable-gpu')
|
49
51
|
options.add_argument('--remote-debugging-port=9222')
|
50
52
|
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
51
|
-
@driver = Selenium::WebDriver.for(:chrome,
|
53
|
+
@driver = Selenium::WebDriver.for(:chrome, options: options)
|
52
54
|
rescue
|
53
|
-
@driver = Selenium::WebDriver.for(:chrome,
|
55
|
+
@driver = Selenium::WebDriver.for(:chrome, options: options)
|
54
56
|
end
|
55
57
|
else
|
56
58
|
begin
|
57
59
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
58
60
|
options = Selenium::WebDriver::Chrome::Options.new
|
59
|
-
#
|
60
|
-
|
61
|
-
# profile['network.proxy.http'] = proxy.split(':')[0]
|
62
|
-
# profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
|
63
|
-
# options = Selenium::WebDriver::Chrome::Options.new
|
64
|
-
# options.profile = profile
|
65
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
61
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
62
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
66
63
|
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
67
64
|
options.page_load_strategy = :normal
|
68
65
|
options.timeouts = {page_load: 20_000}
|
@@ -71,13 +68,15 @@ class Naver
|
|
71
68
|
options.add_argument('--disable-gpu')
|
72
69
|
options.add_argument('--remote-debugging-port=9222')
|
73
70
|
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
74
|
-
@driver = Selenium::WebDriver.for(:chrome,
|
71
|
+
@driver = Selenium::WebDriver.for(:chrome, options: options)
|
75
72
|
rescue => e
|
76
73
|
puts e
|
77
74
|
puts 'proxy error...'
|
78
75
|
begin
|
79
76
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
80
77
|
options = Selenium::WebDriver::Chrome::Options.new
|
78
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
79
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
81
80
|
options.page_load_strategy = :normal
|
82
81
|
options.timeouts = {page_load: 20_000}
|
83
82
|
options.page_load_strategy = 'none'
|
@@ -85,9 +84,9 @@ class Naver
|
|
85
84
|
options.add_argument('--disable-gpu')
|
86
85
|
options.add_argument('--remote-debugging-port=9222')
|
87
86
|
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
88
|
-
@driver = Selenium::WebDriver.for(:chrome,
|
87
|
+
@driver = Selenium::WebDriver.for(:chrome, options: options)
|
89
88
|
rescue
|
90
|
-
@driver = Selenium::WebDriver.for(:chrome,
|
89
|
+
@driver = Selenium::WebDriver.for(:chrome, options: options)
|
91
90
|
end
|
92
91
|
end
|
93
92
|
end
|
@@ -125,39 +124,57 @@ class Naver
|
|
125
124
|
sleep(1)
|
126
125
|
|
127
126
|
begin
|
128
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
127
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
128
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
129
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
130
|
+
sleep(1.5)
|
131
|
+
check_cookie_login = 1
|
132
|
+
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
133
|
+
sleep(2.5)
|
134
|
+
rescue
|
135
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
129
136
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
130
137
|
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
|
131
138
|
sleep(1.5)
|
132
139
|
@driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
|
133
140
|
check_cookie_login = 0
|
134
141
|
sleep(1)
|
135
|
-
rescue
|
136
|
-
check_cookie_login = 1
|
137
|
-
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
138
|
-
sleep(1)
|
139
142
|
end
|
140
143
|
|
141
144
|
if check_cookie_login == 0
|
142
145
|
puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
|
143
146
|
# @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
147
|
+
sleep(3)
|
148
|
+
begin
|
149
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
150
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
151
|
+
wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
|
152
|
+
sleep(1.5)
|
153
|
+
@driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
|
154
|
+
sleep(1.5)
|
155
|
+
@driver.find_element(:xpath, '//*[@id="id"]').click
|
156
|
+
Clipboard.copy(user_id)
|
157
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
158
|
+
sleep(1.5)
|
159
|
+
@driver.find_element(:xpath, '//*[@id="pw"]').click
|
160
|
+
Clipboard.copy(user_pw)
|
161
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
162
|
+
sleep(1.5)
|
163
|
+
@driver.find_element(:xpath, '//*[@id="log.login"]').click
|
164
|
+
sleep(2.5)
|
165
|
+
rescue => e
|
166
|
+
puts '-[√] 로딩 지연 접속 실패.......'.red
|
167
|
+
@driver.window_handles.each do |handle|
|
168
|
+
@driver.switch_to.window(handle)
|
169
|
+
begin
|
170
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
171
|
+
@driver.close
|
172
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
173
|
+
puts "Failed to close tab: #{e.message}"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
return 0
|
177
|
+
end
|
161
178
|
|
162
179
|
else
|
163
180
|
# @driver.switch_to.default_content
|
@@ -169,11 +186,18 @@ class Naver
|
|
169
186
|
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
170
187
|
|
171
188
|
rescue => e
|
172
|
-
puts '-[√] 로그인
|
173
|
-
|
174
|
-
|
189
|
+
puts '-[√] 로그인 실패.......'.red
|
190
|
+
@driver.window_handles.each do |handle|
|
191
|
+
@driver.switch_to.window(handle)
|
192
|
+
begin
|
193
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
194
|
+
@driver.close
|
195
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
196
|
+
puts "Failed to close tab: #{e.message}"
|
197
|
+
end
|
198
|
+
end
|
175
199
|
return 0
|
176
|
-
end
|
200
|
+
end
|
177
201
|
end
|
178
202
|
|
179
203
|
def create_id
|
@@ -197,9 +221,19 @@ class Naver
|
|
197
221
|
# 요소가 나타날 때까지 기다립니다.
|
198
222
|
wait.until { @driver.find_element(:xpath, '//*[@class="tit-info-on"]') }
|
199
223
|
@driver.find_element(:xpath, '//*[@class="tit-info-on"]').click
|
200
|
-
rescue
|
201
|
-
|
202
|
-
|
224
|
+
rescue => e
|
225
|
+
puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
|
226
|
+
@driver.window_handles.each do |handle|
|
227
|
+
@driver.switch_to.window(handle)
|
228
|
+
begin
|
229
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
230
|
+
@driver.close
|
231
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
232
|
+
puts "Failed to close tab: #{e.message}"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
return 0
|
236
|
+
end
|
203
237
|
|
204
238
|
################################################################################ 프로그램에 설정한 이미지랑 글까지 등록
|
205
239
|
if option['닉네임변경'] == 'true'
|
@@ -446,23 +480,22 @@ class Naver
|
|
446
480
|
|
447
481
|
# 이미지 자동 삽입
|
448
482
|
if option['이미지자동삽입'] == 'true'
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
483
|
+
puts "이미지 자동 상입 옵션 진행!!".cyan
|
484
|
+
|
485
|
+
# 아이프레임 요소가 나타날 때까지 기다립니다.
|
486
|
+
@image = image
|
487
|
+
image_path = image
|
488
|
+
|
489
|
+
@driver.find_element(:xpath, '//*[@for="attach2"]').click
|
490
|
+
sleep(1)
|
491
|
+
key_stroke('escape')
|
492
|
+
# 파일 경로 자동 입력
|
493
|
+
file_input = @driver.find_element(:xpath, '//*[@id="attach2"]')
|
494
|
+
|
495
|
+
# send_keys로 파일 경로를 입력하여 이미지 업로드
|
496
|
+
file_input.send_keys(image_path)
|
497
|
+
sleep(2)
|
498
|
+
|
466
499
|
else
|
467
500
|
end
|
468
501
|
|
@@ -665,22 +698,21 @@ class Naver
|
|
665
698
|
# 이미지 자동 삽입
|
666
699
|
if option['이미지자동삽입'] == 'true'
|
667
700
|
puts "이미지 자동 상입 옵션 진행!!".cyan
|
701
|
+
|
668
702
|
# 아이프레임 요소가 나타날 때까지 기다립니다.
|
669
|
-
|
670
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
671
|
-
wait.until { @driver.find_element(:xpath, '//*[@class="button_file"]') }
|
672
|
-
@driver.find_element(:xpath, '//*[@class="button_file"]').click
|
673
|
-
sleep(1)
|
674
703
|
@image = image
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
704
|
+
image_path = image
|
705
|
+
|
706
|
+
@driver.find_element(:xpath, '//*[@for="attach2"]').click
|
707
|
+
sleep(1)
|
708
|
+
key_stroke('escape')
|
709
|
+
# 파일 경로 자동 입력
|
710
|
+
file_input = @driver.find_element(:xpath, '//*[@id="attach2"]')
|
711
|
+
|
712
|
+
# send_keys로 파일 경로를 입력하여 이미지 업로드
|
713
|
+
file_input.send_keys(image_path)
|
714
|
+
sleep(2)
|
715
|
+
|
684
716
|
else
|
685
717
|
end
|
686
718
|
|
@@ -942,23 +974,22 @@ class Naver
|
|
942
974
|
|
943
975
|
# 이미지 자동 삽입
|
944
976
|
if option['이미지자동삽입'] == 'true'
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
977
|
+
puts "이미지 자동 상입 옵션 진행!!".cyan
|
978
|
+
|
979
|
+
# 아이프레임 요소가 나타날 때까지 기다립니다.
|
980
|
+
@image = image
|
981
|
+
image_path = image
|
982
|
+
|
983
|
+
@driver.find_element(:xpath, '//*[@for="attach2"]').click
|
984
|
+
sleep(1)
|
985
|
+
key_stroke('escape')
|
986
|
+
# 파일 경로 자동 입력
|
987
|
+
file_input = @driver.find_element(:xpath, '//*[@id="attach2"]')
|
988
|
+
|
989
|
+
# send_keys로 파일 경로를 입력하여 이미지 업로드
|
990
|
+
file_input.send_keys(image_path)
|
991
|
+
sleep(2)
|
992
|
+
|
962
993
|
else
|
963
994
|
end
|
964
995
|
|
@@ -1035,11 +1066,24 @@ class Naver
|
|
1035
1066
|
@driver.get(url)
|
1036
1067
|
|
1037
1068
|
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1069
|
+
begin
|
1070
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
1071
|
+
#요소가 나타날 때까지 10초 동안 기다립니다.
|
1072
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="area_list_search"]') }
|
1073
|
+
sleep(1)
|
1074
|
+
rescue => e
|
1075
|
+
puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
|
1076
|
+
@driver.window_handles.each do |handle|
|
1077
|
+
@driver.switch_to.window(handle)
|
1078
|
+
begin
|
1079
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1080
|
+
@driver.close
|
1081
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1082
|
+
puts "Failed to close tab: #{e.message}"
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
return 0
|
1086
|
+
end
|
1043
1087
|
|
1044
1088
|
# 현재 페이지에서 7개의 post-url을 찾기
|
1045
1089
|
posts = @driver.find_elements(:xpath, '//div[@class="list_search_post"]//div[@class="desc"]//a[@class="desc_inner"]')
|
@@ -1069,10 +1113,24 @@ class Naver
|
|
1069
1113
|
# 페이지 열기
|
1070
1114
|
url = "https://section.blog.naver.com/Search/Post.naver?pageNo=#{page_no}&rangeType=ALL&orderBy=recentdate&keyword=#{keyword}"
|
1071
1115
|
@driver.get(url)
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1116
|
+
begin
|
1117
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
1118
|
+
#요소가 나타날 때까지 10초 동안 기다립니다.
|
1119
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="area_list_search"]') }
|
1120
|
+
sleep(1)
|
1121
|
+
rescue => e
|
1122
|
+
puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
|
1123
|
+
@driver.window_handles.each do |handle|
|
1124
|
+
@driver.switch_to.window(handle)
|
1125
|
+
begin
|
1126
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1127
|
+
@driver.close
|
1128
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1129
|
+
puts "Failed to close tab: #{e.message}"
|
1130
|
+
end
|
1131
|
+
end
|
1132
|
+
return 0
|
1133
|
+
end
|
1076
1134
|
|
1077
1135
|
# 현재 페이지에서 7개의 post-url을 찾기
|
1078
1136
|
posts = @driver.find_elements(:xpath, '//div[@class="list_search_post"]//div[@class="desc"]//a[@class="desc_inner"]')
|
@@ -1129,11 +1187,24 @@ class Naver
|
|
1129
1187
|
# URL 생성
|
1130
1188
|
url = "https://section.blog.naver.com/ThemePost.naver?directoryNo=#{page_no1}&activeDirectorySeq=#{page_no2}¤tPage=#{page_no}"
|
1131
1189
|
@driver.get(url)
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1190
|
+
begin
|
1191
|
+
# 요소가 나타날 때까지 10초 동안 기다립니다.
|
1192
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
1193
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="list_post_article"]') }
|
1194
|
+
sleep(1)
|
1195
|
+
rescue => e
|
1196
|
+
puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
|
1197
|
+
@driver.window_handles.each do |handle|
|
1198
|
+
@driver.switch_to.window(handle)
|
1199
|
+
begin
|
1200
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1201
|
+
@driver.close
|
1202
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1203
|
+
puts "Failed to close tab: #{e.message}"
|
1204
|
+
end
|
1205
|
+
end
|
1206
|
+
return 0
|
1207
|
+
end
|
1137
1208
|
|
1138
1209
|
# 현재 페이지에서 7개의 post-url을 찾기
|
1139
1210
|
posts = @driver.find_elements(:xpath, '//div[@class="item multi_pic"]//div[@class="desc"]//a[@class="desc_inner"]')
|
@@ -1714,22 +1785,17 @@ class Naver
|
|
1714
1785
|
|
1715
1786
|
|
1716
1787
|
elsif option['이미지자동삽입'] == 'true'
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
@driver.find_element(:xpath, '//*[@data-log="RPO.photo"]').click
|
1722
|
-
sleep(1)
|
1723
|
-
@image = image
|
1788
|
+
begin
|
1789
|
+
sleep(1)
|
1790
|
+
@image = image
|
1791
|
+
image_path = image
|
1724
1792
|
#클립보드에 복사
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
sleep(3)
|
1732
|
-
else
|
1793
|
+
file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
|
1794
|
+
# send_keys로 파일 경로를 입력하여 이미지 업로드
|
1795
|
+
file_input.send_keys(image_path)
|
1796
|
+
sleep(1)
|
1797
|
+
rescue
|
1798
|
+
end
|
1733
1799
|
end
|
1734
1800
|
sleep(1)
|
1735
1801
|
element = @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]')
|
@@ -1794,10 +1860,19 @@ class Naver
|
|
1794
1860
|
else
|
1795
1861
|
end
|
1796
1862
|
|
1797
|
-
begin
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1863
|
+
begin
|
1864
|
+
@driver.window_handles.each do |handle|
|
1865
|
+
@driver.switch_to.window(handle)
|
1866
|
+
begin
|
1867
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1868
|
+
@driver.close
|
1869
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1870
|
+
puts "Failed to close tab: #{e.message}"
|
1871
|
+
end
|
1872
|
+
end
|
1873
|
+
rescue
|
1874
|
+
|
1875
|
+
end
|
1801
1876
|
|
1802
1877
|
|
1803
1878
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|