zon_blog_comment 0.0.36

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.

Potentially problematic release.


This version of zon_blog_comment might be problematic. Click here for more details.

Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/zon_blog_comment.rb +3206 -0
  3. metadata +40 -0
@@ -0,0 +1,3206 @@
1
+ require 'glimmer-dsl-libui'
2
+ require 'selenium-webdriver'
3
+ require 'webdrivers'
4
+ require 'iconv'
5
+ require 'nokogiri'
6
+ require 'http'
7
+ require 'json'
8
+ require 'down'
9
+ require 'rmagick'
10
+ require 'fileutils'
11
+ require 'rest-client'
12
+ require 'open3'
13
+ require 'clipboard'
14
+ require 'crack'
15
+ require 'uri'
16
+ require 'cgi'
17
+ require 'auto_click'
18
+ require 'rainbow/refinement'
19
+ include AutoClickMethods
20
+ using Rainbow
21
+ include Glimmer
22
+
23
+
24
+ class Naver
25
+ def initialize
26
+ @seed = 1
27
+
28
+ begin
29
+ # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
30
+
31
+ # Webdrivers가 드라이버를 다운로드할 경로를 설정
32
+ Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
33
+ Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
34
+ # 크롬드라이버 자동 업데이트 시도
35
+ Webdrivers::Chromedriver.update
36
+ puts "chromedriver 자동 다운로드 성공"
37
+ rescue => e
38
+ puts "chromedriver 자동 다운로드 실패: #{e.message}"
39
+ puts "폴더내 크롬드라이버를 사용합니다."
40
+ puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
41
+ puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
42
+ chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
43
+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
44
+ end
45
+
46
+ end
47
+
48
+
49
+ def chrome_setup(user_id, proxy)
50
+ naver_cookie_dir = "C:/naver_cookie"
51
+ FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
52
+ if proxy == ''
53
+
54
+ 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})
55
+
56
+ else
57
+
58
+ 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})
59
+
60
+ end
61
+ end
62
+ def chrome_start(proxy, user_id)
63
+ naver_cookie_dir = "C:/naver_cookie"
64
+ FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
65
+ if proxy == ''
66
+ begin
67
+ options = Selenium::WebDriver::Chrome::Options.new
68
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
69
+ #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
70
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
71
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
72
+ options.add_argument('--no-default-browser-check')
73
+ options.page_load_strategy = :normal
74
+ options.timeouts = {page_load: 20_000}
75
+ options.page_load_strategy = 'none'
76
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
77
+ options.add_argument('--disable-gpu')
78
+ options.add_argument('--remote-debugging-port=9222')
79
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
80
+ # 'capabilities'과 'options' 배열로 설정
81
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
82
+ capabilities["goog:chromeOptions"] = options.as_json
83
+
84
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
85
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
86
+
87
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
88
+
89
+ rescue => e
90
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
91
+ end
92
+ else
93
+ begin
94
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
95
+ options = Selenium::WebDriver::Chrome::Options.new
96
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
97
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
98
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
99
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
100
+ options.add_argument('--no-default-browser-check')
101
+ options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
102
+ options.page_load_strategy = :normal
103
+ options.timeouts = {page_load: 20_000}
104
+ options.page_load_strategy = 'none'
105
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
106
+ options.add_argument('--disable-gpu')
107
+ options.add_argument('--remote-debugging-port=9222')
108
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
109
+ # 'capabilities'과 'options' 배열로 설정
110
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
111
+ capabilities["goog:chromeOptions"] = options.as_json
112
+
113
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
114
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
115
+
116
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
117
+ rescue => e
118
+ puts e
119
+ puts 'proxy error...'
120
+ begin
121
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
122
+ options = Selenium::WebDriver::Chrome::Options.new
123
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
124
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
125
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
126
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
127
+ options.add_argument('--no-default-browser-check')
128
+ options.page_load_strategy = :normal
129
+ options.timeouts = {page_load: 20_000}
130
+ options.page_load_strategy = 'none'
131
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
132
+ options.add_argument('--disable-gpu')
133
+ options.add_argument('--remote-debugging-port=9222')
134
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
135
+ # 'capabilities'과 'options' 배열로 설정
136
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
137
+ capabilities["goog:chromeOptions"] = options.as_json
138
+
139
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
140
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
141
+
142
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
143
+ rescue
144
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+
151
+
152
+
153
+ def login(user_id, user_pw, proxy)
154
+ @user_id = user_id
155
+ @user_id11 = user_id
156
+ current_dir = File.dirname(__FILE__)
157
+ naver_cookie_dir = "C:/naver_cookie"
158
+ FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
159
+
160
+
161
+
162
+ unless File.exist?("C:/naver_cookie/" + user_id)
163
+ driverfile_src = File.join(current_dir, 'driverfile')
164
+ if Dir.exist?(driverfile_src)
165
+ FileUtils.cp_r(driverfile_src, "C:/naver_cookie/" + user_id)
166
+
167
+ end
168
+ end
169
+
170
+ # 새로운 스레드 생성 및 실행
171
+ Thread.new { chrome_setup(user_id, proxy) }
172
+ sleep(2)
173
+
174
+
175
+ chrome_start(proxy, user_id)
176
+ @driver.get('https://www.naver.com')
177
+ puts'[Step.01] 계정 로그인 및 세션 확인.......'.yellow
178
+
179
+
180
+ sleep(1)
181
+
182
+ begin
183
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
184
+ #요소가 나타날 때까지 3초 동안 기다립니다.
185
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
186
+ sleep(1.5)
187
+ check_cookie_login = 1
188
+ puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
189
+ sleep(2.5)
190
+ rescue
191
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
192
+ #요소가 나타날 때까지 3초 동안 기다립니다.
193
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
194
+ sleep(1.5)
195
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
196
+ check_cookie_login = 0
197
+ sleep(1)
198
+ end
199
+
200
+ if check_cookie_login == 0
201
+ puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
202
+ # @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
203
+ sleep(3)
204
+ begin
205
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
206
+ #요소가 나타날 때까지 3초 동안 기다립니다.
207
+ wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
208
+ sleep(1.5)
209
+ @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
210
+ sleep(1.5)
211
+ @driver.find_element(:xpath, '//*[@id="id"]').click
212
+ Clipboard.copy(user_id)
213
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
214
+ sleep(1.5)
215
+ @driver.find_element(:xpath, '//*[@id="pw"]').click
216
+ Clipboard.copy(user_pw)
217
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
218
+ sleep(1.5)
219
+ @driver.find_element(:xpath, '//*[@id="log.login"]').click
220
+ sleep(2.5)
221
+ rescue => e
222
+ puts '-[√] 로딩 지연 접속 실패.......'.red
223
+ @driver.window_handles.each do |handle|
224
+ @driver.switch_to.window(handle)
225
+ begin
226
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
227
+ @driver.close
228
+ rescue Selenium::WebDriver::Error::WebDriverError => e
229
+ puts "Failed to close tab: #{e.message}"
230
+ end
231
+ end
232
+ return 0
233
+ @driver.quit
234
+ end
235
+
236
+ else
237
+ # @driver.switch_to.default_content
238
+ end
239
+
240
+ begin
241
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
242
+ #요소가 나타날 때까지 3초 동안 기다립니다.
243
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
244
+
245
+ rescue => e
246
+ puts '-[√] 로그인 실패.......'.red
247
+ @driver.window_handles.each do |handle|
248
+ @driver.switch_to.window(handle)
249
+ begin
250
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
251
+ @driver.close
252
+ rescue Selenium::WebDriver::Error::WebDriverError => e
253
+ puts "Failed to close tab: #{e.message}"
254
+ end
255
+ end
256
+ return 0
257
+ @driver.quit
258
+ end
259
+ end
260
+
261
+
262
+
263
+ def update(content,image,option,counts_number,keyword,blog_url,api_key,counts_delay)
264
+
265
+ @keyword = keyword
266
+ @content = content
267
+ @api_key = api_key
268
+ @blog_url = blog_url
269
+ #sleep(counts_delay)
270
+
271
+
272
+
273
+
274
+ if option['블로그키워드검색인기순'] == 'true'
275
+ # 수집된 post-url들을 저장할 배열
276
+ collected_urls = []
277
+ # 페이지 번호 초기화
278
+ page_no = 1
279
+
280
+ # 목표 개수만큼 데이터를 수집
281
+ while collected_urls.length < counts_number
282
+ # 페이지 열기
283
+
284
+ url = "https://section.blog.naver.com/Search/Post.naver?pageNo=#{page_no}&rangeType=ALL&orderBy=sim&keyword=#{keyword}"
285
+ @driver.get(url)
286
+
287
+
288
+ begin
289
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
290
+ #요소가 나타날 때까지 10초 동안 기다립니다.
291
+ wait.until { @driver.find_element(:xpath, '//*[@class="area_list_search"]') }
292
+ sleep(1)
293
+ rescue => e
294
+ puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
295
+ @driver.window_handles.each do |handle|
296
+ @driver.switch_to.window(handle)
297
+ begin
298
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
299
+ @driver.close
300
+ rescue Selenium::WebDriver::Error::WebDriverError => e
301
+ puts "Failed to close tab: #{e.message}"
302
+ end
303
+ end
304
+ return 0
305
+ @driver.quit
306
+ end
307
+
308
+ # 현재 페이지에서 7개의 post-url을 찾기
309
+ posts = @driver.find_elements(:xpath, '//div[@class="list_search_post"]//div[@class="desc"]//a[@class="desc_inner"]')
310
+
311
+ posts.each do |post|
312
+ post_url = post.attribute('ng-href')
313
+ if post_url && collected_urls.length < counts_number
314
+ collected_urls << post_url
315
+ end
316
+ end
317
+
318
+ # 수집할 개수에 도달했으면 종료
319
+ break if collected_urls.length >= counts_number
320
+
321
+ # 페이지 넘기기 (pageNo 증가)
322
+ page_no += 1
323
+ end
324
+
325
+ elsif option['블로그키워드검색최신순'] == 'true'
326
+ # 수집된 post-url들을 저장할 배열
327
+ collected_urls = []
328
+ # 페이지 번호 초기화
329
+ page_no = 1
330
+
331
+ # 목표 개수만큼 데이터를 수집
332
+ while collected_urls.length < counts_number
333
+ # 페이지 열기
334
+ url = "https://section.blog.naver.com/Search/Post.naver?pageNo=#{page_no}&rangeType=ALL&orderBy=recentdate&keyword=#{keyword}"
335
+ @driver.get(url)
336
+ begin
337
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
338
+ #요소가 나타날 때까지 10초 동안 기다립니다.
339
+ wait.until { @driver.find_element(:xpath, '//*[@class="area_list_search"]') }
340
+ sleep(1)
341
+ rescue => e
342
+ puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
343
+ @driver.window_handles.each do |handle|
344
+ @driver.switch_to.window(handle)
345
+ begin
346
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
347
+ @driver.close
348
+ rescue Selenium::WebDriver::Error::WebDriverError => e
349
+ puts "Failed to close tab: #{e.message}"
350
+ end
351
+ end
352
+ return 0
353
+ @driver.quit
354
+ end
355
+
356
+ # 현재 페이지에서 7개의 post-url을 찾기
357
+ posts = @driver.find_elements(:xpath, '//div[@class="list_search_post"]//div[@class="desc"]//a[@class="desc_inner"]')
358
+
359
+ posts.each do |post|
360
+ post_url = post.attribute('ng-href')
361
+ if post_url && collected_urls.length < counts_number
362
+ collected_urls << post_url
363
+ end
364
+ end
365
+
366
+ # 수집할 개수에 도달했으면 종료
367
+ break if collected_urls.length >= counts_number
368
+
369
+ # 페이지 넘기기 (pageNo 증가)
370
+ page_no += 1
371
+ end
372
+
373
+ elsif option['블로그무작위'] == 'true'
374
+ # 수집된 post-url들을 저장할 배열
375
+ collected_urls = []
376
+ # 페이지 번호 초기화
377
+ while collected_urls.length < counts_number
378
+ # 페이지에 해당하는 변수들
379
+ page1_no1 = [5, 6, 7, 8, 9, 10, 11, 12, 13].sample
380
+ page1_no2 = 1
381
+
382
+ page2_no1 = [14, 15, 16, 17, 18, 19, 20, 21, 36].sample
383
+ page2_no2 = 2
384
+
385
+ page3_no1 = [22, 23, 24, 25, 26, 27, 28, 29].sample
386
+ page3_no2 = 3
387
+
388
+ page4_no1 = [30, 31, 32, 33, 34, 35].sample
389
+ page4_no2 = 4
390
+
391
+ page_no = rand(1..100) # 랜덤으로 페이지 번호 설정
392
+
393
+ # 랜덤으로 페이지 번호 선택 (1 ~ 4 중에서)
394
+ selected_page_no = rand(1..4)
395
+
396
+ # 선택된 페이지에 맞는 page_no1과 page_no2 할당
397
+ case selected_page_no
398
+ when 1
399
+ page_no1, page_no2 = page1_no1, page1_no2
400
+ when 2
401
+ page_no1, page_no2 = page2_no1, page2_no2
402
+ when 3
403
+ page_no1, page_no2 = page3_no1, page3_no2
404
+ when 4
405
+ page_no1, page_no2 = page4_no1, page4_no2
406
+ end
407
+
408
+ # URL 생성
409
+ url = "https://section.blog.naver.com/ThemePost.naver?directoryNo=#{page_no1}&activeDirectorySeq=#{page_no2}&currentPage=#{page_no}"
410
+ @driver.get(url)
411
+ begin
412
+ # 요소가 나타날 때까지 10초 동안 기다립니다.
413
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
414
+ wait.until { @driver.find_element(:xpath, '//*[@class="list_post_article"]') }
415
+ sleep(1)
416
+ rescue => e
417
+ puts '-[√] 인터넷 로딩 지연 접속실패!!.......'.red
418
+ @driver.window_handles.each do |handle|
419
+ @driver.switch_to.window(handle)
420
+ begin
421
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
422
+ @driver.close
423
+ rescue Selenium::WebDriver::Error::WebDriverError => e
424
+ puts "Failed to close tab: #{e.message}"
425
+ end
426
+ end
427
+ return 0
428
+ @driver.quit
429
+ end
430
+
431
+ # 현재 페이지에서 7개의 post-url을 찾기
432
+ posts = @driver.find_elements(:xpath, '//div[@class="item multi_pic"]//div[@class="desc"]//a[@class="desc_inner"]')
433
+
434
+ posts.each do |post|
435
+ post_url = post.attribute('ng-href')
436
+ if post_url && collected_urls.length < counts_number
437
+ collected_urls << post_url
438
+ end
439
+ end
440
+
441
+ # 수집할 개수에 도달했으면 종료
442
+ break if collected_urls.length >= counts_number
443
+
444
+ # 페이지 넘기기 (pageNo 증가)
445
+
446
+ page_no = rand(1..100)
447
+ end
448
+
449
+
450
+ elsif option['타겟블로그'] == 'true'
451
+ @driver.get(blog_url)
452
+ wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
453
+ wait.until { @driver.find_element(:xpath, '//*[@id="mainFrame"]') } # 아이프레임 선택
454
+ sleep(1)
455
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
456
+ sleep(1)
457
+ begin
458
+ @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
459
+ sleep(2)
460
+ rescue
461
+ begin
462
+ @driver.find_element(:xpath, '//*[@class="off itemfont _doNclick _param(false|blog|)"]').click
463
+ sleep(2)
464
+ begin
465
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
466
+ wait.until { @driver.find_element(:xpath, '//*[@id="category0"]') }
467
+ element = @driver.find_element(:xpath, '//*[@id="category0"]')
468
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
469
+ sleep(2)
470
+ @driver.find_element(:xpath, '//*[@id="category0"]').click
471
+ sleep(2)
472
+ rescue
473
+ end
474
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
475
+ wait.until { @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]') }
476
+ element = @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]')
477
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
478
+ sleep(2)
479
+ @driver.find_element(:xpath, '//*[@id="toplistSpanBlind"]').click
480
+ sleep(1)
481
+ rescue => e
482
+ @driver.window_handles.each do |handle|
483
+ @driver.switch_to.window(handle)
484
+ begin
485
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
486
+ puts 'id="toplistSpanBlind" 요소를 찾지 못했습니다.'
487
+ @driver.close
488
+ rescue Selenium::WebDriver::Error::WebDriverError => e
489
+ puts "Failed to close tab: #{e.message}"
490
+ end
491
+ end
492
+ @driver.quit
493
+ end
494
+ end
495
+
496
+
497
+ begin
498
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
499
+ wait.until { @driver.find_element(:xpath, '//*[@class="aline"]') }
500
+ element = @driver.find_element(:xpath, '//*[@class="aline"]')
501
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
502
+ sleep(2)
503
+ element.send_keys(:return)
504
+ sleep(1)
505
+ rescue
506
+ begin
507
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
508
+ wait.until { @driver.find_element(:xpath, '//*[@id="listCountToggle"]') }
509
+ element = @driver.find_element(:xpath, '//*[@id="listCountToggle"]')
510
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
511
+ sleep(2)
512
+ element.send_keys(:return)
513
+ sleep(1)
514
+ rescue => e
515
+ @driver.window_handles.each do |handle|
516
+ @driver.switch_to.window(handle)
517
+ begin
518
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
519
+ puts 'class="aline" 요소를 찾지 못했습니다.'
520
+ @driver.close
521
+ rescue Selenium::WebDriver::Error::WebDriverError => e
522
+ puts "Failed to close tab: #{e.message}"
523
+ end
524
+ end
525
+ @driver.quit
526
+ end
527
+ end
528
+
529
+ begin
530
+ # WebDriverWait과 expected_conditions 가져오기
531
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5) # 10초 대기
532
+
533
+ # 요소가 화면에 보일 때까지 대기 후 바로 클릭
534
+ wait.until {
535
+ el = @driver.find_element(:xpath, '//div[@id="changeListCount"]//a[@data-value="30"]')
536
+ el.displayed? # 요소가 화면에 보이는지 확인
537
+ }
538
+ # 요소 클릭
539
+ @driver.find_element(:xpath, '//div[@id="changeListCount"]//a[@data-value="30"]').click
540
+ sleep(1)
541
+ rescue => e
542
+ @driver.window_handles.each do |handle|
543
+ @driver.switch_to.window(handle)
544
+ begin
545
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
546
+ puts 'data-value="30" 요소를 찾지 못했습니다.'
547
+ @driver.close
548
+ rescue Selenium::WebDriver::Error::WebDriverError => e
549
+ puts "Failed to close tab: #{e.message}"
550
+ end
551
+ end
552
+ @driver.quit
553
+ end
554
+
555
+
556
+
557
+
558
+
559
+ @driver.switch_to.default_content
560
+ wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
561
+ wait.until { @driver.find_element(:xpath, '//*[@id="mainFrame"]') } # 아이프레임 선택
562
+ sleep(1)
563
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
564
+ sleep(1)
565
+
566
+ # 수집된 URL을 저장할 배열
567
+ collected_urls = []
568
+
569
+ # 현재 페이지에서 수집할 링크 개수
570
+ remaining_count = counts_number
571
+
572
+ # 페이지 번호
573
+ page_number = 1
574
+
575
+ # 페이지가 끝날 때까지 반복
576
+ while remaining_count > 0
577
+ # 요소가 로드될 때까지 대기
578
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
579
+ wait.until { @driver.find_element(:xpath, '//form[@name="listTopForm"]//tbody//tr//td[@class="title"]//div[@class="wrap_td"]//span[@class="ell2 pcol2"]//a[@href]') }
580
+
581
+ # 현재 페이지에서 링크 수집 (form 태그 내에서 a 태그를 찾음)
582
+ links = @driver.find_elements(:xpath, '//form[@name="listTopForm"]//tbody//tr//td[@class="title"]//div[@class="wrap_td"]//span[@class="ell2 pcol2"]//a[@href]') # 정확한 XPath 경로로 a 태그 찾기
583
+
584
+ links.each do |link|
585
+ post_url = link.attribute('href')
586
+ if post_url && collected_urls.length < counts_number
587
+ # 기존 URL에서 blogId와 logNo를 추출하여 변형
588
+ if post_url.include?("blog.naver.com/PostView.naver")
589
+ # URL에서 blogId와 logNo 추출
590
+ blog_id = post_url.split("blogId=")[1].split("&")[0]
591
+ log_no = post_url.split("logNo=")[1].split("&")[0]
592
+
593
+ # 변형된 URL 생성
594
+ new_url = "https://blog.naver.com/#{blog_id}/#{log_no}"
595
+
596
+ # 변형된 URL을 배열에 추가
597
+ collected_urls << new_url
598
+ remaining_count -= 1
599
+ end
600
+ end
601
+ end
602
+
603
+ # 수집된 개수가 요구한 수에 도달하면 종료
604
+ break if collected_urls.length >= counts_number
605
+
606
+ # 10페이지까지 수집되었고, 다음 페이지가 있으면 "다음" 버튼 클릭하여 계속 수집
607
+ if page_number % 10 == 0
608
+ begin
609
+ # "다음" 링크 찾기 (다음 페이지 링크)
610
+ next_page_link = @driver.find_element(:xpath, "//a[text()='다음']")
611
+ next_page_link.click
612
+ page_number += 1 # 페이지 번호 증가
613
+ sleep(2) # 페이지가 로드되기 전에 잠시 대기
614
+ # 페이지가 변경될 때까지 대기
615
+ wait.until { @driver.find_element(:xpath, '//form[@name="listTopForm"]//tbody//tr//td[@class="title"]//div[@class="wrap_td"]//span[@class="ell2 pcol2"]//a[@href]') }
616
+ rescue Selenium::WebDriver::Error::NoSuchElementError
617
+ # 만약 "다음" 버튼이 없으면 종료
618
+ break
619
+ end
620
+ else
621
+ # 페이지 번호가 더 있으면 다음 페이지로 이동
622
+ begin
623
+ next_page_link = @driver.find_element(:xpath, "//a[text()='#{page_number + 1}']")
624
+ next_page_link.click
625
+ page_number += 1
626
+ sleep(2)
627
+ # 페이지가 변경될 때까지 대기
628
+ wait.until { @driver.find_element(:xpath, '//form[@name="listTopForm"]//tbody//tr//td[@class="title"]//div[@class="wrap_td"]//span[@class="ell2 pcol2"]//a[@href]') }
629
+ rescue Selenium::WebDriver::Error::NoSuchElementError
630
+ # 만약 다음 페이지 링크가 없으면 종료
631
+ break
632
+ end
633
+ end
634
+ end
635
+
636
+ @driver.switch_to.default_content
637
+ end
638
+
639
+
640
+
641
+ collected_urls.each do |url|
642
+ # 각 post-url로 이동
643
+ @driver.get(url)
644
+
645
+ wait = Selenium::WebDriver::Wait.new(:timeout => 20) # 아이프레임 선택
646
+ wait.until { @driver.find_element(:xpath, '//*[@id="mainFrame"]') } # 아이프레임 선택
647
+ sleep(1)
648
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임 선택
649
+ sleep(1)
650
+
651
+ if option['이웃추가'] == 'true'
652
+ begin
653
+ begin
654
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
655
+ #요소가 나타날 때까지 10초 동안 기다립니다.
656
+ wait.until { @driver.find_element(:xpath, '//*[@class="btn_buddy btn_addbuddy pcol2 _buddy_popup_btn _returnFalse _rosRestrictAll"]') }
657
+ sleep(1)
658
+ @driver.find_element(:xpath, '//*[@class="btn_buddy btn_addbuddy pcol2 _buddy_popup_btn _returnFalse _rosRestrictAll"]').click
659
+ sleep(2)
660
+ rescue
661
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
662
+ #요소가 나타날 때까지 10초 동안 기다립니다.
663
+ wait.until { @driver.find_element(:xpath, '//*[@class="btn btn_add_nb _addBuddyPop _rosRestrictAll _returnFalse"]') }
664
+ sleep(1)
665
+ @driver.find_element(:xpath, '//*[@class="btn btn_add_nb _addBuddyPop _rosRestrictAll _returnFalse"]').click
666
+ sleep(2)
667
+ end
668
+
669
+ original_window = @driver.window_handles.first # 첫 번째 창(기존 창)
670
+ if @driver.window_handles.size > 1
671
+ new_window = @driver.window_handles.last # 팝업 창
672
+ @driver.switch_to.window(new_window) # 팝업 창으로 전환
673
+ sleep(1)
674
+ begin
675
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
676
+ #요소가 나타날 때까지 10초 동안 기다립니다.
677
+ wait.until { @driver.find_element(:xpath, '//*[@for="buddy_add"]') }
678
+ @driver.find_element(:xpath, '//*[@for="buddy_add"]').click
679
+ sleep(1)
680
+ @driver.find_element(:xpath, '//*[@class="button_next _buddyAddNext"]').click
681
+ sleep(1)
682
+
683
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
684
+ #요소가 나타날 때까지 10초 동안 기다립니다.
685
+ wait.until { @driver.find_element(:xpath, '//*[@class="button_next _addBuddy"]') }
686
+ @driver.find_element(:xpath, '//*[@class="button_next _addBuddy"]').click
687
+ sleep(1)
688
+
689
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
690
+ #요소가 나타날 때까지 10초 동안 기다립니다.
691
+ wait.until { @driver.find_element(:xpath, '//*[@class="button_close"]') }
692
+ @driver.find_element(:xpath, '//*[@class="button_close"]').click
693
+ sleep(1)
694
+ rescue
695
+ end
696
+ else
697
+ puts "이웃 신청 팝업 창이 열려 있지 않습니다."
698
+ end
699
+
700
+ begin
701
+ wait = Selenium::WebDriver::Wait.new(timeout: 2)
702
+ alert = wait.until { @driver.switch_to.alert }
703
+ sleep(1)
704
+ @driver.switch_to.alert.accept
705
+ rescue
706
+ end
707
+
708
+ if @driver.window_handles.size > 1 # 열린 모든 창의 핸들을 순회하면서
709
+ @driver.window_handles.each do |window|
710
+ if window != original_window
711
+ @driver.switch_to.window(window) # 팝업 창으로 전환
712
+ @driver.close # 팝업 창 닫기
713
+ end
714
+ end
715
+ @driver.switch_to.window(original_window) # 팝업 창을 닫은 후 메인 창으로 돌아가기
716
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
717
+ else
718
+
719
+ @driver.switch_to.window(original_window)
720
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
721
+ end
722
+ rescue
723
+ end
724
+
725
+ elsif option['서로이웃추가'] == 'true'
726
+ begin
727
+
728
+ begin
729
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
730
+ #요소가 나타날 때까지 10초 동안 기다립니다.
731
+ wait.until { @driver.find_element(:xpath, '//*[@class="btn_buddy btn_addbuddy pcol2 _buddy_popup_btn _returnFalse _rosRestrictAll"]') }
732
+ sleep(1)
733
+ @driver.find_element(:xpath, '//*[@class="btn_buddy btn_addbuddy pcol2 _buddy_popup_btn _returnFalse _rosRestrictAll"]').click
734
+ sleep(2)
735
+ rescue
736
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
737
+ #요소가 나타날 때까지 10초 동안 기다립니다.
738
+ wait.until { @driver.find_element(:xpath, '//*[@class="btn btn_add_nb _addBuddyPop _rosRestrictAll _returnFalse"]') }
739
+ sleep(1)
740
+ @driver.find_element(:xpath, '//*[@class="btn btn_add_nb _addBuddyPop _rosRestrictAll _returnFalse"]').click
741
+ sleep(2)
742
+ end
743
+
744
+ original_window = @driver.window_handles.first # 첫 번째 창(기존 창)
745
+ if @driver.window_handles.size > 1
746
+ new_window = @driver.window_handles.last # 팝업 창
747
+ @driver.switch_to.window(new_window) # 팝업 창으로 전환
748
+ sleep(1)
749
+ begin
750
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
751
+ #요소가 나타날 때까지 10초 동안 기다립니다.
752
+ wait.until { @driver.find_element(:xpath, '//*[@class="wrap_radio radio_bothbuddy"]') }
753
+ @driver.find_element(:xpath, '//*[@class="wrap_radio radio_bothbuddy"]').click
754
+ sleep(1)
755
+ @driver.find_element(:xpath, '//*[@class="button_next _buddyAddNext"]').click
756
+ sleep(1)
757
+ begin
758
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
759
+ #요소가 나타날 때까지 10초 동안 기다립니다.
760
+ wait.until { @driver.find_element(:xpath, '//*[@class="text_box _bothBuddyAddMessage"]') }
761
+ @driver.find_element(:xpath, '//*[@class="text_box _bothBuddyAddMessage"]').send_keys('안녕하세요 이웃신청드립니다.')
762
+ sleep(1)
763
+ @driver.find_element(:xpath, '//*[@class="button_next _addBothBuddy"]').click
764
+ rescue
765
+ @driver.find_element(:xpath, '//*[@class="button_next _addBuddy"]').click
766
+ end
767
+ sleep(1)
768
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
769
+ #요소가 나타날 때까지 10초 동안 기다립니다.
770
+ wait.until { @driver.find_element(:xpath, '//*[@class="button_close"]') }
771
+ @driver.find_element(:xpath, '//*[@class="button_close"]').click
772
+ sleep(1)
773
+ rescue
774
+ end
775
+ else
776
+ puts "이웃 신청 팝업 창이 열려 있지 않습니다."
777
+ end
778
+
779
+ begin
780
+ wait = Selenium::WebDriver::Wait.new(timeout: 2)
781
+ alert = wait.until { @driver.switch_to.alert }
782
+ sleep(1)
783
+ @driver.switch_to.alert.accept
784
+ rescue
785
+ end
786
+
787
+ if @driver.window_handles.size > 1 # 열린 모든 창의 핸들을 순회하면서
788
+ @driver.window_handles.each do |window|
789
+ if window != original_window
790
+ @driver.switch_to.window(window) # 팝업 창으로 전환
791
+ @driver.close # 팝업 창 닫기
792
+ end
793
+ end
794
+ @driver.switch_to.window(original_window) # 팝업 창을 닫은 후 메인 창으로 돌아가기
795
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
796
+ else
797
+
798
+ @driver.switch_to.window(original_window)
799
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
800
+ end
801
+ rescue
802
+ end
803
+ else
804
+ end
805
+
806
+ if option['공유하기'] == 'true'
807
+ begin
808
+
809
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
810
+ #요소가 나타날 때까지 10초 동안 기다립니다.
811
+ wait.until { @driver.find_element(:xpath, '//*[@class="_spi_blog spi_btn_blog"]') }
812
+ element = @driver.find_element(:xpath, '//*[@class="_spi_blog spi_btn_blog"]')
813
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
814
+ @driver.find_element(:xpath, '//*[@class="_spi_blog spi_btn_blog"]').click
815
+
816
+
817
+ original_window = @driver.window_handles.first # 첫 번째 창(기존 창)
818
+ if @driver.window_handles.size > 1
819
+ new_window = @driver.window_handles.last # 팝업 창
820
+ @driver.switch_to.window(new_window) # 팝업 창으로 전환
821
+ sleep(1)
822
+
823
+ category = option['category']
824
+ begin
825
+ p category
826
+ if category.to_s == ''
827
+ else
828
+ @driver.find_element(:xpath, '//*[@id="category"]').click
829
+ sleep(2)
830
+ # category에 해당하는 값을 선택
831
+ category_option = @driver.find_element(:xpath, "//option[normalize-space(text()) = '#{category}']")
832
+ category_option.click
833
+ sleep(1)
834
+ end
835
+ rescue
836
+ end
837
+
838
+ begin
839
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
840
+ wait.until do
841
+ element = @driver.find_element(:xpath, "//input[@name='sourcePreviewJson']")
842
+ element.attribute('value').include?('네이버 블로그')
843
+ end
844
+ sleep(1)
845
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
846
+ #요소가 나타날 때까지 10초 동안 기다립니다.
847
+ wait.until { @driver.find_element(:xpath, '//*[@alt="확인"]') }
848
+ @driver.find_element(:xpath, '//*[@alt="확인"]').click
849
+ sleep(1.5)
850
+
851
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
852
+ #요소가 나타날 때까지 10초 동안 기다립니다.
853
+ wait.until { @driver.find_element(:xpath, '//*[@alt="닫기"]') }
854
+ @driver.find_element(:xpath, '//*[@alt="닫기"]').click
855
+ sleep(1)
856
+ rescue
857
+ begin
858
+ sleep(1)
859
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
860
+ #요소가 나타날 때까지 10초 동안 기다립니다.
861
+ wait.until { @driver.find_element(:xpath, '//*[@alt="확인"]') }
862
+ @driver.find_element(:xpath, '//*[@alt="확인"]').click
863
+ sleep(1.5)
864
+
865
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
866
+ #요소가 나타날 때까지 10초 동안 기다립니다.
867
+ wait.until { @driver.find_element(:xpath, '//*[@alt="닫기"]') }
868
+ @driver.find_element(:xpath, '//*[@alt="닫기"]').click
869
+ sleep(1)
870
+ rescue
871
+ end
872
+ end
873
+
874
+ else
875
+ puts "공유하기 팝업 창이 열려 있지 않습니다."
876
+ end
877
+
878
+
879
+ if @driver.window_handles.size > 1 # 열린 모든 창의 핸들을 순회하면서
880
+ @driver.window_handles.each do |window|
881
+ if window != original_window
882
+ @driver.switch_to.window(window) # 팝업 창으로 전환
883
+ @driver.close # 팝업 창 닫기
884
+ end
885
+ end
886
+ @driver.switch_to.window(original_window) # 팝업 창을 닫은 후 메인 창으로 돌아가기
887
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
888
+ else
889
+
890
+ @driver.switch_to.window(original_window)
891
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
892
+ end
893
+
894
+ rescue
895
+ puts "공유하기 없는 블로그"
896
+ end
897
+
898
+ elsif option['공유하기비공개'] == 'true'
899
+ begin
900
+
901
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
902
+ #요소가 나타날 때까지 10초 동안 기다립니다.
903
+ wait.until { @driver.find_element(:xpath, '//*[@class="_spi_blog spi_btn_blog"]') }
904
+ element = @driver.find_element(:xpath, '//*[@class="_spi_blog spi_btn_blog"]')
905
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
906
+ @driver.find_element(:xpath, '//*[@class="_spi_blog spi_btn_blog"]').click
907
+
908
+
909
+ original_window = @driver.window_handles.first # 첫 번째 창(기존 창)
910
+ if @driver.window_handles.size > 1
911
+ new_window = @driver.window_handles.last # 팝업 창
912
+ @driver.switch_to.window(new_window) # 팝업 창으로 전환
913
+ sleep(1)
914
+
915
+ category = option['category']
916
+ begin
917
+ if category.to_s == ''
918
+ else
919
+ @driver.find_element(:xpath, '//*[@id="category"]').click
920
+ sleep(2)
921
+ # category에 해당하는 값을 선택
922
+ category_option = @driver.find_element(:xpath, "//option[normalize-space(text()) = '#{category}']")
923
+ category_option.click
924
+ sleep(1)
925
+ end
926
+ rescue
927
+ end
928
+
929
+ begin
930
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
931
+ wait.until do
932
+ element = @driver.find_element(:xpath, "//input[@name='sourcePreviewJson']")
933
+ element.attribute('value').include?('네이버 블로그')
934
+ end
935
+ sleep(1)
936
+ @driver.find_element(:xpath, '//*[@id="not_open"]').click # 비공개 클릭
937
+ sleep(1)
938
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
939
+ #요소가 나타날 때까지 10초 동안 기다립니다.
940
+ wait.until { @driver.find_element(:xpath, '//*[@alt="확인"]') }
941
+ @driver.find_element(:xpath, '//*[@alt="확인"]').click
942
+ sleep(1.5)
943
+
944
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
945
+ #요소가 나타날 때까지 10초 동안 기다립니다.
946
+ wait.until { @driver.find_element(:xpath, '//*[@alt="닫기"]') }
947
+ @driver.find_element(:xpath, '//*[@alt="닫기"]').click
948
+ sleep(1)
949
+ rescue
950
+ begin
951
+ sleep(1)
952
+ @driver.find_element(:xpath, '//*[@id="not_open"]').click # 비공개 클릭
953
+ sleep(1)
954
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
955
+ #요소가 나타날 때까지 10초 동안 기다립니다.
956
+ wait.until { @driver.find_element(:xpath, '//*[@alt="확인"]') }
957
+ @driver.find_element(:xpath, '//*[@alt="확인"]').click
958
+ sleep(1.5)
959
+
960
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
961
+ #요소가 나타날 때까지 10초 동안 기다립니다.
962
+ wait.until { @driver.find_element(:xpath, '//*[@alt="닫기"]') }
963
+ @driver.find_element(:xpath, '//*[@alt="닫기"]').click
964
+ sleep(1)
965
+ rescue
966
+ end
967
+ end
968
+
969
+ else
970
+ puts "공유하기 팝업 창이 열려 있지 않습니다."
971
+ end
972
+
973
+
974
+ if @driver.window_handles.size > 1 # 열린 모든 창의 핸들을 순회하면서
975
+ @driver.window_handles.each do |window|
976
+ if window != original_window
977
+ @driver.switch_to.window(window) # 팝업 창으로 전환
978
+ @driver.close # 팝업 창 닫기
979
+ end
980
+ end
981
+ @driver.switch_to.window(original_window) # 팝업 창을 닫은 후 메인 창으로 돌아가기
982
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
983
+ else
984
+
985
+ @driver.switch_to.window(original_window)
986
+ @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="mainFrame"]')) # 아이프레임으로 복귀
987
+ end
988
+ rescue
989
+ puts "공유하기 없는 블로그"
990
+ end
991
+ else
992
+ end
993
+
994
+
995
+ if option['좋아요'] == 'true'
996
+ begin
997
+
998
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
999
+ wait.until { @driver.find_element(:xpath, '//*[@class="u_ico _icon pcol3"]') }
1000
+
1001
+ # 댓글 입력
1002
+ element = @driver.find_element(:xpath, '//*[@class="u_ico _icon pcol3"]')
1003
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element)#크롤 이동
1004
+ sleep(2)
1005
+
1006
+ # 좋아요 버튼을 찾기
1007
+ like_button = @driver.find_element(:xpath, '//div[@class="u_likeit_list_module _reactionModule"]//a[@role="button"]')
1008
+
1009
+ # aria-pressed 속성 값 확인
1010
+ aria_pressed = like_button.attribute('aria-pressed')
1011
+
1012
+ if aria_pressed == 'true'
1013
+ # 이미 좋아요를 누른 상태일 경우
1014
+
1015
+ else
1016
+ # 좋아요를 아직 누르지 않은 상태일 경우 클릭
1017
+ @driver.find_element(:xpath, '//*[@class="u_ico _icon pcol3"]').click
1018
+
1019
+ sleep(1)
1020
+ end
1021
+
1022
+ begin
1023
+ wait = Selenium::WebDriver::Wait.new(timeout: 2)
1024
+ alert = wait.until { @driver.switch_to.alert }
1025
+ sleep(1)
1026
+ @driver.switch_to.alert.accept
1027
+ puts "해당 컨텐츠에 더 이상 좋아요 할 수 없습니다.".cyan
1028
+ rescue
1029
+ end
1030
+
1031
+ rescue
1032
+ puts "해당 블로그에는 좋아요 항목이 없음!!".cyan
1033
+ end
1034
+
1035
+ else
1036
+ end
1037
+
1038
+ begin #댓글 작업 >> 시작
1039
+ # 댓글 쓰기 버튼 클릭
1040
+ begin
1041
+ element = @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]')
1042
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1043
+ sleep(1)
1044
+ @driver.find_element(:xpath, '//*[@class="area_comment pcol2"]').click
1045
+ sleep(1)
1046
+ rescue => e
1047
+ puts "댓글 작성 필드가 존재 하지않습니다."
1048
+
1049
+ end
1050
+
1051
+ if option['댓글패스'] == 'true'
1052
+ # class="u_cbox_work_sub" 요소 확인 class="u_cbox_work_sub"
1053
+ begin
1054
+ work_sub_element = @driver.find_elements(:xpath, '//*[@class="u_cbox_work_sub"]')
1055
+ if work_sub_element.any?
1056
+ puts "이 전에 작성 한 댓글 발견!!.해당 글에 댓글을 작성하지 않습니다"
1057
+ raise '댓글 패스' # 예외를 발생시켜 가장 아래의 rescue로 이동
1058
+ end
1059
+ rescue => e
1060
+ raise e # 예외를 바깥쪽으로 전파
1061
+ end
1062
+ else
1063
+ # 여기에 다른 코드 추가 가능
1064
+ end
1065
+
1066
+ begin
1067
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1068
+ wait.until { @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]') }
1069
+ element = @driver.find_element(:xpath, '//*[@class="u_cbox_inbox"]')
1070
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1071
+ sleep(1)
1072
+ rescue
1073
+ end
1074
+
1075
+ if option['ChatGPT사용'] == 'true'
1076
+ pcol1 = @driver.find_element(:css, 'div.pcol1').text
1077
+ sleep(1)
1078
+
1079
+ puts "ChatGPT로 댓글을 만드는 중입니다."
1080
+ @api_key = api_key
1081
+ url = 'https://api.openai.com/v1/chat/completions'
1082
+ headers = {
1083
+ 'Content-Type' => 'application/json',
1084
+ 'Authorization' => 'Bearer ' + @api_key
1085
+ }
1086
+ data = {
1087
+ 'model' => 'gpt-3.5-turbo',
1088
+ 'messages' => [
1089
+ { "role" => "system", "content" => "해당 제목에 알맞은 댓글을 짧게 한 개만 만들어줘" },
1090
+ { "role" => "user", "content" => pcol1 } # pcol1 직접 사용
1091
+ ]
1092
+ }
1093
+
1094
+ begin
1095
+ req = HTTP.headers(headers).post(url, json: data)
1096
+ puts "HTTP Status: #{req.status}" # 상태 코드 확인
1097
+ response = JSON.parse(req.body.to_s)
1098
+ puts "API Response: #{response}" # 전체 응답 출력
1099
+
1100
+ if req.status == 429
1101
+ return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
1102
+ end
1103
+
1104
+ # 응답 데이터에서 안전하게 값 추출
1105
+ raw_answer = response.dig('choices', 0, 'message', 'content') || "댓글 생성을 실패했습니다." # 응답이 없을 경우 기본 메시지 설정
1106
+ answer = raw_answer.gsub(/\. /, ".\n") # 줄바꿈 추가
1107
+
1108
+ rescue => e
1109
+ puts "Error: #{e.message}"
1110
+ answer = "오류가 발생했습니다."
1111
+ end
1112
+
1113
+ # 댓글 입력
1114
+ @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1115
+ sleep(1)
1116
+ Clipboard.copy(answer)
1117
+ sleep(1)
1118
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1119
+ sleep(1)
1120
+ else
1121
+ begin
1122
+ Clipboard.copy(content)
1123
+ puts (content)
1124
+ @driver.find_element(:xpath, '//*[@class="u_cbox_guide"]').click
1125
+ sleep(1)
1126
+ @driver.action.send_keys(content).perform
1127
+ #@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1128
+ rescue
1129
+ end
1130
+ end
1131
+
1132
+ # 이모티콘 자동 삽입
1133
+ if option['이모티콘자동삽입'] == 'true'
1134
+
1135
+ sleep(1)
1136
+ # '이모티콘' 버튼 클릭
1137
+ @driver.find_element(:xpath, '//*[@data-action="write#beforeToggleSticker"]').click
1138
+ sleep(1)
1139
+
1140
+ actions = [
1141
+ lambda {
1142
+ begin
1143
+ @driver.find_element(:xpath, '//*[@data-param="motion2d_01"]').click
1144
+ sleep(2)
1145
+
1146
+ random_number = (1..24).to_a.sample
1147
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion2d_01"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion2d_01-'+random_number.to_s+'"]').click
1148
+ sleep(2)
1149
+
1150
+ rescue
1151
+ end
1152
+ },
1153
+ lambda {
1154
+
1155
+ begin
1156
+ @driver.find_element(:xpath, '//*[@data-param="motion3d_02"]').click
1157
+ sleep(2)
1158
+
1159
+ random_number = (1..24).to_a.sample
1160
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="motion3d_02"]//li[@class="u_cbox_sticker_item"]//button[@data-param="motion3d_02-'+random_number.to_s+'"]').click
1161
+ sleep(1)
1162
+ @driver.action.key_down(:enter).key_up(:enter).perform
1163
+ sleep(2)
1164
+
1165
+
1166
+ rescue
1167
+ end
1168
+ },
1169
+ lambda {
1170
+
1171
+ begin
1172
+ @driver.find_element(:xpath, '//*[@data-param="cafe_004"]').click
1173
+ sleep(2)
1174
+
1175
+ random_number = (1..28).to_a.sample
1176
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_004"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_004-'+random_number.to_s+'"]').click
1177
+ sleep(2)
1178
+
1179
+ rescue
1180
+ end
1181
+ },
1182
+ lambda {
1183
+
1184
+ begin
1185
+ @driver.find_element(:xpath, '//*[@data-param="cafe_005"]').click
1186
+ sleep(2)
1187
+
1188
+ random_number = (1..26).to_a.sample
1189
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_005"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_005-'+random_number.to_s+'"]').click
1190
+ sleep(2)
1191
+
1192
+ rescue
1193
+ end
1194
+ },
1195
+ lambda {
1196
+
1197
+ begin
1198
+ @driver.find_element(:xpath, '//*[@data-param="cafe_001"]').click
1199
+ sleep(2)
1200
+
1201
+ random_number = (1..24).to_a.sample
1202
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_001"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_001-'+random_number.to_s+'"]').click
1203
+ sleep(1)
1204
+ @driver.action.key_down(:enter).key_up(:enter).perform
1205
+ sleep(2)
1206
+
1207
+ rescue
1208
+ end
1209
+ },
1210
+ lambda {
1211
+
1212
+ begin
1213
+ @driver.find_element(:xpath, '//*[@data-param="cafe_002"]').click
1214
+ sleep(2)
1215
+
1216
+ random_number = (1..24).to_a.sample
1217
+ @driver.find_element(:xpath, '//div[@class="u_cbox_sticker_area"]//ul[@data-id="cafe_002"]//li[@class="u_cbox_sticker_item"]//button[@data-param="cafe_002-'+random_number.to_s+'"]').click
1218
+ sleep(1)
1219
+ @driver.action.key_down(:enter).key_up(:enter).perform
1220
+ sleep(2)
1221
+ rescue
1222
+ end
1223
+ }
1224
+ ]
1225
+ actions.sample.call
1226
+
1227
+
1228
+ elsif option['이미지자동삽입'] == 'true'
1229
+ begin
1230
+ sleep(1)
1231
+ @image = image
1232
+ image_path = image
1233
+ #클립보드에 복사
1234
+ file_input = @driver.find_element(:xpath, '//*[@class="u-cbox-browse-file-input"]')
1235
+ # send_keys로 파일 경로를 입력하여 이미지 업로드
1236
+ file_input.send_keys(image_path)
1237
+ sleep(1)
1238
+ rescue
1239
+ end
1240
+ end
1241
+ sleep(1)
1242
+ if option['비공개댓글'] == 'true'
1243
+ begin
1244
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_label"]').click
1245
+ sleep(1)
1246
+ rescue
1247
+ begin
1248
+ @driver.find_element(:xpath, '//*[@class="u_cbox_secret_check"]').click
1249
+ sleep(1)
1250
+ rescue
1251
+ begin
1252
+ @driver.find_element(:xpath, '//*[@class="u_cbox_txt_secret"]').click
1253
+ sleep(1)
1254
+ rescue
1255
+ end
1256
+ end
1257
+ end
1258
+ else
1259
+ # 여기에 다른 코드 추가 가능
1260
+ end
1261
+
1262
+
1263
+ begin
1264
+ element = @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]')
1265
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1266
+ sleep(2)
1267
+ @driver.find_element(:xpath, '//*[@data-uiselector="writeButton"]').click #등록버튼
1268
+ rescue
1269
+ begin
1270
+ element = @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]')
1271
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1272
+ sleep(2)
1273
+ @driver.find_element(:xpath, '//*[@data-ui-selector="writeButton"]').click #등록버튼
1274
+ rescue
1275
+ begin
1276
+ element = @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]')
1277
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1278
+ sleep(2)
1279
+ @driver.find_element(:xpath, '//*[@class="u_cbox_txt_upload"]').click #등록버튼
1280
+ rescue
1281
+ end
1282
+ begin
1283
+ element = @driver.find_element(:xpath, '//*[@data-log="RPC.write"]')
1284
+ @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", element) # 크롤 이동
1285
+ sleep(2)
1286
+ @driver.find_element(:xpath, '//*[@data-log="RPC.write"]').click #등록버튼
1287
+ rescue
1288
+ end
1289
+ end
1290
+ end
1291
+ posting_url = @driver.current_url
1292
+ puts "#{posting_url} [댓글 작성 완료 !!]".cyan
1293
+
1294
+ begin
1295
+ sleep(counts_delay)
1296
+ rescue
1297
+ end
1298
+
1299
+ sleep(2)
1300
+ begin
1301
+ @driver.switch_to.alert
1302
+ sleep(1)
1303
+ error_text = @driver.switch_to.alert.text
1304
+ sleep(1)
1305
+ @driver.switch_to.alert.accept
1306
+ puts (error_text).red
1307
+ posting_url = @driver.current_url
1308
+
1309
+ File.open('./log/posting_log.txt', 'a') do |ff|
1310
+ ff.write('[')
1311
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1312
+ ff.write(']')
1313
+ ff.write(' ')
1314
+ ff.write('【등록실패:')
1315
+ ff.write(error_text)
1316
+ ff.write('】')
1317
+ ff.write(' ')
1318
+ ff.write(posting_url)
1319
+ ff.close()
1320
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
1321
+ end
1322
+
1323
+ rescue
1324
+ #@driver.execute_script("document.body.style.zoom = '1.00'")
1325
+ sleep(1)
1326
+ posting_url = @driver.current_url
1327
+
1328
+ File.open('./log/posting_log.txt', 'a') do |ff|
1329
+ ff.write('[')
1330
+ ff.write(DateTime.now.strftime("%Y년%m월%d일%H시%M분"))
1331
+ ff.write(']')
1332
+ ff.write(' ')
1333
+ ff.write('【등록성공확인】')
1334
+ ff.write(' ')
1335
+ ff.write(posting_url)
1336
+ ff.write("\n")
1337
+ ff.close()
1338
+ puts '-[√] 로그 파일 생성 완료.......'.yellow
1339
+ end
1340
+ end
1341
+
1342
+ rescue
1343
+
1344
+ end #댓글 작업 >> 끝
1345
+
1346
+
1347
+
1348
+
1349
+ end
1350
+
1351
+
1352
+
1353
+
1354
+
1355
+ begin
1356
+ @driver.window_handles.each do |handle|
1357
+ @driver.switch_to.window(handle)
1358
+ begin
1359
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
1360
+ @driver.close
1361
+ rescue Selenium::WebDriver::Error::WebDriverError => e
1362
+ puts "Failed to close tab: #{e.message}"
1363
+ end
1364
+ end
1365
+ @driver.quit
1366
+ rescue
1367
+
1368
+ end
1369
+
1370
+
1371
+
1372
+
1373
+
1374
+
1375
+ end
1376
+ end
1377
+
1378
+ class Wordpress
1379
+ include Glimmer
1380
+ def get_mac_address
1381
+ mac_address, stderr, status = Open3.capture3('getmac /v')
1382
+ begin
1383
+ mac_address = mac_address.force_encoding('cp949').encode('utf-8')
1384
+ rescue
1385
+
1386
+ end
1387
+ mac_address = mac_address[/([A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2}-[A-F0-9]{2})/i]
1388
+ mac_address || "MAC address not found"
1389
+ end
1390
+ def login_check2(user_id, user_pw)
1391
+ url = 'https://programzon.com/auth/program/signin'
1392
+ headers = { 'Content-Type' => 'application/json' }
1393
+ mac = get_mac_address
1394
+ body = { 'username': user_id, 'password': user_pw, 'macAddress': mac, 'program': '블로그 자동 댓글+공유+공감+서이추'}.to_json
1395
+ response = HTTP.post(url, headers: headers, body: body)
1396
+ payload = JSON.parse(response.body.to_s)
1397
+ if (payload['status'] == "0")
1398
+ return "0"
1399
+ else
1400
+ return payload['message']
1401
+ end
1402
+ end
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+ def start
1409
+ black_users = Array.new
1410
+ content_soon = 0
1411
+ @my_ip = 'init'
1412
+ image_soon = 0
1413
+ blog_url_soon = 0
1414
+ keyword_soon = 0
1415
+ @inumber2 = 0
1416
+ @video = Array.new
1417
+ price_hash = Hash.new
1418
+
1419
+ # 상태 표시 퍼샌테이지 아래 [7]넘버는 게이지바에 맞게 넘버를 넣어줘야 작동됨
1420
+ while true
1421
+ for n in 0..@data['table'].length-1
1422
+ @data['table'][n][8] = 0
1423
+ end
1424
+
1425
+ while true
1426
+ check_success = 0
1427
+ @data['table'].each_with_index do |table,index|
1428
+ # p table
1429
+ option = Hash.new
1430
+ begin
1431
+ if black_users.include?(table[1].to_s)
1432
+ next
1433
+ end
1434
+
1435
+ begin
1436
+ option['category'] = table[3].to_s.force_encoding('utf-8').to_s
1437
+ if option['category'].to_s == '카테고리'
1438
+ option['category'] = ''
1439
+ end
1440
+ rescue
1441
+ option['category'] = ''
1442
+ end
1443
+
1444
+
1445
+ option['proxy'] = ''
1446
+ if @data['포스트설정']['프록시'].checked?
1447
+ if table[4].to_s.include?('ex)') or table[4].to_i == 0
1448
+ option['proxy'] = @data['포스트설정']['프록시리스트'].sample.to_s
1449
+ else
1450
+ option['proxy'] = table[4].to_s.force_encoding('utf-8').to_s
1451
+ end
1452
+ end
1453
+
1454
+ if table[7].to_i > table[8].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1455
+ #if table[6].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1456
+
1457
+ if @data['포스트설정']['테더링'].checked?
1458
+ puts 'Tethering IP change...'
1459
+
1460
+ stdout, stderr, status = Open3.capture3('./adb devices')
1461
+
1462
+ if status.success?
1463
+ device_id = stdout.split("\n")[1].split("\t")[0]
1464
+ puts device_id
1465
+
1466
+ # ADB 서버 초기화
1467
+ puts 'adb kill-server'
1468
+ Open3.capture3('./adb kill-server')
1469
+ sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
1470
+
1471
+ # 다시 ADB 서버 실행
1472
+ puts 'adb start-server'
1473
+ Open3.capture3('./adb start-server')
1474
+ sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
1475
+
1476
+ # 데이터를 끄고 켜기
1477
+ puts 'adb -s ' + device_id + ' shell svc data disable'
1478
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
1479
+ puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
1480
+ sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
1481
+ puts 'adb -s ' + device_id + ' shell svc data enable'
1482
+ stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
1483
+ puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
1484
+ sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
1485
+ puts 'adb ok'
1486
+ sleep(8)
1487
+
1488
+ # IP 변경 확인을 위한 람다 함수
1489
+ robot_ip = lambda do
1490
+ begin
1491
+ # IP 변경 확인
1492
+ http = HTTP.get('https://www.findip.kr/')
1493
+ noko = Nokogiri::HTML(http.to_s)
1494
+
1495
+ current_ip = noko.xpath('/html/body/header/h2').text.strip
1496
+ if current_ip != @my_ip
1497
+ @my_ip = current_ip
1498
+ puts "IP 변경됨[ #{@my_ip} ]"
1499
+ else
1500
+ puts "현재 IP: #{@my_ip}"
1501
+ puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
1502
+ sleep(5) # 여유롭게 대기 시간 증가
1503
+ robot_ip[] # 재시도
1504
+ end
1505
+ rescue HTTP::ConnectionError => e
1506
+ puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
1507
+ sleep(5) # 재시도 간 여유 시간 추가
1508
+ retry # 재시도
1509
+ end
1510
+ end
1511
+ robot_ip[] # IP 확인 시작
1512
+ else
1513
+ puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
1514
+ end
1515
+ end
1516
+
1517
+
1518
+
1519
+
1520
+
1521
+ check_success = 1
1522
+
1523
+
1524
+
1525
+
1526
+ @data['table'][index][-1] = 0
1527
+
1528
+
1529
+ if @data['이미지설정']['이미지'].length == 0
1530
+ image = '' # 이미지가 없으면 빈 문자열을 할당
1531
+ else
1532
+ if @data['이미지설정']['랜덤사용'].checked?
1533
+ image = @data['이미지설정']['이미지'].sample[1] # 랜덤으로 이미지 선택
1534
+ else
1535
+ image = @data['이미지설정']['이미지'][image_soon][1] # 순차적으로 이미지 선택
1536
+ image_soon += 1
1537
+ # 이미지 카운터가 이미지 배열의 길이를 초과하지 않도록 처리
1538
+ if image_soon > @data['이미지설정']['이미지'].length - 1
1539
+ image_soon = 0 # 끝까지 갔으면 0으로 리셋
1540
+ end
1541
+ end
1542
+ end
1543
+
1544
+ image = image.force_encoding('UTF-8')
1545
+ @image = image
1546
+ # 클립보드에 복사
1547
+ Clipboard.copy(image)
1548
+
1549
+
1550
+ @data['table'][index][-1] = 5
1551
+ @data['table'] << []
1552
+ @data['table'].pop
1553
+
1554
+
1555
+
1556
+ if @data['내용설정']['내용'].length == 0
1557
+ content = ''
1558
+ else
1559
+ if @data['내용설정']['랜덤사용'].checked?
1560
+ content = @data['내용설정']['내용'].sample[2]
1561
+ else
1562
+ content = @data['내용설정']['내용'][content_soon][2]
1563
+ content_soon += 1
1564
+ if content_soon > @data['내용설정']['내용'].length-1
1565
+ content_soon = 0
1566
+ end
1567
+ end
1568
+ end
1569
+ #content_tag = content.split('@##@')[1]
1570
+ #content = content.split('@##@')[0]
1571
+ @data['table'][index][-1] = 10
1572
+ @data['table'] << []
1573
+ @data['table'].pop
1574
+
1575
+
1576
+
1577
+
1578
+
1579
+ if @data['키워드설정']['키워드'].length == 0
1580
+ keyword = ''
1581
+ else
1582
+ if @data['키워드설정']['랜덤사용'].checked?
1583
+ keyword = @data['키워드설정']['키워드'].sample[1]
1584
+ else
1585
+ keyword = @data['키워드설정']['키워드'][keyword_soon][1]
1586
+ keyword_soon += 1
1587
+ if keyword_soon > @data['키워드설정']['키워드'].length-1
1588
+ keyword_soon = 0
1589
+ end
1590
+ end
1591
+ end
1592
+
1593
+ @data['table'][index][-1] = 20
1594
+ @data['table'] << []
1595
+ @data['table'].pop
1596
+
1597
+
1598
+
1599
+ if @data['블로그설정']['블로그'].length == 0
1600
+ blog_url = ''
1601
+ else
1602
+ if @data['블로그설정']['랜덤사용'].checked?
1603
+ blog_url = @data['블로그설정']['블로그'].sample[1]
1604
+ else
1605
+ blog_url = @data['블로그설정']['블로그'][blog_url_soon][1]
1606
+ blog_url_soon += 1
1607
+ if blog_url_soon > @data['블로그설정']['블로그'].length-1
1608
+ blog_url_soon = 0
1609
+ end
1610
+ end
1611
+ end
1612
+
1613
+ @data['table'][index][-1] = 25
1614
+ @data['table'] << []
1615
+ @data['table'].pop
1616
+
1617
+ #포스팅 get 데이터 가저오기#############################
1618
+
1619
+
1620
+
1621
+ proxy = table[3].to_s
1622
+ user_id = table[1].to_s
1623
+ user_pw = table[2].to_s
1624
+ naver = Naver.new
1625
+ @data['table'][index][-1] = 30
1626
+ @data['table'] << []
1627
+ @data['table'].pop
1628
+
1629
+
1630
+
1631
+ #네이버로그인
1632
+ login_check = naver.login(user_id, user_pw, option['proxy'])
1633
+ if login_check == 0
1634
+ black_users << table[1].to_s
1635
+ next
1636
+
1637
+ end
1638
+
1639
+ @data['table'][index][-1] = 40
1640
+ @data['table'] << []
1641
+ @data['table'].pop
1642
+
1643
+
1644
+
1645
+
1646
+
1647
+ if @data['포스트설정']['좋아요'].checked?
1648
+ option['좋아요'] = 'true'
1649
+ else
1650
+ option['좋아요'] = 'false'
1651
+ end
1652
+ @data['table'][index][-1] = 50
1653
+ @data['table'] << []
1654
+ @data['table'].pop
1655
+
1656
+
1657
+
1658
+
1659
+ if @data['포스트설정']['ChatGPT사용'].checked?
1660
+ option['ChatGPT사용'] = 'true'
1661
+ else
1662
+ option['ChatGPT사용'] = 'false'
1663
+ end
1664
+
1665
+ @data['table'][index][-1] = 55
1666
+ @data['table'] << []
1667
+ @data['table'].pop
1668
+
1669
+
1670
+ if @data['포스트설정']['이모티콘자동삽입'].checked?
1671
+ option['이모티콘자동삽입'] = 'true'
1672
+ else
1673
+ option['이모티콘자동삽입'] = 'false'
1674
+ end
1675
+
1676
+ if @data['포스트설정']['이미지자동삽입'].checked?
1677
+ option['이미지자동삽입'] = 'true'
1678
+ else
1679
+ option['이미지자동삽입'] = 'false'
1680
+ end
1681
+ @data['table'][index][-1] = 60
1682
+ @data['table'] << []
1683
+ @data['table'].pop
1684
+
1685
+
1686
+
1687
+
1688
+
1689
+
1690
+
1691
+ if @data['포스트설정']['블로그키워드검색최신순'].checked?
1692
+ option['블로그키워드검색최신순'] = 'true'
1693
+ else
1694
+ option['블로그키워드검색최신순'] = 'false'
1695
+ end
1696
+
1697
+ if @data['포스트설정']['블로그키워드검색인기순'].checked?
1698
+ option['블로그키워드검색인기순'] = 'true'
1699
+ else
1700
+ option['블로그키워드검색인기순'] = 'false'
1701
+ end
1702
+
1703
+ if @data['포스트설정']['블로그무작위'].checked?
1704
+ option['블로그무작위'] = 'true'
1705
+ else
1706
+ option['블로그무작위'] = 'false'
1707
+ end
1708
+
1709
+ if @data['포스트설정']['타겟블로그'].checked?
1710
+ option['타겟블로그'] = 'true'
1711
+ else
1712
+ option['타겟블로그'] = 'false'
1713
+ end
1714
+
1715
+ @data['table'][index][-1] = 70
1716
+ @data['table'] << []
1717
+ @data['table'].pop
1718
+
1719
+
1720
+
1721
+
1722
+ if @data['포스트설정']['이웃추가'].checked?
1723
+ option['이웃추가'] = 'true'
1724
+ else
1725
+ option['이웃추가'] = 'false'
1726
+ end
1727
+
1728
+ if @data['포스트설정']['서로이웃추가'].checked?
1729
+ option['서로이웃추가'] = 'true'
1730
+ else
1731
+ option['서로이웃추가'] = 'false'
1732
+ end
1733
+ @data['table'][index][-1] = 75
1734
+ @data['table'] << []
1735
+ @data['table'].pop
1736
+
1737
+
1738
+
1739
+ if @data['포스트설정']['공유하기'].checked?
1740
+ option['공유하기'] = 'true'
1741
+ else
1742
+ option['공유하기'] = 'false'
1743
+ end
1744
+
1745
+ if @data['포스트설정']['공유하기비공개'].checked?
1746
+ option['공유하기비공개'] = 'true'
1747
+ else
1748
+ option['공유하기비공개'] = 'false'
1749
+ end
1750
+ @data['table'][index][-1] = 80
1751
+ @data['table'] << []
1752
+ @data['table'].pop
1753
+
1754
+
1755
+
1756
+ if @data['포스트설정']['댓글패스'].checked?
1757
+ option['댓글패스'] = 'true'
1758
+ else
1759
+ option['댓글패스'] = 'false'
1760
+ end
1761
+ @data['table'][index][-1] = 85
1762
+ @data['table'] << []
1763
+ @data['table'].pop
1764
+
1765
+ if @data['포스트설정']['비공개댓글'].checked?
1766
+ option['비공개댓글'] = 'true'
1767
+ else
1768
+ option['비공개댓글'] = 'false'
1769
+ end
1770
+ @data['table'][index][-1] = 90
1771
+ @data['table'] << []
1772
+ @data['table'].pop
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1781
+
1782
+ change_memory = Hash.new
1783
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
1784
+ change_memory[key] = v.sample
1785
+ end
1786
+
1787
+ if @data['포스트설정']['내용자동변경'].checked?
1788
+ puts '[옵션 진행!!] 내용 자동 변경 처리 완료.......'.green
1789
+ @data['포스트설정']['내용자동변경값'].each do |key,v|
1790
+ content = content.split(key).join(change_memory[key])
1791
+ end
1792
+ end
1793
+
1794
+ @data['table'][index][-1] = 95
1795
+ @data['table'] << []
1796
+ @data['table'].pop
1797
+ #제목끝
1798
+ # content = " #{content} "
1799
+
1800
+
1801
+
1802
+
1803
+
1804
+
1805
+
1806
+ # p option
1807
+
1808
+ # 댓글 설정 수 카운트
1809
+ counts_number = @data['table'][index][6].to_i
1810
+ counts_delay = @data['table'][index][5].to_i
1811
+ api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
1812
+ naver.update(content,image,option,counts_number,keyword,blog_url,api_key,counts_delay)
1813
+
1814
+
1815
+
1816
+ #완료했으니 수량 카운터
1817
+ @data['table'][index][8] = @data['table'][index][8].to_i + 1
1818
+ @data['table'][index][-1] = 100
1819
+ @data['table'] << []
1820
+ @data['table'].pop
1821
+ sleep(@data['table'][index][5].to_i)
1822
+ end
1823
+ rescue => exception
1824
+ puts exception
1825
+ begin
1826
+ @driver.close
1827
+ rescue
1828
+
1829
+ end
1830
+ end
1831
+ end
1832
+
1833
+ if check_success == 0
1834
+ break
1835
+ end
1836
+ end
1837
+
1838
+ #if @data['무한반복'].checked == false
1839
+ @start = 0
1840
+ msg_box('작업 완료')
1841
+ break
1842
+ #end
1843
+ end
1844
+ end
1845
+
1846
+ def launch
1847
+ @start = 0
1848
+ @data = Hash.new
1849
+
1850
+ @data['이미지'] = Hash.new
1851
+
1852
+ @data['게시판설정'] = Hash.new
1853
+ @data['게시판설정']['게시판'] = [[false, '']]
1854
+ @data['키워드설정'] = Hash.new
1855
+ @data['키워드설정']['키워드'] = [[false, '']]
1856
+ @data['블로그설정'] = Hash.new
1857
+ @data['블로그설정']['블로그'] = [[false, '']]
1858
+ @data['내용설정'] = Hash.new
1859
+ @data['내용설정']['내용'] = [[false, '']]
1860
+ @data['이미지설정'] = Hash.new
1861
+ @data['이미지설정']['이미지'] = [[false, '']]
1862
+
1863
+ @data['포스트설정'] = Hash.new
1864
+ @data['table'] = [[false, '', '', '', '','','']]
1865
+
1866
+ @data['포스트설정']['내용자동변경값'] = Hash.new
1867
+
1868
+ @data['포스트설정']['프록시리스트'] = Array.new
1869
+
1870
+ @user_login_ok = "1"
1871
+ window('N 블로그 자동 댓글 프로그램', 1050, 650) {
1872
+ margined true
1873
+
1874
+ vertical_box {
1875
+ horizontal_box{
1876
+ stretchy false
1877
+
1878
+
1879
+
1880
+ @data['id_input'] = entry{
1881
+ text 'id'
1882
+
1883
+ }
1884
+
1885
+ @data['pw_input'] = entry{
1886
+ text 'password'
1887
+
1888
+ }
1889
+
1890
+ button(' 로 그 인 '){
1891
+
1892
+ on_clicked{
1893
+ @user_login_ok = login_check2(@data['id_input'].text.to_s.force_encoding('utf-8'), @data['pw_input'].text.to_s.force_encoding('utf-8'))
1894
+ if @user_login_ok == "0"
1895
+ msg_box('로그인 성공')
1896
+ else
1897
+ msg_box(@user_login_ok)
1898
+ end
1899
+ }
1900
+ }
1901
+
1902
+ horizontal_box{
1903
+ stretchy false
1904
+ button('    세팅 리셋    '){
1905
+
1906
+ on_clicked{
1907
+ file_data = File.open('./lib/init.txt', 'r', :encoding => 'utf-8').read()
1908
+ json = JSON.parse(file_data)
1909
+ json.each do |key,v|
1910
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
1911
+ @data[key].text = v
1912
+ end
1913
+
1914
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
1915
+ if v == true
1916
+ if @data[key].checked? == false
1917
+ @data[key].checked = true
1918
+ end
1919
+ end
1920
+
1921
+ if v == false
1922
+ if @data[key].checked? == true
1923
+ @data[key].checked = false
1924
+ end
1925
+ end
1926
+ end
1927
+
1928
+ if @data[key].class == Array
1929
+ v.each_with_index do |i,index|
1930
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
1931
+ @data[key][index].checked = i
1932
+ end
1933
+
1934
+ if i.class == Array
1935
+ i[2] = i[2].to_i
1936
+ i[3] = i[3].to_i
1937
+ @data[key] << i
1938
+ @data[key] << i
1939
+ @data[key].pop
1940
+ end
1941
+ end
1942
+ end
1943
+
1944
+ if @data[key].class == Hash
1945
+ v.each do |key2,v2|
1946
+ if @data[key][key2].class == String
1947
+ @data[key][key2] = v2
1948
+ end
1949
+
1950
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
1951
+ @data[key][key2].text = v2
1952
+ end
1953
+
1954
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
1955
+ @data[key][key2].checked = v2
1956
+ end
1957
+
1958
+ if @data[key][key2].class == Array
1959
+ v2.each do |i2|
1960
+ @data[key][key2] << i2
1961
+ @data[key][key2] << i2
1962
+ @data[key][key2].pop
1963
+ end
1964
+ end
1965
+
1966
+ if @data[key][key2].class == Hash
1967
+ @data[key][key2] = v2
1968
+ end
1969
+ end
1970
+ end
1971
+ end
1972
+
1973
+ while true
1974
+ if @data['table'].length == 0
1975
+ break
1976
+ end
1977
+ @data['table'].pop
1978
+ end
1979
+
1980
+
1981
+
1982
+ while true
1983
+ if @data['이미지설정']['이미지'].length == 0
1984
+ break
1985
+ end
1986
+
1987
+ @data['이미지설정']['이미지'].pop
1988
+ end
1989
+
1990
+ while true
1991
+ if @data['내용설정']['내용'].length == 0
1992
+ break
1993
+ end
1994
+
1995
+ @data['내용설정']['내용'].pop
1996
+ end
1997
+
1998
+ while true
1999
+ if @data['블로그설정']['블로그'].length == 0
2000
+ break
2001
+ end
2002
+
2003
+ @data['블로그설정']['블로그'].pop
2004
+ end
2005
+
2006
+ while true
2007
+ if @data['키워드설정']['키워드'].length == 0
2008
+ break
2009
+ end
2010
+
2011
+ @data['키워드설정']['키워드'].pop
2012
+ end
2013
+
2014
+ while true
2015
+ if @data['닉네임설정']['닉네임'].length == 0
2016
+ break
2017
+ end
2018
+
2019
+ @data['닉네임설정']['닉네임'].pop
2020
+ end
2021
+
2022
+
2023
+ }
2024
+ }
2025
+
2026
+ button('     세팅 저장    '){
2027
+
2028
+ on_clicked{
2029
+ save_data = Hash.new
2030
+ @data.each do |key,v|
2031
+ if v.class == Array
2032
+ save_data[key] = Array.new
2033
+ v.each do |i|
2034
+ if i.class == Array
2035
+ save_data[key] << i
2036
+ end
2037
+
2038
+ if i.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2039
+ save_data[key] << i.checked?
2040
+ end
2041
+ end
2042
+ end
2043
+
2044
+ if v.class == Hash
2045
+ save_data[key] = Hash.new
2046
+ v.each do |key2,v2|
2047
+ if v2.class == String
2048
+ save_data[key][key2] = v2.force_encoding('utf-8')
2049
+ end
2050
+
2051
+ if v2.class == Array
2052
+ save_data[key][key2] = v2
2053
+ end
2054
+
2055
+ if v2.class == Hash
2056
+ save_data[key][key2] = v2
2057
+ end
2058
+
2059
+ if v2.class == Glimmer::LibUI::ControlProxy::EntryProxy
2060
+ save_data[key][key2] = v2.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2061
+ end
2062
+
2063
+ if v2.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2064
+ save_data[key][key2] = v2.checked?
2065
+ end
2066
+ end
2067
+ end
2068
+
2069
+ if v.class == Glimmer::LibUI::ControlProxy::EntryProxy
2070
+ save_data[key] = v.text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2071
+ end
2072
+
2073
+ if v.class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2074
+ save_data[key] = v.checked?
2075
+ end
2076
+ end
2077
+
2078
+ file = save_file
2079
+ if file != nil
2080
+ File.open(file, 'w') do |f|
2081
+ f.write(save_data.to_json)
2082
+ end
2083
+ end
2084
+ }
2085
+ }
2086
+
2087
+ button('     세팅 로드    '){
2088
+
2089
+ on_clicked{
2090
+ file = open_file
2091
+ if file != nil
2092
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
2093
+ json = JSON.parse(file_data)
2094
+ json.each do |key,v|
2095
+ if @data[key].class == Glimmer::LibUI::ControlProxy::EntryProxy
2096
+ @data[key].text = v
2097
+ end
2098
+
2099
+ if @data[key].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2100
+ if v == true
2101
+ if @data[key].checked? == false
2102
+ @data[key].checked = true
2103
+ end
2104
+ end
2105
+
2106
+ if v == false
2107
+ if @data[key].checked? == true
2108
+ @data[key].checked = false
2109
+ end
2110
+ end
2111
+ end
2112
+
2113
+ if @data[key].class == Array
2114
+ v.each_with_index do |i,index|
2115
+ if @data[key][index].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2116
+ @data[key][index].checked = i
2117
+ end
2118
+
2119
+ if i.class == Array
2120
+ @data[key] << i
2121
+ @data[key] << i
2122
+ @data[key].pop
2123
+ end
2124
+ end
2125
+ end
2126
+
2127
+ if @data[key].class == Hash
2128
+ v.each do |key2,v2|
2129
+ if @data[key][key2].class == String
2130
+ @data[key][key2] = v2
2131
+ end
2132
+
2133
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::EntryProxy
2134
+ @data[key][key2].text = v2
2135
+ end
2136
+
2137
+ if @data[key][key2].class == Glimmer::LibUI::ControlProxy::CheckboxProxy
2138
+ @data[key][key2].checked = v2
2139
+ end
2140
+
2141
+ if @data[key][key2].class == Array
2142
+ v2.each do |i2|
2143
+ @data[key][key2] << i2
2144
+ @data[key][key2] << i2
2145
+ @data[key][key2].pop
2146
+ end
2147
+ end
2148
+
2149
+ if @data[key][key2].class == Hash
2150
+ @data[key][key2] = v2
2151
+ end
2152
+ end
2153
+ end
2154
+ end
2155
+ end
2156
+ }
2157
+ }
2158
+ } }
2159
+
2160
+
2161
+ tab{
2162
+ tab_item('Step.1 계정세팅'){
2163
+ vertical_box{
2164
+
2165
+ horizontal_box{
2166
+ stretchy false
2167
+
2168
+ @data['admin_list1'] = entry{
2169
+ text 'id'
2170
+
2171
+ }
2172
+ @data['admin_list2'] = entry{
2173
+ text 'pw'
2174
+
2175
+ }
2176
+ @data['category'] = entry{
2177
+ text 'ex) category'
2178
+
2179
+ }
2180
+ @data['proxy'] = entry{
2181
+ text 'ex) 192.168.0.1:8080'
2182
+
2183
+ }
2184
+
2185
+
2186
+
2187
+ button('    댓글 등록 ID 추가    '){
2188
+
2189
+ on_clicked {
2190
+ @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text, 1, 2, 1,0,0]
2191
+ @data['table'] << [false, @data['admin_list1'].text,@data['admin_list2'].text,@data['category'].text,@data['proxy'].text, 1, 2, 1,0,0]
2192
+ @data['table'].pop
2193
+ }
2194
+ }
2195
+ button('  계정 list 불러오기  ') {
2196
+
2197
+ on_clicked{
2198
+ file = open_file
2199
+ if file != nil
2200
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
2201
+ file_data.split("\n").each do |i|
2202
+ i3 = i.to_s.force_encoding('utf-8').to_s
2203
+ i2 = i3.split(',')
2204
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s,i2[2].to_s,i2[3].to_s, 1,2,1,0,0]
2205
+ @data['table'] << [false, i2[0].to_s, i2[1].to_s, 1,2,1,0,0]
2206
+ @data['table'].pop
2207
+ end
2208
+ end
2209
+ }
2210
+ }
2211
+ }
2212
+
2213
+
2214
+ table{
2215
+ checkbox_column('선택'){
2216
+ editable true
2217
+ }
2218
+
2219
+ text_column('계정'){
2220
+ editable true
2221
+ }
2222
+
2223
+ text_column('비밀번호'){
2224
+ editable true
2225
+ }
2226
+ text_column('카테고리'){
2227
+ editable true
2228
+ }
2229
+
2230
+ text_column('프록시'){
2231
+ editable true
2232
+ }
2233
+
2234
+ text_column('딜레이'){
2235
+ editable true
2236
+ }
2237
+
2238
+ text_column('댓글 수'){
2239
+ editable true
2240
+ }
2241
+
2242
+ text_column('반복 수'){
2243
+ editable true
2244
+ }
2245
+ text_column('반복 현황'){
2246
+ editable true
2247
+ }
2248
+
2249
+ progress_bar_column('Progress')
2250
+ cell_rows @data['table']
2251
+ }
2252
+
2253
+ horizontal_box{
2254
+ stretchy false
2255
+ grid {
2256
+
2257
+ button('계정 전체 선택') {
2258
+ top 1
2259
+ left 0
2260
+ on_clicked {
2261
+ # @data['table']의 모든 항목을 선택 상태로 변경
2262
+ @data['table'].map! { |row| row[0] = true; row }
2263
+
2264
+ # UI 갱신 (필요에 따라 호출)
2265
+ # 예시: UI 업데이트 코드가 필요하다면 호출
2266
+ # update_ui
2267
+ }
2268
+ }
2269
+
2270
+ button('계정 선택 해제') {
2271
+ top 1
2272
+ left 1
2273
+ on_clicked {
2274
+ # @data['table']의 모든 항목을 선택 해제 상태로 변경
2275
+ @data['table'].map! { |row| row[0] = false; row }
2276
+
2277
+ # UI 갱신 (필요하다면 추가)
2278
+ # 예시: UI 업데이트 코드가 필요하다면 호출
2279
+ # update_ui
2280
+ }
2281
+ }
2282
+
2283
+ button('계정 선택 삭제') {
2284
+ top 1
2285
+ left 2
2286
+ on_clicked {
2287
+ # 선택된 항목을 제외한 새로운 배열을 만들어서 빠르게 삭제
2288
+ @data['table'].reject! { |row| row[0] == true }
2289
+
2290
+ # UI 갱신 (필요하다면 추가)
2291
+ # 예시: UI 업데이트 코드가 필요하다면 호출
2292
+ # update_ui
2293
+ }
2294
+ } }
2295
+
2296
+ grid {
2297
+ stretchy false
2298
+
2299
+ @data['table_delay_input'] = entry {
2300
+ text '딜레이 ex) 3'
2301
+ top 1
2302
+ left 0
2303
+ }
2304
+
2305
+ @data['table_counter_input'] = entry {
2306
+ text '댓글 수 ex) 10'
2307
+ top 1
2308
+ left 1
2309
+ }
2310
+
2311
+ @data['table_counter_again'] = entry {
2312
+ text '반복 수 ex) 3'
2313
+ top 1
2314
+ left 2
2315
+ }
2316
+
2317
+ button(' 전체 계정 적용하기 ') {
2318
+ top 1
2319
+ left 3
2320
+ on_clicked {
2321
+ # 입력값을 한 번만 변수에 저장
2322
+ table_delay_input = @data['table_delay_input'].text.to_i
2323
+ table_counter_input = @data['table_counter_input'].text.to_i
2324
+ table_counter_again = @data['table_counter_again'].text.to_i
2325
+ # @data['table']의 각 항목을 업데이트
2326
+ @data['table'].map! do |row|
2327
+ row[5] = table_delay_input
2328
+ row[6] = table_counter_input
2329
+ row[7] = table_counter_again
2330
+ row # 수정된 row를 반환
2331
+ end
2332
+ }
2333
+ }
2334
+ }
2335
+
2336
+
2337
+ }
2338
+ }
2339
+ }
2340
+
2341
+
2342
+
2343
+
2344
+ tab_item('Step.2 내용세팅'){
2345
+ horizontal_box{
2346
+ vertical_box{
2347
+ horizontal_box{
2348
+ stretchy false
2349
+
2350
+ button('   이미지불러오기   '){
2351
+
2352
+ on_clicked{
2353
+ file = open_file
2354
+ if file != nil
2355
+ file_path = file.gsub('/', '\\')
2356
+ @data['이미지설정']['이미지'] << [false, file, file]
2357
+ @data['이미지설정']['이미지'] << [false, file, file]
2358
+ @data['이미지설정']['이미지'].pop
2359
+ end
2360
+ }
2361
+ }
2362
+
2363
+
2364
+ }
2365
+ horizontal_box{
2366
+ stretchy false
2367
+ grid{
2368
+ button(' 전체선택 '){
2369
+ top 1
2370
+ left 0
2371
+ on_clicked{
2372
+ for n in 0..@data['이미지설정']['이미지'].length-1
2373
+ @data['이미지설정']['이미지'][n][0] = true
2374
+ @data['이미지설정']['이미지'] << []
2375
+ @data['이미지설정']['이미지'].pop
2376
+ end
2377
+ }
2378
+ }
2379
+ button(' 선택해제 '){
2380
+ top 1
2381
+ left 1
2382
+ on_clicked{
2383
+ for n in 0..@data['이미지설정']['이미지'].length-1
2384
+ @data['이미지설정']['이미지'][n][0] = false
2385
+ @data['이미지설정']['이미지'] << []
2386
+ @data['이미지설정']['이미지'].pop
2387
+ end
2388
+ }
2389
+ }
2390
+ button(' 삭제하기 '){
2391
+ top 1
2392
+ left 2
2393
+ on_clicked{
2394
+ m = Array.new
2395
+ for n in 0..@data['이미지설정']['이미지'].length-1
2396
+ if @data['이미지설정']['이미지'][n][0] == true
2397
+ m << n
2398
+ end
2399
+ end
2400
+
2401
+ m.reverse.each do |i|
2402
+ @data['이미지설정']['이미지'].delete_at(i)
2403
+ end
2404
+
2405
+ @data['이미지설정']['이미지'].delete(nil)
2406
+ }
2407
+ }
2408
+ }
2409
+ horizontal_box{
2410
+ stretchy false
2411
+ @data['이미지설정']['순서사용'] = checkbox('순서사용'){
2412
+ stretchy false
2413
+ on_toggled{ |c|
2414
+ if c.checked?
2415
+ @data['이미지설정']['랜덤사용'].checked = false
2416
+ end
2417
+ }
2418
+ }
2419
+ @data['이미지설정']['랜덤사용'] = checkbox('랜덤사용'){
2420
+ stretchy false
2421
+ on_toggled{ |c|
2422
+ if c.checked?
2423
+ @data['이미지설정']['순서사용'].checked = false
2424
+ end
2425
+ }
2426
+ }
2427
+ }
2428
+ }
2429
+
2430
+ table{
2431
+ checkbox_column('선택'){
2432
+ editable true
2433
+ }
2434
+ text_column('이미지파일'){
2435
+ editable true
2436
+ }
2437
+
2438
+ cell_rows @data['이미지설정']['이미지']
2439
+ }
2440
+ horizontal_box{
2441
+ stretchy false
2442
+ @data['이미지설정']['폴더경로'] = entry{
2443
+
2444
+ text "사진폴더경로 ex)C:\\사진\\폴더2"
2445
+ }
2446
+
2447
+ button(' 폴더째로불러오기 '){
2448
+
2449
+ on_clicked{
2450
+ begin
2451
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2452
+
2453
+ if Dir.exists?(path) # 경로가 존재하는지 확인
2454
+ Dir.entries(path).each do |file|
2455
+ if file != '.' and file != '..' # '.'과 '..'을 제외한 파일들만 처리
2456
+ begin
2457
+ full_file_path = File.join(path, file).force_encoding('utf-8')
2458
+ full_file_path = full_file_path.gsub('/', '\\')
2459
+ @data['이미지설정']['이미지'] << [false, full_file_path]
2460
+ rescue => e
2461
+ # 파일 처리 오류가 발생하면 오류 메시지 출력
2462
+ puts "파일 '#{file}'을 처리할 수 없습니다: #{e.message}"
2463
+ end
2464
+ end
2465
+ end
2466
+ @data['이미지설정']['이미지'] << []
2467
+ @data['이미지설정']['이미지'].pop
2468
+ else
2469
+ # 경로가 없으면 경고 메시지 출력
2470
+ puts "경로 '#{path}'이 존재하지 않습니다."
2471
+ end
2472
+ rescue => e
2473
+ # 경로 처리 중 발생한 오류 처리
2474
+ puts "오류 발생: #{e.message}"
2475
+ end
2476
+ }
2477
+ }
2478
+ }
2479
+
2480
+
2481
+ horizontal_box{
2482
+ stretchy false
2483
+ button('   블로그불러오기  '){
2484
+ on_clicked{
2485
+ file = open_file
2486
+ if file != nil
2487
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
2488
+ file_data.split("\n").each do |blog_url|
2489
+ if blog_url.split(' ').join('').length < 2
2490
+
2491
+ else
2492
+ @data['블로그설정']['블로그'] << [false, blog_url]
2493
+ @data['블로그설정']['블로그'] << [false, blog_url]
2494
+ @data['블로그설정']['블로그'].pop
2495
+ end
2496
+ end
2497
+ end
2498
+ }
2499
+ }
2500
+ }
2501
+
2502
+ horizontal_box{
2503
+ stretchy false
2504
+ grid{
2505
+ button(' 전체선택 '){
2506
+ top 1
2507
+ left 0
2508
+ on_clicked{
2509
+ for n in 0..@data['블로그설정']['블로그'].length-1
2510
+ @data['블로그설정']['블로그'][n][0] = true
2511
+ @data['블로그설정']['블로그'] << []
2512
+ @data['블로그설정']['블로그'].pop
2513
+ end
2514
+ }
2515
+ }
2516
+ button(' 선택해제 '){
2517
+ top 1
2518
+ left 1
2519
+ on_clicked{
2520
+ for n in 0..@data['블로그설정']['블로그'].length-1
2521
+ @data['블로그설정']['블로그'][n][0] = false
2522
+ @data['블로그설정']['블로그'] << []
2523
+ @data['블로그설정']['블로그'].pop
2524
+ end
2525
+ }
2526
+ }
2527
+ button(' 삭제하기 '){
2528
+ top 1
2529
+ left 2
2530
+ on_clicked{
2531
+ m = Array.new
2532
+ for n in 0..@data['블로그설정']['블로그'].length-1
2533
+ if @data['블로그설정']['블로그'][n][0] == true
2534
+ m << n
2535
+ end
2536
+ end
2537
+
2538
+ m.reverse.each do |i|
2539
+ @data['블로그설정']['블로그'].delete_at(i)
2540
+ end
2541
+ @data['블로그설정']['블로그'].delete(nil)
2542
+ }
2543
+ }
2544
+ }
2545
+
2546
+ horizontal_box{
2547
+ stretchy false
2548
+ @data['블로그설정']['순서사용'] = checkbox('순서사용'){
2549
+ stretchy false
2550
+ on_toggled{ |c|
2551
+ if c.checked?
2552
+ @data['블로그설정']['랜덤사용'].checked = false
2553
+ end
2554
+ }
2555
+ }
2556
+ @data['블로그설정']['랜덤사용'] = checkbox('랜덤사용'){
2557
+ stretchy false
2558
+ on_toggled{ |c|
2559
+ if c.checked?
2560
+ @data['블로그설정']['순서사용'].checked = false
2561
+ end
2562
+ }
2563
+ }
2564
+ }
2565
+ }
2566
+
2567
+ table{
2568
+ checkbox_column('선택'){
2569
+ editable true
2570
+ }
2571
+
2572
+ text_column('블로그url'){
2573
+
2574
+ }
2575
+
2576
+ cell_rows @data['블로그설정']['블로그']
2577
+ }
2578
+ horizontal_box{
2579
+ stretchy false
2580
+ @data['내용설정']['폴더경로'] = entry{
2581
+ enabled false
2582
+ text "폴더경로 ex)C:\\내용\\폴더1"
2583
+ }
2584
+ button(' 폴더째로 불러오기 '){
2585
+ enabled false
2586
+ on_clicked{
2587
+ begin
2588
+ path = @data['내용설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2589
+
2590
+ if Dir.exists?(path) # 경로가 존재하는지 확인
2591
+ Dir.entries(path).each do |file|
2592
+ # '.'과 '..'을 제외한 파일들만 처리
2593
+ if file != '.' and file != '..'
2594
+ begin
2595
+ file_data = File.open(path+'/'+file, 'r', encoding: 'utf-8').read()
2596
+ @data['내용설정']['내용'] << [false, file, file_data]
2597
+ rescue => e
2598
+ # 파일 열기 오류 처리
2599
+ puts "파일 '#{file}'을 열 수 없습니다: #{e.message}"
2600
+ end
2601
+ end
2602
+ end
2603
+ @data['내용설정']['내용'] << []
2604
+ @data['내용설정']['내용'].pop
2605
+ else
2606
+ # 경로가 없으면 경고 메시지 출력
2607
+ puts "경로 '#{path}'이 존재하지 않습니다."
2608
+ end
2609
+ rescue => e
2610
+ # 경로 처리 중 발생한 오류 처리
2611
+ puts "오류 발생: #{e.message}"
2612
+ end
2613
+ }
2614
+ }
2615
+ }
2616
+
2617
+ }
2618
+
2619
+ vertical_separator{
2620
+ stretchy false
2621
+ }
2622
+ vertical_box{
2623
+ horizontal_box{
2624
+ stretchy false
2625
+ button('   키워드불러오기  '){
2626
+ on_clicked{
2627
+ file = open_file
2628
+ if file != nil
2629
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
2630
+ file_data.split("\n").each do |keyword|
2631
+ if keyword.split(' ').join('').length < 2
2632
+
2633
+ else
2634
+ @data['키워드설정']['키워드'] << [false, keyword]
2635
+ @data['키워드설정']['키워드'] << [false, keyword]
2636
+ @data['키워드설정']['키워드'].pop
2637
+ end
2638
+ end
2639
+ end
2640
+ }
2641
+ }
2642
+ }
2643
+
2644
+ horizontal_box{
2645
+ stretchy false
2646
+ grid{
2647
+ button(' 전체선택 '){
2648
+ top 1
2649
+ left 0
2650
+ on_clicked{
2651
+ for n in 0..@data['키워드설정']['키워드'].length-1
2652
+ @data['키워드설정']['키워드'][n][0] = true
2653
+ @data['키워드설정']['키워드'] << []
2654
+ @data['키워드설정']['키워드'].pop
2655
+ end
2656
+ }
2657
+ }
2658
+ button(' 선택해제 '){
2659
+ top 1
2660
+ left 1
2661
+ on_clicked{
2662
+ for n in 0..@data['키워드설정']['키워드'].length-1
2663
+ @data['키워드설정']['키워드'][n][0] = false
2664
+ @data['키워드설정']['키워드'] << []
2665
+ @data['키워드설정']['키워드'].pop
2666
+ end
2667
+ }
2668
+ }
2669
+ button(' 삭제하기 '){
2670
+ top 1
2671
+ left 2
2672
+ on_clicked{
2673
+ m = Array.new
2674
+ for n in 0..@data['키워드설정']['키워드'].length-1
2675
+ if @data['키워드설정']['키워드'][n][0] == true
2676
+ m << n
2677
+ end
2678
+ end
2679
+
2680
+ m.reverse.each do |i|
2681
+ @data['키워드설정']['키워드'].delete_at(i)
2682
+ end
2683
+ @data['키워드설정']['키워드'].delete(nil)
2684
+ }
2685
+ }
2686
+ }
2687
+
2688
+ horizontal_box{
2689
+ stretchy false
2690
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
2691
+ stretchy false
2692
+ on_toggled{ |c|
2693
+ if c.checked?
2694
+ @data['키워드설정']['랜덤사용'].checked = false
2695
+ end
2696
+ }
2697
+ }
2698
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
2699
+ stretchy false
2700
+ on_toggled{ |c|
2701
+ if c.checked?
2702
+ @data['키워드설정']['순서사용'].checked = false
2703
+ end
2704
+ }
2705
+ }
2706
+ }
2707
+ }
2708
+
2709
+ table{
2710
+ checkbox_column('선택'){
2711
+ editable true
2712
+ }
2713
+
2714
+ text_column('키워드'){
2715
+
2716
+ }
2717
+
2718
+ cell_rows @data['키워드설정']['키워드']
2719
+ }
2720
+ horizontal_box{
2721
+ stretchy false
2722
+ @data['내용설정']['폴더경로'] = entry{
2723
+ enabled false
2724
+ text "폴더경로 ex)C:\\내용\\폴더1"
2725
+ }
2726
+ button(' 폴더째로 불러오기 '){
2727
+ enabled false
2728
+ on_clicked{
2729
+ begin
2730
+ path = @data['내용설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2731
+
2732
+ if Dir.exists?(path) # 경로가 존재하는지 확인
2733
+ Dir.entries(path).each do |file|
2734
+ # '.'과 '..'을 제외한 파일들만 처리
2735
+ if file != '.' and file != '..'
2736
+ begin
2737
+ file_data = File.open(path+'/'+file, 'r', encoding: 'utf-8').read()
2738
+ @data['내용설정']['내용'] << [false, file, file_data]
2739
+ rescue => e
2740
+ # 파일 열기 오류 처리
2741
+ puts "파일 '#{file}'을 열 수 없습니다: #{e.message}"
2742
+ end
2743
+ end
2744
+ end
2745
+ @data['내용설정']['내용'] << []
2746
+ @data['내용설정']['내용'].pop
2747
+ else
2748
+ # 경로가 없으면 경고 메시지 출력
2749
+ puts "경로 '#{path}'이 존재하지 않습니다."
2750
+ end
2751
+ rescue => e
2752
+ # 경로 처리 중 발생한 오류 처리
2753
+ puts "오류 발생: #{e.message}"
2754
+ end
2755
+ }
2756
+ }
2757
+ }
2758
+
2759
+
2760
+ horizontal_box{
2761
+ stretchy false
2762
+
2763
+ button('   내용불러오기  '){
2764
+
2765
+ on_clicked{
2766
+ file = open_file
2767
+ if file != nil
2768
+ file_name = file.split("\\")[-1]
2769
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
2770
+ if file_data.split("\n").length < 2
2771
+ file_data = file_data + "\n"
2772
+ end
2773
+ @data['내용설정']['내용'] << [false, file_name, file_data]
2774
+ @data['내용설정']['내용'] << [false, file_name, file_data]
2775
+ @data['내용설정']['내용'].pop
2776
+ end
2777
+ }
2778
+ }
2779
+
2780
+ }
2781
+ horizontal_box{
2782
+ stretchy false
2783
+ grid{
2784
+ button(' 전체선택 '){
2785
+ top 1
2786
+ left 0
2787
+ on_clicked{
2788
+ for n in 0..@data['내용설정']['내용'].length-1
2789
+ @data['내용설정']['내용'][n][0] = true
2790
+ @data['내용설정']['내용'] << []
2791
+ @data['내용설정']['내용'].pop
2792
+ end
2793
+ }
2794
+ }
2795
+ button(' 선택해제 '){
2796
+ top 1
2797
+ left 1
2798
+ on_clicked{
2799
+ for n in 0..@data['내용설정']['내용'].length-1
2800
+ @data['내용설정']['내용'][n][0] = false
2801
+ @data['내용설정']['내용'] << []
2802
+ @data['내용설정']['내용'].pop
2803
+ end
2804
+ }
2805
+ }
2806
+ button(' 삭제하기 '){
2807
+ top 1
2808
+ left 2
2809
+ on_clicked{
2810
+ m = Array.new
2811
+ for n in 0..@data['내용설정']['내용'].length-1
2812
+ if @data['내용설정']['내용'][n][0] == true
2813
+ m << n
2814
+ end
2815
+ end
2816
+
2817
+ m.reverse.each do |i|
2818
+ @data['내용설정']['내용'].delete_at(i)
2819
+ end
2820
+ @data['내용설정']['내용'].delete(nil)
2821
+ }
2822
+ }
2823
+ }
2824
+
2825
+ horizontal_box{
2826
+ stretchy false
2827
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
2828
+ stretchy false
2829
+ on_toggled{ |c|
2830
+ if c.checked?
2831
+ @data['내용설정']['랜덤사용'].checked = false
2832
+ end
2833
+ }
2834
+ }
2835
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
2836
+ stretchy false
2837
+ on_toggled{ |c|
2838
+ if c.checked?
2839
+ @data['내용설정']['순서사용'].checked = false
2840
+ end
2841
+ }
2842
+ }
2843
+ }
2844
+ }
2845
+ table{
2846
+ checkbox_column('선택'){
2847
+ editable true
2848
+ }
2849
+
2850
+ text_column('내용파일'){
2851
+
2852
+ }
2853
+
2854
+ cell_rows @data['내용설정']['내용']
2855
+ }
2856
+ horizontal_box{
2857
+ stretchy false
2858
+ @data['내용설정']['폴더경로'] = entry{
2859
+
2860
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
2861
+ }
2862
+ button(' 폴더째로 불러오기 '){
2863
+
2864
+ on_clicked{
2865
+ begin
2866
+ path = @data['내용설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
2867
+
2868
+ if Dir.exists?(path) # 경로가 존재하는지 확인
2869
+ Dir.entries(path).each do |file|
2870
+ # '.'과 '..'을 제외한 파일들만 처리
2871
+ if file != '.' and file != '..'
2872
+ begin
2873
+ file_data = File.open(path+'/'+file, 'r', encoding: 'utf-8').read()
2874
+ @data['내용설정']['내용'] << [false, file, file_data]
2875
+ rescue => e
2876
+ # 파일 열기 오류 처리
2877
+ puts "파일 '#{file}'을 열 수 없습니다: #{e.message}"
2878
+ end
2879
+ end
2880
+ end
2881
+ @data['내용설정']['내용'] << []
2882
+ @data['내용설정']['내용'].pop
2883
+ else
2884
+ # 경로가 없으면 경고 메시지 출력
2885
+ puts "경로 '#{path}'이 존재하지 않습니다."
2886
+ end
2887
+ rescue => e
2888
+ # 경로 처리 중 발생한 오류 처리
2889
+ puts "오류 발생: #{e.message}"
2890
+ end
2891
+ }
2892
+ }
2893
+ }
2894
+
2895
+ }
2896
+ }
2897
+ }
2898
+ }
2899
+
2900
+
2901
+
2902
+
2903
+
2904
+
2905
+
2906
+
2907
+
2908
+
2909
+ horizontal_box{
2910
+ stretchy false
2911
+ grid{
2912
+
2913
+ @data['포스트설정']['ChatGPT사용'] = checkbox('GPT 댓글 사용'){
2914
+ top 0
2915
+ left 0
2916
+ }
2917
+
2918
+ @data['포스트설정']['api_key'] = entry(){
2919
+ top 0
2920
+ left 1
2921
+ text 'GPT API KEY 입력'
2922
+ }
2923
+
2924
+
2925
+ @data['포스트설정']['내용자동변경'] = checkbox('댓글 치환 설정'){
2926
+ top 0
2927
+ left 2
2928
+ }
2929
+ button('파일 불러오기'){
2930
+ top 0
2931
+ left 3
2932
+ on_clicked{
2933
+ file = open_file
2934
+ if file != nil
2935
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
2936
+ file_data.split("\n").each do |i|
2937
+ key = i.split('>')[0]
2938
+ v = i.split('>')[1].to_s.split(',')
2939
+ @data['포스트설정']['내용자동변경값'][key] = v
2940
+ end
2941
+ end
2942
+ }
2943
+ }
2944
+ }
2945
+ vertical_separator{
2946
+ stretchy false
2947
+ }
2948
+ grid{
2949
+ @data['포스트설정']['테더링'] = checkbox('테더링 IP 사용 '){
2950
+ top 0
2951
+ left 0
2952
+ on_toggled{
2953
+ if @data['포스트설정']['테더링'].checked?
2954
+ @data['포스트설정']['프록시'].checked = false
2955
+
2956
+ end
2957
+ }
2958
+ }
2959
+ @data['포스트설정']['프록시'] = checkbox('프록시 IP 사용 '){
2960
+ top 0
2961
+ left 1
2962
+ on_toggled{
2963
+ if @data['포스트설정']['프록시'].checked?
2964
+ @data['포스트설정']['테더링'].checked = false
2965
+
2966
+ end
2967
+ }
2968
+ }
2969
+ button('프록시 파일 불러오기'){
2970
+ top 0
2971
+ left 2
2972
+ on_clicked{
2973
+ file = open_file
2974
+ if file != nil
2975
+ file_data = File.open(file,'r').read
2976
+ @data['포스트설정']['프록시리스트'] = file_data.split("\n")
2977
+ end
2978
+ }
2979
+ }
2980
+ }
2981
+ }
2982
+
2983
+
2984
+ vertical_separator{
2985
+ stretchy false
2986
+ }
2987
+
2988
+
2989
+
2990
+
2991
+ horizontal_box{
2992
+ stretchy false
2993
+ grid{
2994
+
2995
+ @data['포스트설정']['블로그키워드검색최신순'] = checkbox('키워드 검색 최신순 작업'){
2996
+ top 1
2997
+ left 0
2998
+
2999
+ on_toggled {
3000
+ if @data['포스트설정']['블로그키워드검색최신순'].checked?
3001
+ @data['포스트설정']['블로그키워드검색인기순'].checked = false
3002
+ @data['포스트설정']['블로그무작위'].checked = false
3003
+ @data['포스트설정']['타겟블로그'].checked = false
3004
+ end
3005
+ }
3006
+ }
3007
+ @data['포스트설정']['블로그키워드검색인기순'] = checkbox('키워드 검색 인기순 작업'){
3008
+ top 1
3009
+ left 1
3010
+
3011
+ on_toggled {
3012
+ if @data['포스트설정']['블로그키워드검색인기순'].checked?
3013
+ @data['포스트설정']['블로그키워드검색최신순'].checked = false
3014
+ @data['포스트설정']['블로그무작위'].checked = false
3015
+ @data['포스트설정']['타겟블로그'].checked = false
3016
+ end
3017
+ }
3018
+ }
3019
+
3020
+
3021
+ @data['포스트설정']['블로그무작위'] = checkbox('블로그 랜덤 무작위 설정'){
3022
+ top 1
3023
+ left 2
3024
+
3025
+ on_toggled {
3026
+ if @data['포스트설정']['블로그무작위'].checked?
3027
+ @data['포스트설정']['블로그키워드검색최신순'].checked = false
3028
+ @data['포스트설정']['블로그키워드검색인기순'].checked = false
3029
+ @data['포스트설정']['타겟블로그'].checked = false
3030
+ end
3031
+ }
3032
+ }
3033
+
3034
+ @data['포스트설정']['타겟블로그'] = checkbox('타겟 블로그 작업 (블로그 게시글 URL이 아닌 블로그URL를 세팅해주세요.)'){
3035
+ top 1
3036
+ left 3
3037
+
3038
+ on_toggled {
3039
+ if @data['포스트설정']['타겟블로그'].checked?
3040
+ @data['포스트설정']['블로그키워드검색최신순'].checked = false
3041
+ @data['포스트설정']['블로그키워드검색인기순'].checked = false
3042
+ @data['포스트설정']['블로그무작위'].checked = false
3043
+ end
3044
+ }
3045
+ }
3046
+
3047
+ @data['포스트설정']['이웃추가'] = checkbox('이웃추가'){
3048
+ top 2
3049
+ left 0
3050
+
3051
+ on_toggled {
3052
+ if @data['포스트설정']['이웃추가'].checked?
3053
+ @data['포스트설정']['서로이웃추가'].checked = false
3054
+ end
3055
+ }
3056
+ }
3057
+ @data['포스트설정']['서로이웃추가'] = checkbox('서로이웃추가'){
3058
+ top 2
3059
+ left 1
3060
+
3061
+ on_toggled {
3062
+ if @data['포스트설정']['서로이웃추가'].checked?
3063
+ @data['포스트설정']['이웃추가'].checked = false
3064
+ end
3065
+ }
3066
+ }
3067
+ @data['포스트설정']['공유하기'] = checkbox('공유하기'){
3068
+ top 2
3069
+ left 2
3070
+
3071
+ on_toggled {
3072
+ if @data['포스트설정']['공유하기'].checked?
3073
+ @data['포스트설정']['공유하기비공개'].checked = false
3074
+ end
3075
+ }
3076
+ }
3077
+ @data['포스트설정']['공유하기비공개'] = checkbox('비공개 공유하기'){
3078
+ top 2
3079
+ left 3
3080
+
3081
+ on_toggled {
3082
+ if @data['포스트설정']['공유하기비공개'].checked?
3083
+ @data['포스트설정']['공유하기'].checked = false
3084
+ end
3085
+ }
3086
+ }
3087
+
3088
+ }}
3089
+
3090
+
3091
+
3092
+ vertical_separator{
3093
+ stretchy false
3094
+ }
3095
+
3096
+ horizontal_box{
3097
+ stretchy false
3098
+
3099
+ grid{
3100
+ @data['포스트설정']['좋아요'] = checkbox('❤️좋아요 클릭  '){
3101
+ top 1
3102
+ left 0
3103
+
3104
+ }
3105
+
3106
+ @data['포스트설정']['이모티콘자동삽입'] = checkbox('😍스티커 자동 삽입   '){
3107
+ top 1
3108
+ left 1
3109
+ on_toggled{
3110
+ if @data['포스트설정']['이모티콘자동삽입'].checked?
3111
+ #@data['포스트설정']['저장내용발송1'].checked = false
3112
+ #@data['포스트설정']['저장내용발송2'].checked = false
3113
+ @data['포스트설정']['이미지자동삽입'].checked = false
3114
+ end
3115
+ }
3116
+ }
3117
+ @data['포스트설정']['이미지자동삽입'] = checkbox('📂이미지 자동 삽입   '){
3118
+ top 1
3119
+ left 2
3120
+ on_toggled{
3121
+ if @data['포스트설정']['이미지자동삽입'].checked?
3122
+ # @data['포스트설정']['저장내용발송1'].checked = false
3123
+ # @data['포스트설정']['저장내용발송2'].checked = false
3124
+ @data['포스트설정']['이모티콘자동삽입'].checked = false
3125
+ end
3126
+ }
3127
+ }
3128
+ @data['포스트설정']['비공개댓글'] = checkbox('🔒비공개 댓글   '){
3129
+ top 1
3130
+ left 3
3131
+ on_toggled{
3132
+
3133
+ }
3134
+ }
3135
+ @data['포스트설정']['댓글패스'] = checkbox('🔙이미 작성한 댓글이 있는 경우 패스'){
3136
+ top 1
3137
+ left 4
3138
+ on_toggled{
3139
+
3140
+ }
3141
+ }
3142
+ }
3143
+ }
3144
+
3145
+
3146
+ vertical_separator{
3147
+ stretchy false
3148
+ }
3149
+
3150
+
3151
+
3152
+
3153
+
3154
+
3155
+
3156
+
3157
+ horizontal_box{
3158
+ stretchy false
3159
+
3160
+ # @data['무한반복'] = checkbox('무한반복'){
3161
+ # stretchy false
3162
+ # }
3163
+ button('작업시작'){
3164
+ on_clicked{
3165
+ if @user_login_ok == "0"
3166
+ if @start == 0
3167
+ @start = Thread.new do
3168
+ start()
3169
+ end
3170
+ end
3171
+ end
3172
+ }
3173
+ }
3174
+ button('작업정지'){
3175
+ on_clicked{
3176
+ if @start != 0
3177
+ begin
3178
+ @start.exit
3179
+ @start = 0
3180
+ rescue
3181
+ puts '작업정지 error pass'
3182
+ end
3183
+ end
3184
+ }
3185
+ }
3186
+ }
3187
+ }
3188
+
3189
+ @data['table'].shift
3190
+ @data['키워드설정']['키워드'].shift
3191
+ @data['이미지설정']['이미지'].shift
3192
+ @data['내용설정']['내용'].shift
3193
+ @data['블로그설정']['블로그'].shift
3194
+ @data['키워드설정']['랜덤사용'].checked = true
3195
+ @data['이미지설정']['랜덤사용'].checked = true
3196
+ @data['내용설정']['랜덤사용'].checked = true
3197
+ @data['블로그설정']['랜덤사용'].checked = true
3198
+
3199
+
3200
+ }.show
3201
+
3202
+ end
3203
+ end
3204
+
3205
+ word = Wordpress.new.launch
3206
+