posting_zon 0.0.65 → 0.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/posting_zon.rb +1426 -911
  3. metadata +2 -2
data/lib/posting_zon.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'glimmer-dsl-libui'
2
2
  require 'selenium-webdriver'
3
- # require 'webdrivers'
3
+ require 'webdrivers'
4
4
  require 'iconv'
5
5
  require 'nokogiri'
6
6
  require 'open-uri'
@@ -27,42 +27,71 @@ using Rainbow
27
27
 
28
28
 
29
29
  class Naver
30
-
31
- def chrome_start(proxy)
30
+ def initialize
31
+
32
+ begin
33
+ # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
34
+
35
+ # Webdrivers가 드라이버를 다운로드할 경로를 설정
36
+ Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
37
+ Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
38
+ # 크롬드라이버 자동 업데이트 시도
39
+ Webdrivers::Chromedriver.update
40
+ puts "chromedriver 자동 다운로드 성공"
41
+ rescue => e
42
+ puts "chromedriver 자동 다운로드 실패: #{e.message}"
43
+ puts "폴더내 크롬드라이버를 사용합니다."
44
+ puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
45
+ puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
46
+ chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
47
+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
48
+ end
49
+
50
+ end
51
+
52
+
53
+ def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
54
+ board_cookie_dir = "C:/board_cookie"
55
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
56
+
57
+ if proxy == ''
58
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --window-position=0,0 --remote-debugging-port=9222 --user-data-dir=C:/board_cookie --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
59
+ else
60
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --window-position=0,0 --remote-debugging-port=9222 --user-data-dir=C:/board_cookie --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
61
+ end
62
+ end
63
+
64
+
65
+
66
+ def chrome_start(proxy, board_cookie_dir = "C:/board_cookie")
67
+ board_cookie_dir = "C:/board_cookie"
68
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
32
69
  if proxy == ''
33
70
  begin
34
-
35
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
36
71
  options = Selenium::WebDriver::Chrome::Options.new
37
- options.add_extension('./crx/free.crx')
38
- options.add_extension('./crx/app.crx')
72
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
73
+ #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
74
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
75
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
76
+ options.add_argument('--no-default-browser-check')
39
77
  options.page_load_strategy = :normal
40
- options.timeouts = { page_load: 20_000 }
78
+ options.timeouts = {page_load: 30_000}
79
+ options.page_load_strategy = 'none'
80
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
41
81
  options.add_argument('--disable-gpu')
42
- options.add_argument('--start-maximized')
43
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
44
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
45
- options.add_argument('--disable-web-security') # 보안 비활성화
46
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
47
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
48
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
49
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
50
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
51
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
52
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
53
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
54
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
55
- options.add_argument("--disable-logging")
56
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
57
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
58
-
82
+ options.add_argument('--remote-debugging-port=9222')
83
+ options.add_argument('user-data-dir=C:/board_cookie')
84
+
85
+ options.add_argument('--disable-save-password-bubble') # 비밀번호 저장 팝업 비활성화
86
+ options.add_argument('--disable-password-manager') # 비밀번호 관리 비활성화
87
+
88
+
59
89
  # 'capabilities'과 'options' 배열로 설정
60
90
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
61
91
  capabilities["goog:chromeOptions"] = options.as_json
62
92
 
63
93
  # Selenium 4에서는 'capabilities'만 사용하는 방식
64
94
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
65
-
66
95
 
67
96
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
68
97
 
@@ -71,35 +100,23 @@ class Naver
71
100
  end
72
101
  else
73
102
  begin
74
- puts '프록시 연결합니다.......'.magenta
75
- puts '프록시 연결시 프록시 서버에 의해 인터넷속도가 낮아질수있어.......'.magenta
76
- puts '원활한 작업이 되지않을수있습니다.......'.magenta
77
103
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
78
104
  options = Selenium::WebDriver::Chrome::Options.new
105
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
106
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
107
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
108
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
109
+ options.add_argument('--no-default-browser-check')
79
110
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
80
- options.add_extension('./crx/free.crx')
81
- options.add_extension('./crx/app.crx')
82
111
  options.page_load_strategy = :normal
83
- options.timeouts = { page_load: 20_000 }
112
+ options.timeouts = {page_load: 30_000}
113
+ options.page_load_strategy = 'none'
114
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
84
115
  options.add_argument('--disable-gpu')
85
- options.add_argument('--start-maximized')
86
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
87
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
88
- options.add_argument('--disable-web-security') # 웹 보안 비활성화
89
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
90
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
91
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
92
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
93
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
94
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
95
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
96
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
97
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
98
- options.add_argument("--disable-logging")
99
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
100
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
101
-
102
-
116
+ options.add_argument('--remote-debugging-port=9222')
117
+ options.add_argument('user-data-dir=C:/board_cookie')
118
+
119
+
103
120
  # 'capabilities'과 'options' 배열로 설정
104
121
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
105
122
  capabilities["goog:chromeOptions"] = options.as_json
@@ -108,35 +125,27 @@ class Naver
108
125
  @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
109
126
 
110
127
  @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
111
-
112
128
  rescue => e
113
129
  puts e
114
130
  puts 'proxy error...'
115
131
  begin
116
132
  Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
117
133
  options = Selenium::WebDriver::Chrome::Options.new
118
- options.add_extension('./crx/free.crx')
119
- options.add_extension('./crx/app.crx')
134
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
135
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
136
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
137
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
138
+ options.add_argument('--no-default-browser-check')
120
139
  options.page_load_strategy = :normal
121
- options.timeouts = { page_load: 20_000 }
140
+ options.timeouts = {page_load: 30_000}
141
+ options.page_load_strategy = 'none'
142
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
122
143
  options.add_argument('--disable-gpu')
123
- options.add_argument('--start-maximized')
124
- options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36') # user-agent 위조
125
- options.add_argument('--disable-blink-features=AutomationControlled') # 자동화된 환경에서 실행되는 것을 감지하는 기능 비활성화
126
- options.add_argument('--disable-web-security') # 웹 보안 비활성화
127
- options.add_argument('--allow-running-insecure-content') # HTTPS 사이트에서 HTTP 컨텐츠 실행 허용
128
- options.add_argument('--no-sandbox') # 샌드박스 모드 비활성화
129
- options.exclude_switches = ['enable-automation'] # 자동화 테스트 제거
130
- options.add_preference("profile.password_manager_enabled", false) # 비밀번호 관리자 비활성화
131
- options.add_preference("credentials_enable_service", false) # 비밀번호 저장 기능 비활성화
132
- options.add_preference("profile.default_content_setting_values.notifications", 2) # 알림 차단
133
- options.add_argument("--disable-save-password-bubble") # 비밀번호 저장 팝업 차단
134
- options.add_argument('--disable-software-rasterizer') # 소프트웨어 렌더링 비활성화
135
- options.add_argument('--remote-debugging-port=9222') # 디버깅 포트 설정
136
- options.add_argument("--disable-logging")
137
- options.add_argument("--silent") # 로그를 최소화 (최소한의 경고만)
138
- options.add_argument("--log-level=3") # LogLevel: 3 = ERROR
139
-
144
+ options.add_argument('--remote-debugging-port=9222')
145
+ options.add_argument('user-data-dir=C:/board_cookie')
146
+
147
+
148
+
140
149
  # 'capabilities'과 'options' 배열로 설정
141
150
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
142
151
  capabilities["goog:chromeOptions"] = options.as_json
@@ -151,225 +160,419 @@ class Naver
151
160
  end
152
161
  end
153
162
  end
154
-
155
-
156
- def login(proxy)
157
- chrome_start(proxy)
158
-
159
- @driver.get('about:blank')
160
- sleep(2)
161
163
 
162
- # 열린 모든 핸들 확인
163
- all_windows = @driver.window_handles
164
- puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
165
-
166
- # 탭만 남기고 나머지 탭 닫기
167
- all_windows.each do |window|
168
- @driver.switch_to.window(window)
169
- current_url = @driver.current_url
170
- puts "탭 URL: #{current_url}" # 각 탭 URL 출력
164
+ def login(proxy, captcha_key, board_cookie_dir = "C:/board_cookie")
165
+ @captcha_key = captcha_key
166
+ @board_cookie_dir = "C:/board_cookie"
167
+ current_dir = File.dirname(__FILE__)
168
+ board_cookie_dir = "C:/board_cookie"
169
+ FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
171
170
 
172
- # 'chrome-extension://'로 시작하는 확장 프로그램 탭을 제외하고 닫기
173
- if current_url.start_with?('chrome-extension://')
174
- puts "확장 프로그램 탭을 닫지 않음: #{current_url}"
175
- else
176
- @driver.close # 빈 탭 등 다른 탭은 닫기
177
- puts "빈 탭 또는 확장 프로그램이 아닌 탭을 닫았습니다."
171
+ unless File.exist?(board_cookie_dir)
172
+ driverfile_src = File.join(current_dir, 'driverfile')
173
+ if Dir.exist?(driverfile_src)
174
+ FileUtils.cp_r(driverfile_src, board_cookie_dir)
178
175
  end
179
176
  end
180
177
 
181
- # 탭을 남긴 후, 빈 탭으로 다시 전환
182
- all_windows = @driver.window_handles # 남은 리스트 갱신
183
- if all_windows.size == 1
184
- @driver.switch_to.window(all_windows.first) # 남은 빈 탭으로 전환
185
- puts "빈 탭으로 전환됨."
186
- else
187
- puts "빈 탭을 찾을 수 없습니다."
188
- end
178
+ # 새로운 스레드 생성 실행
179
+ Thread.new { chrome_setup(proxy, board_cookie_dir) }
189
180
 
181
+ # 충분한 대기 시간을 두고 실행
190
182
  sleep(1)
191
183
 
192
- # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
193
- @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
194
- sleep(1)
195
- end
196
-
197
-
198
-
199
-
200
-
201
- def update(user_id, user_pw, title, content, option, post_url, signup_url, login_url, cc_check_url, image_url_cheng, img_link2, category, more_txt1, more_txt2, more_txt3, more_txt4, captcha_key, keyword)
202
- puts 'start...'.yellow
203
- @user_id = user_id
204
- @user_pw = user_pw
205
- @signup_url = signup_url
206
- @login_url = login_url
207
- @cc_check_url = cc_check_url
208
- @post_url = post_url
209
- @image_url_cheng = image_url_cheng
210
- @img_link2 = img_link2
211
- @category = category
212
- @more_txt1 = more_txt1
213
- @more_txt2 = more_txt2
214
- @more_txt3 = more_txt3
215
- @more_txt4 = more_txt4
216
- @captcha_key = captcha_key
217
- sleep(1)
218
-
219
-
220
- ####################탭나누기 수정중######################################
221
- begin
222
- puts '-[√] 투 캡챠 api 입력 시도 1.......'.green
223
-
224
- #@driver.switch_to.window(@driver.window_handles[0])
184
+ chrome_start(proxy, board_cookie_dir)
225
185
 
186
+ # 열린 모든 탭 핸들 확인
187
+ all_windows = @driver.window_handles
188
+ #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
226
189
 
227
- # 요소 찾기 타임아웃을 10초로 설정
228
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
229
- #요소가 나타날 때까지 60초 동안 기다립니다.
230
- wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
231
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
232
- sleep(1)
233
- Clipboard.copy(captcha_key)
234
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
235
- sleep(1)
236
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
237
- sleep(1)
238
-
239
- begin
240
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
241
- wait.until do
242
- begin
243
- alert = @driver.switch_to.alert
244
- alert.accept
245
- true
246
- rescue Selenium::WebDriver::Error::NoSuchAlertError
247
- false
248
- end
249
- end
250
- rescue Selenium::WebDriver::Error::TimeoutError
251
- puts "alert이 없으므로 버튼 클릭"
252
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
253
- begin
254
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
255
- wait.until do
256
- begin
257
- alert = @driver.switch_to.alert
258
- alert.accept
259
- true
260
- rescue Selenium::WebDriver::Error::NoSuchAlertError
261
- false
262
- end
190
+ # 원하는 URL
191
+ target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
192
+
193
+ # 탭을 순회하면서
194
+ all_windows.each do |window|
195
+ @driver.switch_to.window(window)
196
+ current_url = @driver.current_url
197
+ #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
198
+
199
+ # 원하는 URL이 아니면 탭을 닫기
200
+ if current_url != target_url
201
+ begin
202
+ @driver.close # 다른 탭을 닫기
203
+ rescue Selenium::WebDriver::Error::WebDriverError => e
204
+ #puts "탭을 닫는 데 오류 발생: #{e.message}"
263
205
  end
264
- puts "두 번째 alert 처리 완료"
265
- rescue Selenium::WebDriver::Error::TimeoutError
266
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
267
- system('taskkill /F /IM chrome.exe')
268
- @driver.quit if @driver
269
- end
270
- end
271
-
206
+ end
207
+ end
272
208
 
273
- rescue
274
- begin
275
- puts '-[√] 캡챠 api 입력 시도 2.......'.green
276
- sleep(1)
277
- #@driver.switch_to.window(@driver.window_handles[0])
209
+ # 남아 있는 탭으로 전환
210
+ all_windows = @driver.window_handles # 남은 탭 리스트 갱신
211
+ if all_windows.size > 0
212
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
213
+ else
214
+ #puts "남은 탭이 없습니다."
215
+ end
278
216
 
279
217
 
280
- # 요소 찾기 타임아웃을 10초로 설정
281
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
282
- #요소가 나타날 때까지 60초 동안 기다립니다.
283
- wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
284
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
218
+
219
+ @driver.manage.window.maximize
285
220
  sleep(1)
286
221
  begin
287
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
222
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
223
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
224
+ check_cookie_login = 1
225
+ puts'[Step.01] CAPTCHA 세션 및 브라우저 설정 완료 상태 확인!!.......'.yellow
288
226
  rescue
289
-
290
- puts '-[√] 로딩 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
291
- puts '-[] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
292
-
293
- end
294
-
295
- Clipboard.copy(captcha_key)
296
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
297
- sleep(1)
298
- begin
299
- @driver.find_element(:class_name, 'default-btn').click
300
- sleep(1)
301
-
302
- begin
303
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
304
- wait.until do
305
- begin
306
- alert = @driver.switch_to.alert
307
- alert.accept
308
- true
309
- rescue Selenium::WebDriver::Error::NoSuchAlertError
310
- false
311
- end
227
+ begin
228
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
229
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
230
+ sleep(1.5)
231
+ @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
232
+ puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.yellow
233
+ puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.yellow
234
+ sleep(1.5)
235
+ mouse_move_percentage(0.3,0.02)
236
+ sleep(0.5)
237
+ left_click
238
+ sleep(1)
239
+ key_stroke('tab')
240
+ sleep(0.5)
241
+ key_stroke('enter')
242
+ check_cookie_login = 0
243
+ sleep(1)
244
+ rescue
245
+ @driver.quit
246
+ return 0
312
247
  end
313
- rescue Selenium::WebDriver::Error::TimeoutError
314
- puts "alert이 없으므로 버튼 클릭"
315
- @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[3]/button').click
248
+ end
249
+
250
+ if check_cookie_login == 0
251
+ sleep(10)
316
252
  begin
317
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
318
- wait.until do
319
- begin
320
- alert = @driver.switch_to.alert
321
- alert.accept
322
- true
323
- rescue Selenium::WebDriver::Error::NoSuchAlertError
324
- false
253
+
254
+ begin
255
+ # 열린 모든 탭 핸들 확인
256
+ all_windows = @driver.window_handles
257
+ puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
258
+
259
+ # 각 탭을 순회하면서
260
+ all_windows.each do |window|
261
+ @driver.switch_to.window(window)
262
+ current_url = @driver.current_url
263
+ puts "탭 URL: #{current_url}" # 각 탭 URL 출력
264
+
265
+ # 확장 프로그램 탭인지 확인
266
+ if current_url.include?('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
267
+ begin
268
+ @driver.close # 확장 프로그램 탭을 닫기
269
+
270
+ rescue Selenium::WebDriver::Error::WebDriverError => e
271
+ end
272
+ else
273
+ end
274
+ end
275
+
276
+ # 남아 있는 탭으로 전환
277
+ all_windows = @driver.window_handles # 남은 탭 리스트 갱신
278
+ if all_windows.size > 0
279
+ @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
280
+ else
281
+ end
282
+
283
+ sleep(1)
284
+
285
+ rescue => e
286
+ @driver.quit if @driver
325
287
  end
288
+
289
+
290
+
291
+
292
+
293
+ # 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
294
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
295
+ sleep(1)
296
+
297
+
298
+
299
+
300
+
301
+ begin
302
+ puts '-[√] 캡챠 연결 설정 1차 시도.......'.green
303
+ # 요소 찾기 타임아웃을 10초로 설정
304
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
305
+ #요소가 나타날 때까지 60초 동안 기다립니다.
306
+ wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
307
+ @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
308
+ sleep(1)
309
+ Clipboard.copy(captcha_key)
310
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
311
+ sleep(1)
312
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
313
+ sleep(1)
314
+
315
+ begin
316
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
317
+ wait.until do
318
+ begin
319
+ alert = @driver.switch_to.alert
320
+ alert.accept
321
+ sleep(1)
322
+ true
323
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
324
+ false
325
+ end
326
+ end
327
+ rescue Selenium::WebDriver::Error::TimeoutError
328
+ puts "alert이 없으므로 버튼 클릭"
329
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
330
+ begin
331
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
332
+ wait.until do
333
+ begin
334
+ alert = @driver.switch_to.alert
335
+ alert.accept
336
+ sleep(1)
337
+ true
338
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
339
+ false
340
+ end
341
+ end
342
+ puts "두 번째 alert 처리 완료"
343
+ rescue Selenium::WebDriver::Error::TimeoutError
344
+ puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
345
+ system('taskkill /F /IM chrome.exe')
346
+ @driver.quit if @driver
347
+ end
348
+ end
349
+ puts '-[√] 브라우저 필요 설정 1차 시도.......'.green
350
+ @driver.get('chrome://settings/security')
351
+ sleep(2)
352
+ mouse_move_percentage(0.3,0.02)
353
+ sleep(0.5)
354
+ left_click
355
+ sleep(1)
356
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
357
+ 6.times do
358
+ key_stroke('tab') # 'tab' 키를 입력
359
+ sleep(0.5) # 0.5초 대기
360
+ end
361
+ key_stroke('enter')
362
+ sleep(1)
363
+
364
+ @driver.get('chrome://password-manager/settings')
365
+ sleep(2)
366
+ mouse_move_percentage(0.3,0.02)
367
+ sleep(0.5)
368
+ left_click
369
+ sleep(1)
370
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
371
+ 3.times do
372
+ key_stroke('tab') # 'tab' 키를 입력
373
+ sleep(0.5) # 0.5초 대기
374
+ end
375
+ key_stroke('enter')
376
+ sleep(1)
377
+
378
+ rescue
379
+ begin
380
+ puts '-[√] 캡챠 연결 설정 2차 시도.......'.green
381
+ sleep(1)
382
+ #@driver.switch_to.window(@driver.window_handles[0])
383
+
384
+
385
+ # 요소 찾기 타임아웃을 10초로 설정
386
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
387
+ #요소가 나타날 때까지 60초 동안 기다립니다.
388
+ wait.until { @driver.find_element(:xpath, '//*[@name="apiKey"]') }
389
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
390
+ sleep(1)
391
+ begin
392
+ @driver.find_element(:xpath, '//*[@name="apiKey"]').click
393
+ rescue
394
+
395
+ puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
396
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
397
+
398
+ end
399
+
400
+ Clipboard.copy(captcha_key)
401
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
402
+ sleep(1)
403
+ begin
404
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
405
+ sleep(1)
406
+
407
+ begin
408
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
409
+ wait.until do
410
+ begin
411
+ alert = @driver.switch_to.alert
412
+ alert.accept
413
+ sleep(1)
414
+ true
415
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
416
+ false
417
+ end
418
+ end
419
+ rescue Selenium::WebDriver::Error::TimeoutError
420
+ puts "alert이 없으므로 버튼 클릭"
421
+ @driver.find_element(:xpath, '//*[@class="default-btn"]').click
422
+ begin
423
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
424
+ wait.until do
425
+ begin
426
+ alert = @driver.switch_to.alert
427
+ alert.accept
428
+ sleep(1)
429
+ true
430
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
431
+ false
432
+ end
433
+ end
434
+ puts "두 번째 alert 처리 완료"
435
+ rescue Selenium::WebDriver::Error::TimeoutError
436
+ puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
437
+ system('taskkill /F /IM chrome.exe')
438
+ @driver.quit if @driver
439
+ end
440
+ end
441
+
442
+ rescue => e
443
+ @driver.window_handles.each do |handle|
444
+ @driver.switch_to.window(handle)
445
+ begin
446
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
447
+ @driver.close
448
+ rescue Selenium::WebDriver::Error::WebDriverError => e
449
+ puts "크롬 브라우저 종료: #{e.message}"
450
+ end
451
+ end
452
+ return 0
453
+ @driver.quit
454
+ end
455
+ puts '-[√] 브라우저 필요 설정 2차 시도.......'.green
456
+ @driver.get('chrome://settings/security')
457
+ sleep(2)
458
+ mouse_move_percentage(0.3,0.02)
459
+ sleep(0.5)
460
+ left_click
461
+ sleep(1)
462
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
463
+ 6.times do
464
+ key_stroke('tab') # 'tab' 키를 입력
465
+ sleep(0.5) # 0.5초 대기
466
+ end
467
+ key_stroke('enter')
468
+ sleep(1)
469
+
470
+ @driver.get('chrome://password-manager/settings')
471
+ sleep(2)
472
+ mouse_move_percentage(0.3,0.02)
473
+ sleep(0.5)
474
+ left_click
475
+ sleep(1)
476
+ # 루비에서 'tab' 키를 0.5초마다 7번 누르기
477
+ 3.times do
478
+ key_stroke('tab') # 'tab' 키를 입력
479
+ sleep(0.5) # 0.5초 대기
480
+ end
481
+ key_stroke('enter')
482
+ sleep(1)
483
+
484
+ rescue => e
485
+ puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
486
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
487
+ @driver.window_handles.each do |handle|
488
+ @driver.switch_to.window(handle)
489
+ begin
490
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
491
+ @driver.close
492
+ rescue Selenium::WebDriver::Error::WebDriverError => e
493
+ puts "크롬 브라우저 종료: #{e.message}"
494
+ end
495
+ end
496
+ return 0
497
+ @driver.quit
498
+ end
499
+
326
500
  end
327
- puts "두 번째 alert 처리 완료"
328
- rescue Selenium::WebDriver::Error::TimeoutError
329
- puts "두 번째 alert이 10초 내에 나타나지 않음. Chrome 종료."
330
- system('taskkill /F /IM chrome.exe')
331
- @driver.quit if @driver
332
- end
501
+
502
+ rescue => e
503
+ puts '-[√] 로딩 지연 접속 실패.......'.red
504
+ @driver.window_handles.each do |handle|
505
+ @driver.switch_to.window(handle)
506
+ begin
507
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
508
+ @driver.close
509
+ rescue Selenium::WebDriver::Error::WebDriverError => e
510
+ puts "Failed to close tab: #{e.message}"
511
+ end
512
+ end
513
+ @driver.quit
514
+ return 0
515
+ end
516
+
517
+ else
518
+ # @driver.switch_to.default_content
333
519
  end
334
-
520
+
521
+ begin
522
+
523
+
524
+
525
+ @driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
526
+
527
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
528
+ #요소가 나타날 때까지 3초 동안 기다립니다.
529
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
530
+
531
+
532
+
335
533
  rescue => e
534
+ puts '-[√] 로그인 실패.......'.red
336
535
  @driver.window_handles.each do |handle|
337
536
  @driver.switch_to.window(handle)
338
537
  begin
339
538
  # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
340
539
  @driver.close
341
540
  rescue Selenium::WebDriver::Error::WebDriverError => e
342
- puts "크롬 브라우저 종료: #{e.message}"
541
+ puts "Failed to close tab: #{e.message}"
343
542
  end
344
543
  end
345
- return 0
346
- @driver.quit
347
- end
544
+ @driver.quit
545
+ return 0
546
+ end
547
+ end
548
+
348
549
 
349
- rescue => e
350
- puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
351
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
352
- @driver.window_handles.each do |handle|
353
- @driver.switch_to.window(handle)
354
- begin
355
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
356
- @driver.close
357
- rescue Selenium::WebDriver::Error::WebDriverError => e
358
- puts "크롬 브라우저 종료: #{e.message}"
359
- end
360
- end
361
- return 0
362
- @driver.quit
363
- end
364
-
365
- end
366
- #@driver.switch_to.window(@driver.window_handles[0])
367
- ####################탭나누기 수정중######################################
368
- sleep(2)
369
550
 
370
551
 
371
552
 
372
- ##################
553
+ def update(user_id, user_pw, title, content, option, post_url, signup_url, login_url, cc_check_url, image_url_cheng, img_link2, category, more_txt1, more_txt2, more_txt3, more_txt4, captcha_key, keyword)
554
+ puts 'start...'.yellow
555
+ @user_id = user_id
556
+ @user_pw = user_pw
557
+ @signup_url = signup_url
558
+ @login_url = login_url
559
+ @cc_check_url = cc_check_url
560
+ @post_url = post_url
561
+ @image_url_cheng = image_url_cheng
562
+ @img_link2 = img_link2
563
+ @category = category
564
+ @more_txt1 = more_txt1
565
+ @more_txt2 = more_txt2
566
+ @more_txt3 = more_txt3
567
+ @more_txt4 = more_txt4
568
+ @captcha_key = captcha_key
569
+ sleep(1)
570
+
571
+
572
+ ####################탭나누기 수정중######################################
573
+
574
+
575
+
373
576
  signup_url = option['signup_url'].to_s
374
577
 
375
578
 
@@ -379,52 +582,72 @@ sleep(2)
379
582
  if signup_url == '' or signup_url == '회원가입 페이지 url'
380
583
 
381
584
  else
382
-
383
- begin
384
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
385
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
386
- @driver.get(signup_url)
387
- sleep(1)
388
- puts '-[√] 회원가입 페이지 URL 이동.......'.magenta
389
-
390
- # Alert 처리 부분
391
- begin
392
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
393
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
394
- alert.accept # 알림을 확인
395
- rescue
396
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
397
- end
398
-
585
+ @driver.get(signup_url)
586
+ puts '-[√] 회원가입 페이지 URL 이동.......'.magenta
587
+
399
588
 
400
- rescue Selenium::WebDriver::Error::UnknownError => e
401
- puts "#{signup_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
402
- # 열린 모든 창을 닫음
403
- @driver.window_handles.each do |handle|
404
- @driver.switch_to.window(handle)
405
- begin
406
- @driver.close
407
- rescue Selenium::WebDriver::Error::WebDriverError => e
408
- puts "사이트 내부에 예외 발생: #{e.message}"
409
- end
410
- end
411
589
 
412
- # 드라이버 종료
413
- @driver.quit if @driver
414
- return 0
415
590
 
416
- rescue Selenium::WebDriver::Error::TimeoutError => e
417
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
418
- @driver.quit if @driver
419
- return 0
420
591
 
421
- rescue
422
- end
592
+ begin
593
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
594
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
595
+ if error_text
596
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
597
+ @driver.quit if @driver
598
+ return 0
599
+ end
600
+ rescue
601
+ end
602
+
603
+ begin
604
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
605
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
606
+ if error_text
607
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
608
+ @driver.quit if @driver
609
+ return 0
610
+ end
611
+ rescue
612
+ end
613
+
614
+ begin
615
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
616
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
617
+ alert.accept # 알림을 확인
618
+ rescue
619
+ end
620
+
621
+
622
+ sleep(1)
623
+
624
+
423
625
 
424
626
 
425
627
 
426
628
 
427
629
 
630
+ #오른쪽 마우스 해제 코드
631
+ begin
632
+ @driver.execute_script <<-JS
633
+ document.querySelectorAll('body').forEach(function(element) {
634
+ element.oncontextmenu = null;
635
+ });
636
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
637
+ JS
638
+
639
+ @driver.execute_script <<-JS
640
+ document.addEventListener('contextmenu', function(e) {
641
+ e.stopImmediatePropagation();
642
+ }, true);
643
+ JS
644
+
645
+ @driver.execute_script("window.oncontextmenu = null;")
646
+ rescue
647
+ end
648
+
649
+
650
+
428
651
  sleep(1)
429
652
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
430
653
 
@@ -435,6 +658,8 @@ sleep(2)
435
658
  puts '-[√] 3 캡챠 발생 유무 확인.......'.green
436
659
  sleep(2)
437
660
 
661
+
662
+
438
663
  begin
439
664
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
440
665
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -610,9 +835,22 @@ sleep(2)
610
835
  begin
611
836
  sleep(1)
612
837
  @driver.switch_to.alert.accept
838
+ sleep(1)
613
839
  rescue
614
840
  end
615
841
 
842
+ begin
843
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
844
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
845
+ if error_text
846
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
847
+ @driver.quit if @driver
848
+ return 0
849
+ end
850
+ rescue Selenium::WebDriver::Error::NoSuchElementError
851
+ # 해당 텍스트가 없으면 아무 작업 안함
852
+ end
853
+
616
854
 
617
855
  ##체크박스1-1 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
618
856
  puts '-[√] 회원가입 체크박스 1차 탐색.......'.yellow
@@ -1468,15 +1706,28 @@ sleep(2)
1468
1706
 
1469
1707
 
1470
1708
 
1471
-
1472
-
1473
-
1474
-
1475
1709
 
1476
1710
 
1477
1711
  sleep(1)
1478
1712
  ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
1479
-
1713
+ #오른쪽 마우스 해제 코드
1714
+ begin
1715
+ @driver.execute_script <<-JS
1716
+ document.querySelectorAll('body').forEach(function(element) {
1717
+ element.oncontextmenu = null;
1718
+ });
1719
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
1720
+ JS
1721
+
1722
+ @driver.execute_script <<-JS
1723
+ document.addEventListener('contextmenu', function(e) {
1724
+ e.stopImmediatePropagation();
1725
+ }, true);
1726
+ JS
1727
+
1728
+ @driver.execute_script("window.oncontextmenu = null;")
1729
+ rescue
1730
+ end
1480
1731
  sleep(1)
1481
1732
  ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
1482
1733
  puts '-[√] 캡챠 유형 탐색.......'.green
@@ -1575,12 +1826,7 @@ rescue
1575
1826
  rescue
1576
1827
  begin
1577
1828
  @driver.switch_to.default_content()
1578
- @driver.find_elements(:tag_name, 'img').each do |img|
1579
- if img.attribute('src').include?('kboard_captcha')
1580
- el = img # 캡챠 이미지를 el에 저장
1581
- break # 첫 번째 이미지를 찾으면 루프 종료
1582
- end
1583
- end
1829
+ el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
1584
1830
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
1585
1831
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
1586
1832
  puts '-[√] 챕챠 코드 code 5-1.......'.red
@@ -1597,11 +1843,13 @@ rescue
1597
1843
  @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
1598
1844
  sleep(1)
1599
1845
  puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
1846
+
1847
+
1600
1848
  rescue
1601
1849
  begin
1602
1850
  @driver.switch_to.default_content()
1603
1851
  #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
1604
- el = @driver.find_element(:css, 'label[for="kboard-input-captcha"] img')
1852
+ el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
1605
1853
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
1606
1854
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
1607
1855
  puts '-[√] 챕챠 코드 code 5-2.......'.red
@@ -2444,6 +2692,7 @@ end
2444
2692
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
2445
2693
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2446
2694
  alert.accept # 알림을 확인
2695
+ sleep(1)
2447
2696
  rescue
2448
2697
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
2449
2698
  end
@@ -2465,58 +2714,69 @@ login_url = option['login_url'].to_s
2465
2714
  if login_url == '' or login_url == '로그인 페이지 url'
2466
2715
 
2467
2716
  else
2468
-
2717
+ @driver.get(login_url)
2718
+ puts '-[√] 로그인 페이지 URL 이동.......'.magenta
2719
+
2720
+
2721
+
2722
+
2723
+
2469
2724
  begin
2470
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
2471
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
2472
- @driver.get(login_url)
2473
- sleep(1)
2474
- puts '-[√] 로그인 페이지 URL 이동.......'.magenta
2475
- # Alert 처리 부분
2476
- begin
2477
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
2478
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2479
- alert.accept # 알림을 확인
2480
- rescue
2481
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
2482
- end
2483
-
2484
- rescue Selenium::WebDriver::Error::UnknownError => e
2485
- puts "#{login_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
2486
- # 열린 모든 창을 닫음
2487
- @driver.window_handles.each do |handle|
2488
- @driver.switch_to.window(handle)
2489
- begin
2490
- @driver.close
2491
- rescue Selenium::WebDriver::Error::WebDriverError => e
2492
- puts "사이트 내부에 예외 발생: #{e.message}"
2493
- end
2494
- end
2495
-
2496
- # 드라이버 종료
2725
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
2726
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
2727
+ if error_text
2728
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
2497
2729
  @driver.quit if @driver
2498
- return 0
2499
-
2500
- rescue Selenium::WebDriver::Error::TimeoutError => e
2501
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
2730
+ return 0
2731
+ end
2732
+ rescue
2733
+ end
2734
+
2735
+ begin
2736
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
2737
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
2738
+ if error_text
2739
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
2502
2740
  @driver.quit if @driver
2503
2741
  return 0
2504
-
2505
- rescue
2506
2742
  end
2507
-
2508
-
2509
-
2510
- sleep(1)
2743
+ rescue
2744
+ end
2745
+
2746
+ begin
2747
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
2748
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
2749
+ alert.accept # 알림을 확인
2750
+ rescue
2751
+ end
2752
+
2753
+
2754
+
2755
+ sleep(1)
2756
+
2511
2757
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
2758
+ #오른쪽 마우스 해제 코드
2759
+ begin
2760
+ @driver.execute_script <<-JS
2761
+ document.querySelectorAll('body').forEach(function(element) {
2762
+ element.oncontextmenu = null;
2763
+ });
2764
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
2765
+ JS
2512
2766
 
2513
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
2514
- sleep(1)
2515
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
2516
- sleep(1)
2517
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
2518
- sleep(1)
2519
-
2767
+ @driver.execute_script <<-JS
2768
+ document.addEventListener('contextmenu', function(e) {
2769
+ e.stopImmediatePropagation();
2770
+ }, true);
2771
+ JS
2772
+
2773
+ @driver.execute_script("window.oncontextmenu = null;")
2774
+ rescue
2775
+ end
2776
+
2777
+ sleep(5)
2778
+
2779
+
2520
2780
  begin
2521
2781
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
2522
2782
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -2612,7 +2872,7 @@ login_url = option['login_url'].to_s
2612
2872
  rescue
2613
2873
  begin
2614
2874
  # 타임아웃을 3초로 설정
2615
- wait = Selenium::WebDriver::Wait.new(:timeout => 5)
2875
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2)
2616
2876
  # 요소가 나타날 때까지 30초 동안 기다립니다.
2617
2877
  wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
2618
2878
  sleep(1)
@@ -2700,7 +2960,7 @@ login_url = option['login_url'].to_s
2700
2960
 
2701
2961
 
2702
2962
  begin
2703
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2963
+
2704
2964
  chat_box = @driver.find_element(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')
2705
2965
  @driver.execute_script("arguments[0].remove();", chat_box)
2706
2966
  puts '-[√] 숨김 code 1 제거 완료.......'.green
@@ -2709,7 +2969,7 @@ login_url = option['login_url'].to_s
2709
2969
  end
2710
2970
 
2711
2971
  begin
2712
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2972
+
2713
2973
  chat_box = @driver.find_element(:xpath, '//*[@class="google-auto-placed"]')
2714
2974
  @driver.execute_script("arguments[0].remove();", chat_box)
2715
2975
  puts '-[√] 숨김 code 2 제거 완료.......'.green
@@ -2718,7 +2978,7 @@ login_url = option['login_url'].to_s
2718
2978
  end
2719
2979
 
2720
2980
  begin
2721
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2981
+
2722
2982
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[1]
2723
2983
  @driver.execute_script("arguments[0].remove();", chat_box)
2724
2984
  puts '-[√] 숨김 code 3 제거 완료.......'.green
@@ -2727,7 +2987,7 @@ login_url = option['login_url'].to_s
2727
2987
  end
2728
2988
 
2729
2989
  begin
2730
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2990
+
2731
2991
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[2]
2732
2992
  @driver.execute_script("arguments[0].remove();", chat_box)
2733
2993
  puts '-[√] 숨김 code 4 제거 완료.......'.green
@@ -2736,7 +2996,7 @@ login_url = option['login_url'].to_s
2736
2996
  end
2737
2997
 
2738
2998
  begin
2739
- puts '-[√] 숨김 code 탐색 중 (발견시 제거).......'.green
2999
+
2740
3000
  chat_box = @driver.find_elements(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')[3]
2741
3001
  @driver.execute_script("arguments[0].remove();", chat_box)
2742
3002
  puts '-[√] 숨김 code 5 제거 완료.......'.green
@@ -2744,11 +3004,23 @@ login_url = option['login_url'].to_s
2744
3004
  rescue
2745
3005
  end
2746
3006
 
3007
+ begin
3008
+ # <ins> 태그를 찾고 삭제하기
3009
+ ins_elements = @driver.find_elements(tag_name: 'ins')
3010
+
3011
+ ins_elements.each do |element|
3012
+ # 요소 삭제
3013
+ @driver.execute_script("arguments[0].remove();", element)
3014
+ puts '-[√] 숨김 code 6 제거 완료.......'.green
3015
+ sleep(1)
3016
+ end
3017
+ rescue
3018
+ end
2747
3019
 
2748
3020
 
2749
3021
 
2750
3022
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2751
- puts '-[√] 팝업 여부 확인 체크 01.......'.yellow
3023
+
2752
3024
 
2753
3025
  begin
2754
3026
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -2830,7 +3102,7 @@ login_url = option['login_url'].to_s
2830
3102
  @driver.find_element(:xpath, '//*[@id="hd_pops_1"]/div[2]/button[1]').click
2831
3103
  sleep(1)
2832
3104
  rescue
2833
- puts '.......'.yellow
3105
+
2834
3106
 
2835
3107
  end
2836
3108
 
@@ -2860,7 +3132,7 @@ login_url = option['login_url'].to_s
2860
3132
 
2861
3133
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
2862
3134
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2863
- puts '-[√] 팝업 여부 확인 체크 02.......'.yellow
3135
+
2864
3136
 
2865
3137
  begin
2866
3138
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -2942,7 +3214,7 @@ login_url = option['login_url'].to_s
2942
3214
  @driver.find_element(:xpath, '//*[@id="hd_pops_2"]/div[2]/button[1]').click
2943
3215
  sleep(1)
2944
3216
  rescue
2945
- puts '.......'.yellow
3217
+
2946
3218
 
2947
3219
  end
2948
3220
 
@@ -2972,7 +3244,7 @@ login_url = option['login_url'].to_s
2972
3244
  end
2973
3245
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
2974
3246
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
2975
- puts '-[√] 팝업 여부 확인 체크 03.......'.yellow
3247
+
2976
3248
 
2977
3249
  begin
2978
3250
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3054,7 +3326,7 @@ login_url = option['login_url'].to_s
3054
3326
  @driver.find_element(:xpath, '//*[@id="hd_pops_3"]/div[2]/button[1]').click
3055
3327
  sleep(1)
3056
3328
  rescue
3057
- puts '.......'.yellow
3329
+
3058
3330
 
3059
3331
  end
3060
3332
 
@@ -3084,7 +3356,7 @@ login_url = option['login_url'].to_s
3084
3356
  end
3085
3357
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3086
3358
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
3087
- puts '-[√] 팝업 여부 확인 체크 04.......'.yellow
3359
+
3088
3360
 
3089
3361
  begin
3090
3362
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3166,7 +3438,7 @@ login_url = option['login_url'].to_s
3166
3438
  @driver.find_element(:xpath, '//*[@id="hd_pops_4"]/div[2]/button[1]').click
3167
3439
  sleep(1)
3168
3440
  rescue
3169
- puts '.......'.yellow
3441
+
3170
3442
 
3171
3443
  end
3172
3444
 
@@ -3196,7 +3468,7 @@ login_url = option['login_url'].to_s
3196
3468
  end
3197
3469
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3198
3470
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
3199
- puts '-[√] 팝업 여부 확인 체크 05.......'.yellow
3471
+
3200
3472
 
3201
3473
  begin
3202
3474
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
@@ -3278,7 +3550,7 @@ login_url = option['login_url'].to_s
3278
3550
  @driver.find_element(:xpath, '//*[@id="hd_pops_5"]/div[2]/button[1]').click
3279
3551
  sleep(1)
3280
3552
  rescue
3281
- puts '.......'.yellow
3553
+
3282
3554
 
3283
3555
  end
3284
3556
 
@@ -3308,10 +3580,20 @@ login_url = option['login_url'].to_s
3308
3580
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
3309
3581
 
3310
3582
 
3311
-
3583
+ begin
3584
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3585
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
3586
+ if error_text
3587
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
3588
+ @driver.quit if @driver
3589
+ return 0
3590
+ end
3591
+ rescue Selenium::WebDriver::Error::NoSuchElementError
3592
+ # 해당 텍스트가 없으면 아무 작업 안함
3593
+ end
3312
3594
 
3313
3595
  ##아이디 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3314
- puts '-[√] 로그인 ID/PW 입력 필드 탐색.......'.cyan
3596
+
3315
3597
  sleep(1)
3316
3598
  begin
3317
3599
  @driver.find_element(:xpath, '//*[@name="mb_id"]').send_keys(user_id)
@@ -3408,20 +3690,7 @@ login_url = option['login_url'].to_s
3408
3690
  begin
3409
3691
  @driver.find_element(:xpath, '//*[@class="username"]').send_keys(user_id)
3410
3692
  sleep(3)
3411
- rescue => e
3412
- puts '-[√] 로그인 페이지 접속 시도 실패 (페이지 로딩 지연 및 접속 불량).......'.red
3413
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
3414
- @driver.window_handles.each do |handle|
3415
- @driver.switch_to.window(handle)
3416
- begin
3417
- # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
3418
- @driver.close
3419
- rescue Selenium::WebDriver::Error::WebDriverError => e
3420
- puts "크롬 브라우저 종료: #{e.message}"
3421
- end
3422
- end
3423
- return 0
3424
- @driver.quit
3693
+ rescue
3425
3694
  end
3426
3695
 
3427
3696
  end
@@ -3542,7 +3811,7 @@ login_url = option['login_url'].to_s
3542
3811
  end
3543
3812
  end
3544
3813
  end
3545
- puts '-[√] 로그인 ID/PW 입력 필드 종료.......'.cyan
3814
+
3546
3815
  sleep(1)
3547
3816
  end
3548
3817
  ##패스워드 입력 코드 부분─────────────────────────────────────────────────────────────────────<
@@ -3581,47 +3850,53 @@ login_url = option['login_url'].to_s
3581
3850
  sleep(3)
3582
3851
  rescue
3583
3852
  begin
3584
- @driver.find_element(:xpath, '//*[@alt="로그인"]').click
3853
+ @driver.find_element(:xpath, '//*[@class="btn btn-color pull-right"]').click
3585
3854
  puts '-[√] 로그인 버튼 코드 7 타겟.......'.cyan
3586
3855
  sleep(3)
3587
3856
  rescue
3588
3857
  begin
3589
- @driver.find_element(:xpath, '//*[@id="mb_login"]/form/div[5]/button').click
3858
+ @driver.find_element(:xpath, '//*[@alt="로그인"]').click
3590
3859
  puts '-[√] 로그인 버튼 코드 8 타겟.......'.cyan
3591
3860
  sleep(3)
3592
3861
  rescue
3593
3862
  begin
3594
- @driver.find_element(:xpath, '//*[@id="ol_submit"]').click
3863
+ @driver.find_element(:xpath, '//*[@id="mb_login"]/form/div[5]/button').click
3595
3864
  puts '-[√] 로그인 버튼 코드 9 타겟.......'.cyan
3596
3865
  sleep(3)
3597
3866
  rescue
3598
3867
  begin
3599
- @driver.find_element(:xpath, '//*[@alt="login"]').click
3868
+ @driver.find_element(:xpath, '//*[@id="ol_submit"]').click
3600
3869
  puts '-[√] 로그인 버튼 코드 10 타겟.......'.cyan
3601
3870
  sleep(3)
3602
3871
  rescue
3603
3872
  begin
3604
- @driver.find_element(:xpath, '//*[@title="login"]').click
3873
+ @driver.find_element(:xpath, '//*[@alt="login"]').click
3605
3874
  puts '-[√] 로그인 버튼 코드 11 타겟.......'.cyan
3606
3875
  sleep(3)
3607
3876
  rescue
3608
3877
  begin
3609
- @driver.find_element(:xpath, '//*[@id="signIn_1"]').click
3878
+ @driver.find_element(:xpath, '//*[@title="login"]').click
3610
3879
  puts '-[√] 로그인 버튼 코드 12 타겟.......'.cyan
3611
3880
  sleep(3)
3612
3881
  rescue
3613
3882
  begin
3614
- @driver.find_element(:xpath, '//*[@id="btn_login"]').click
3883
+ @driver.find_element(:xpath, '//*[@id="signIn_1"]').click
3615
3884
  puts '-[√] 로그인 버튼 코드 13 타겟.......'.cyan
3616
3885
  sleep(3)
3617
3886
  rescue
3618
3887
  begin
3619
- @driver.find_element(:xpath, '//*[@name="wp-submit"]').click
3888
+ @driver.find_element(:xpath, '//*[@id="btn_login"]').click
3620
3889
  puts '-[√] 로그인 버튼 코드 14 타겟.......'.cyan
3621
3890
  sleep(3)
3622
3891
  rescue
3623
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
3624
- sleep(3)
3892
+ begin
3893
+ @driver.find_element(:xpath, '//*[@name="wp-submit"]').click
3894
+ puts '-[√] 로그인 버튼 코드 15 타겟.......'.cyan
3895
+ sleep(3)
3896
+ rescue
3897
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
3898
+ sleep(3)
3899
+ end
3625
3900
  end
3626
3901
  end
3627
3902
  end
@@ -3638,11 +3913,14 @@ login_url = option['login_url'].to_s
3638
3913
  end
3639
3914
  ##로그인 버튼 코드 부분─────────────────────────────────────────────────────────────────────<
3640
3915
 
3916
+
3917
+
3641
3918
  # Alert 처리 부분
3642
3919
  begin
3643
3920
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3644
3921
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3645
3922
  alert.accept # 알림을 확인
3923
+ sleep(1)
3646
3924
  rescue
3647
3925
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
3648
3926
  end
@@ -3653,7 +3931,7 @@ login_url = option['login_url'].to_s
3653
3931
 
3654
3932
 
3655
3933
  rescue => e
3656
- puts '-[√] 로그인 PASS.......'.cyan
3934
+ #puts '-[√] 로그인 PASS.......'.cyan
3657
3935
  puts e
3658
3936
  end
3659
3937
 
@@ -3671,57 +3949,68 @@ begin
3671
3949
 
3672
3950
  else
3673
3951
 
3952
+ @driver.get(cc_check_url)
3953
+ puts '-[√] 출석 체크 페이지 URL 이동.......'.magenta
3954
+
3955
+
3956
+
3957
+
3958
+
3674
3959
  begin
3675
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3676
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
3677
- @driver.get(cc_check_url)
3678
- sleep(1)
3679
- puts '-[√] 출석체크 페이지 URL 이동.......'.magenta
3680
- # Alert 처리 부분
3681
- begin
3682
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3683
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3684
- alert.accept # 알림을 확인
3685
- rescue
3686
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
3687
- end
3688
-
3689
- rescue Selenium::WebDriver::Error::UnknownError => e
3690
- puts "#{cc_check_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
3691
- # 열린 모든 창을 닫음
3692
- @driver.window_handles.each do |handle|
3693
- @driver.switch_to.window(handle)
3694
- begin
3695
- @driver.close
3696
- rescue Selenium::WebDriver::Error::WebDriverError => e
3697
- puts "사이트 내부에 예외 발생: #{e.message}"
3698
- end
3699
- end
3700
-
3701
- # 드라이버 종료
3960
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3961
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
3962
+ if error_text
3963
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3702
3964
  @driver.quit if @driver
3703
- return 0
3704
-
3705
- rescue Selenium::WebDriver::Error::TimeoutError => e
3706
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
3965
+ return 0
3966
+ end
3967
+ rescue
3968
+ end
3969
+
3970
+ begin
3971
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
3972
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
3973
+ if error_text
3974
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3707
3975
  @driver.quit if @driver
3708
3976
  return 0
3709
-
3710
- rescue
3711
3977
  end
3978
+ rescue
3979
+ end
3712
3980
 
3713
-
3981
+ begin
3982
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
3983
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3984
+ alert.accept # 알림을 확인
3985
+ rescue
3986
+ end
3714
3987
 
3988
+
3715
3989
 
3716
3990
  sleep(1)
3991
+ #오른쪽 마우스 해제 코드
3992
+ begin
3993
+ @driver.execute_script <<-JS
3994
+ document.querySelectorAll('body').forEach(function(element) {
3995
+ element.oncontextmenu = null;
3996
+ });
3997
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
3998
+ JS
3999
+
4000
+ @driver.execute_script <<-JS
4001
+ document.addEventListener('contextmenu', function(e) {
4002
+ e.stopImmediatePropagation();
4003
+ }, true);
4004
+ JS
4005
+
4006
+ @driver.execute_script("window.oncontextmenu = null;")
4007
+ rescue
4008
+ end
3717
4009
  ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3718
4010
  begin
3719
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
3720
- sleep(1)
3721
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
3722
- sleep(1)
3723
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
3724
- sleep(1)
4011
+ sleep(5)
4012
+
4013
+
3725
4014
  # 타임아웃을 3초로 설정
3726
4015
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
3727
4016
  # 요소가 나타날 때까지 30초 동안 기다립니다.
@@ -3760,7 +4049,7 @@ begin
3760
4049
  end
3761
4050
  ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
3762
4051
 
3763
- begin
4052
+ begin
3764
4053
  # 요소 찾기 타임아웃을 10초로 설정
3765
4054
  wait = Selenium::WebDriver::Wait.new(:timeout => 20)
3766
4055
  #요소가 나타날 때까지 20초 동안 기다립니다.
@@ -3785,6 +4074,19 @@ begin
3785
4074
  end
3786
4075
  end
3787
4076
 
4077
+ begin
4078
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4079
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4080
+ if error_text
4081
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
4082
+ @driver.quit if @driver
4083
+ return 0
4084
+ end
4085
+ rescue Selenium::WebDriver::Error::NoSuchElementError
4086
+ # 해당 텍스트가 없으면 아무 작업 안함
4087
+ end
4088
+
4089
+
3788
4090
  ##출석 체크 입력 코드 부분─────────────────────────────────────────────────────────────────────>
3789
4091
  cctxt_value = ['ㅊㅊ','출석체크','출석 체크해요','출첵~','추추','출석~','출석 체크 하고 가요','출석 체크 합니다.','안녕하세요','출첵왔어요','출석체크합니다.','출석체크~','출석했어요','출첵!!','출석 체크~,','출석 도장 쾅~!','출석 도장 쾅쾅!!','출석 하고 가요','출첵^^*','출석 체크~!^^','^^','^*^','출첵*_*','추추^^*'].sample
3790
4092
  begin
@@ -3895,6 +4197,7 @@ begin
3895
4197
  wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3896
4198
  alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3897
4199
  alert.accept # 알림을 확인
4200
+ sleep(1)
3898
4201
  rescue
3899
4202
  # 알림이 나타나지 않으면 예외 처리하고 넘어감
3900
4203
  end
@@ -3911,71 +4214,67 @@ end
3911
4214
 
3912
4215
 
3913
4216
 
3914
- login_url = option['login_url'].to_s
4217
+ post_url = option['post_url'].to_s
3915
4218
 
3916
4219
  begin
3917
4220
  if post_url == '' or post_url == '게시판 글쓰기 url'
3918
4221
 
3919
4222
  else
3920
-
4223
+ @driver.get(post_url)
4224
+ puts '-[√] 게시판 페이지 URL 이동.......'.magenta
4225
+
4226
+
4227
+
4228
+
4229
+
3921
4230
  begin
3922
- wait = Selenium::WebDriver::Wait.new(:timeout => 30) # 최대 20초 대기
3923
- wait.until { @driver.execute_script("return document.readyState") == "complete" }
3924
- @driver.get(post_url)
3925
- sleep(1)
3926
- puts '-[√] 글쓰기 페이지 URL 이동.......'.magenta
3927
- # Alert 처리 부분
3928
- begin
3929
- wait = Selenium::WebDriver::Wait.new(:timeout => 3) # 3초 대기
3930
- alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
3931
- alert.accept # 알림을 확인
3932
- rescue
3933
- # 알림이 나타나지 않으면 예외 처리하고 넘어감
3934
- end
3935
-
3936
- rescue Selenium::WebDriver::Error::UnknownError => e
3937
- puts "#{post_url} 해당 사이트의 문제로 접속이 불가능합니다." # 오류 메시지 출력
3938
- # 열린 모든 창을 닫음
3939
- @driver.window_handles.each do |handle|
3940
- @driver.switch_to.window(handle)
3941
- begin
3942
- @driver.close
3943
- rescue Selenium::WebDriver::Error::WebDriverError => e
3944
- puts "사이트 내부에 예외 발생: #{e.message}"
3945
- end
3946
- end
3947
-
3948
- # 드라이버 종료
3949
- @driver.quit if @driver
3950
- return 0
3951
-
3952
- rescue Selenium::WebDriver::Error::TimeoutError => e
3953
- puts "웹 페이지 로드가 시간 초과되었습니다: #{e.message}"
4231
+ # 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4232
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4233
+ if error_text
4234
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
3954
4235
  @driver.quit if @driver
3955
4236
  return 0
3956
-
3957
- rescue
3958
4237
  end
4238
+ rescue
4239
+ end
3959
4240
 
4241
+ begin
4242
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4243
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"Connection timed out")]')
4244
+ if error_text
4245
+ puts '사이트 문제 발견!! 사이트에 접근할수 없습니다 창을 닫습니다.'
4246
+ @driver.quit if @driver
4247
+ return 0
4248
+ end
4249
+ rescue
4250
+ end
3960
4251
 
4252
+ begin
4253
+ wait = Selenium::WebDriver::Wait.new(:timeout => 2) # 3초 대기
4254
+ alert = wait.until { @driver.switch_to.alert } # alert가 나타날 때까지 기다림
4255
+ alert.accept # 알림을 확인
4256
+ rescue
4257
+ end
3961
4258
 
3962
-
4259
+
3963
4260
  sleep(1)
4261
+
4262
+
3964
4263
  begin
3965
- puts '-[√] 글쓰기 버튼 클릭이 필수인지 탐색합니다.......'.green
4264
+
3966
4265
  el_post_btn = @driver.find_element(:xpath, '//*[@class="btn btn-primary btn-sm float_r"]')
3967
4266
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3968
4267
  sleep(1)
3969
4268
  @driver.find_element(:xpath, '//*[@class="btn btn-primary btn-sm float_r"]').click
3970
4269
  sleep(3.7)
3971
- puts '-[√] 글쓰기 버튼 code 1.......'.green
4270
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 1 타겟.......'.green
3972
4271
  rescue
3973
4272
  begin
3974
4273
  el_post_btn = @driver.find_element(:xpath, '//*[@class="btn-block-right"]')
3975
4274
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3976
4275
  sleep(1)
3977
4276
  @driver.find_element(:xpath, '//*[@class="btn-block-right"]').click
3978
- puts '-[√] 글쓰기 버튼 code 2.......'.green
4277
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 2 타겟.......'.green
3979
4278
  sleep(3.7)
3980
4279
  rescue
3981
4280
  begin
@@ -3983,7 +4282,7 @@ login_url = option['login_url'].to_s
3983
4282
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3984
4283
  sleep(1)
3985
4284
  @driver.find_element(:xpath, '//*[@class="write_btn"]').click
3986
- puts '-[√] 글쓰기 버튼 code 3.......'.green
4285
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 3 타겟.......'.green
3987
4286
  sleep(3.7)
3988
4287
  rescue
3989
4288
  begin
@@ -3991,7 +4290,7 @@ login_url = option['login_url'].to_s
3991
4290
  @driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'center'})", el_post_btn)
3992
4291
  sleep(1)
3993
4292
  @driver.find_element(:xpath, '//*[@class="gRight"]').click
3994
- puts '-[√] 글쓰기 버튼 code 4.......'.green
4293
+ puts '-[√] 글쓰기 버튼 클릭 확인 code 4 타겟.......'.green
3995
4294
  sleep(3.7)
3996
4295
  rescue
3997
4296
 
@@ -3999,18 +4298,33 @@ login_url = option['login_url'].to_s
3999
4298
  end
4000
4299
  end
4001
4300
  end
4002
-
4301
+
4003
4302
  sleep(1)
4303
+ #오른쪽 마우스 해제 코드
4304
+ begin
4305
+ @driver.execute_script <<-JS
4306
+ document.querySelectorAll('body').forEach(function(element) {
4307
+ element.oncontextmenu = null;
4308
+ });
4309
+ document.removeEventListener('contextmenu', function(e) { e.preventDefault(); }, false);
4310
+ JS
4004
4311
 
4005
- ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4312
+ @driver.execute_script <<-JS
4313
+ document.addEventListener('contextmenu', function(e) {
4314
+ e.stopImmediatePropagation();
4315
+ }, true);
4316
+ JS
4317
+
4318
+ @driver.execute_script("window.oncontextmenu = null;")
4319
+ rescue
4320
+ end
4321
+
4322
+ ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4006
4323
 
4007
- puts '-[√] 1 캡챠 발생 유무 확인.......'.green
4008
- sleep(1)
4009
- puts '-[√] 2 캡챠 발생 유무 확인.......'.green
4010
- sleep(1)
4011
- puts '-[√] 3 캡챠 발생 유무 확인.......'.green
4012
- sleep(1)
4013
4324
 
4325
+ sleep(5)
4326
+
4327
+
4014
4328
  begin
4015
4329
  @driver.find_element(:xpath, '//*[@class="amzn-captcha-state-container"]')
4016
4330
  puts '-[√] 아임웹 캡챠 확인!! 해제 실행.......'.green
@@ -4148,7 +4462,7 @@ login_url = option['login_url'].to_s
4148
4462
  end
4149
4463
  end
4150
4464
  rescue
4151
- puts '-[√] 캡챠 발생 없음.......'.green
4465
+
4152
4466
  end
4153
4467
  end
4154
4468
  end
@@ -4187,6 +4501,7 @@ login_url = option['login_url'].to_s
4187
4501
  rescue => e
4188
4502
  begin
4189
4503
  @driver.switch_to.alert.accept
4504
+ sleep(1)
4190
4505
  rescue
4191
4506
  end
4192
4507
  puts '-[√] 글쓰기 페이지 접속 시도 실패 (페이지 로딩 지연 및 접속 불량).......'.red
@@ -4202,7 +4517,20 @@ login_url = option['login_url'].to_s
4202
4517
  sleep(2)
4203
4518
  rescue
4204
4519
  end
4205
-
4520
+
4521
+ begin
4522
+ # 이 부분을 통해 페이지 내에서 "사이트에 연결할 수 없음" 텍스트를 찾습니다.
4523
+ error_text = @driver.find_element(:xpath, '//*[contains(text(),"사이트에 연결할 수 없음")]')
4524
+ if error_text
4525
+ puts '사이트에 연결할 수 없음 텍스트가 발견되었습니다. 창을 닫습니다.'
4526
+ @driver.quit if @driver
4527
+ return 0
4528
+ end
4529
+ rescue Selenium::WebDriver::Error::NoSuchElementError
4530
+ # 해당 텍스트가 없으면 아무 작업 안함
4531
+ end
4532
+
4533
+
4206
4534
 
4207
4535
  begin
4208
4536
  chat_box = @driver.find_element(:xpath, '//*[@class="adsbygoogle adsbygoogle-noablate"]')
@@ -4323,68 +4651,95 @@ login_url = option['login_url'].to_s
4323
4651
  rescue
4324
4652
  end
4325
4653
 
4654
+ begin
4655
+ # <ins> 태그를 찾고 삭제하기
4656
+ ins_elements = @driver.find_elements(tag_name: 'ins')
4657
+
4658
+ ins_elements.each do |element|
4659
+ # 요소 삭제
4660
+ @driver.execute_script("arguments[0].remove();", element)
4661
+ puts '-[√] 숨김 code 중 13번 code 제거 완료.......'.green
4662
+ sleep(1)
4663
+ end
4664
+ rescue
4665
+ end
4666
+
4326
4667
  end
4327
4668
 
4328
4669
 
4329
4670
 
4330
4671
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4331
- puts '-[√] 팝업 여부 확인 체크 01.......'.yellow
4672
+
4332
4673
 
4333
4674
  begin
4334
4675
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4335
4676
  sleep(1)
4677
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4336
4678
  rescue
4337
4679
  begin
4338
4680
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4339
4681
  sleep(1)
4682
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4340
4683
  rescue
4341
4684
  begin
4342
4685
  @driver.find_element(:xpath, '//*[@class="close"]').click
4343
4686
  sleep(1)
4687
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4344
4688
  rescue
4345
4689
  begin
4346
4690
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4347
4691
  sleep(1)
4692
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4348
4693
  rescue
4349
4694
  begin
4350
4695
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4351
4696
  sleep(1)
4697
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4352
4698
  rescue
4353
4699
  begin
4354
4700
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4355
4701
  sleep(1)
4702
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4356
4703
  rescue
4357
4704
  begin
4358
4705
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4359
4706
  sleep(1)
4707
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4360
4708
  rescue
4361
4709
  begin
4362
4710
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4363
4711
  sleep(1)
4712
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4364
4713
  rescue
4365
4714
  begin
4366
4715
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4367
4716
  sleep(1)
4717
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4368
4718
  rescue
4369
4719
  begin
4370
4720
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4371
4721
  sleep(1)
4722
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4372
4723
  rescue
4373
4724
  begin
4374
4725
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4375
4726
  sleep(1)
4727
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4376
4728
  rescue
4377
4729
  begin
4378
4730
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4379
4731
  sleep(1)
4732
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4380
4733
  rescue
4381
4734
  begin
4382
4735
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4383
4736
  sleep(1)
4737
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4384
4738
  rescue
4385
4739
  begin
4386
4740
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4387
4741
  sleep(1)
4742
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4388
4743
  rescue
4389
4744
  begin
4390
4745
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4393,29 +4748,35 @@ login_url = option['login_url'].to_s
4393
4748
  sleep(1)
4394
4749
  @driver.switch_to.default_content()
4395
4750
  sleep(1)
4751
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4396
4752
  rescue
4397
4753
  begin
4398
4754
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4399
4755
  sleep(1)
4756
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4400
4757
  rescue
4401
4758
  begin
4402
4759
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4403
4760
  sleep(1)
4761
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4404
4762
  rescue
4405
4763
  begin
4406
4764
  @driver.find_element(:xpath, '//*[@id="banner"]/div[1]/div/div[1]').click
4407
4765
  sleep(1)
4766
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4408
4767
  rescue
4409
4768
 
4410
4769
  begin
4411
4770
  @driver.find_element(:xpath, '//*[@id="hd_pops_1"]/div[2]/button[1]').click
4412
4771
  sleep(1)
4772
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4413
4773
  rescue
4414
4774
  begin
4415
4775
  @driver.find_element(:xpath, '//*[@class="modal_close"]').click
4416
4776
  sleep(1)
4777
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4417
4778
  rescue
4418
- puts '.......'.yellow
4779
+
4419
4780
 
4420
4781
  end
4421
4782
 
@@ -4446,63 +4807,77 @@ login_url = option['login_url'].to_s
4446
4807
 
4447
4808
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4448
4809
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4449
- puts '-[√] 팝업 여부 확인 체크 02.......'.yellow
4810
+
4450
4811
 
4451
4812
  begin
4452
4813
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4453
4814
  sleep(1)
4815
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4454
4816
  rescue
4455
4817
  begin
4456
4818
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4457
4819
  sleep(1)
4820
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4458
4821
  rescue
4459
4822
  begin
4460
4823
  @driver.find_element(:xpath, '//*[@class="close"]').click
4461
4824
  sleep(1)
4825
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4462
4826
  rescue
4463
4827
  begin
4464
4828
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4465
4829
  sleep(1)
4830
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4466
4831
  rescue
4467
4832
  begin
4468
4833
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4469
4834
  sleep(1)
4835
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4470
4836
  rescue
4471
4837
  begin
4472
4838
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4473
4839
  sleep(1)
4840
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4474
4841
  rescue
4475
4842
  begin
4476
4843
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4477
4844
  sleep(1)
4845
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4478
4846
  rescue
4479
4847
  begin
4480
4848
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4481
4849
  sleep(1)
4850
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4482
4851
  rescue
4483
4852
  begin
4484
4853
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4485
4854
  sleep(1)
4855
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4486
4856
  rescue
4487
4857
  begin
4488
4858
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4489
4859
  sleep(1)
4860
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4490
4861
  rescue
4491
4862
  begin
4492
4863
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4493
4864
  sleep(1)
4865
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4494
4866
  rescue
4495
4867
  begin
4496
4868
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4497
4869
  sleep(1)
4870
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4498
4871
  rescue
4499
4872
  begin
4500
4873
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4501
4874
  sleep(1)
4875
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4502
4876
  rescue
4503
4877
  begin
4504
4878
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4505
4879
  sleep(1)
4880
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4506
4881
  rescue
4507
4882
  begin
4508
4883
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4511,25 +4886,29 @@ login_url = option['login_url'].to_s
4511
4886
  sleep(1)
4512
4887
  @driver.switch_to.default_content()
4513
4888
  sleep(1)
4889
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4514
4890
  rescue
4515
4891
  begin
4516
4892
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4517
4893
  sleep(1)
4894
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4518
4895
  rescue
4519
4896
  begin
4520
4897
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4521
4898
  sleep(1)
4899
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4522
4900
  rescue
4523
4901
  begin
4524
4902
  @driver.find_element(:xpath, '//*[@id="banner"]/div[2]/div/div[1]').click
4525
4903
  sleep(1)
4904
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4526
4905
  rescue
4527
4906
  begin
4528
4907
  @driver.find_element(:xpath, '//*[@id="hd_pops_2"]/div[2]/button[1]').click
4529
4908
  sleep(1)
4530
-
4909
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4531
4910
  rescue
4532
- puts '.......'.yellow
4911
+
4533
4912
 
4534
4913
  end
4535
4914
 
@@ -4559,63 +4938,76 @@ login_url = option['login_url'].to_s
4559
4938
  end
4560
4939
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4561
4940
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4562
- puts '-[√] 팝업 여부 확인 체크 03.......'.yellow
4563
4941
 
4564
4942
  begin
4565
4943
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4566
4944
  sleep(1)
4945
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4567
4946
  rescue
4568
4947
  begin
4569
4948
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4570
4949
  sleep(1)
4950
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4571
4951
  rescue
4572
4952
  begin
4573
4953
  @driver.find_element(:xpath, '//*[@class="close"]').click
4574
4954
  sleep(1)
4955
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4575
4956
  rescue
4576
4957
  begin
4577
4958
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4578
4959
  sleep(1)
4960
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4579
4961
  rescue
4580
4962
  begin
4581
4963
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4582
4964
  sleep(1)
4965
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4583
4966
  rescue
4584
4967
  begin
4585
4968
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4586
4969
  sleep(1)
4970
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4587
4971
  rescue
4588
4972
  begin
4589
4973
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4590
4974
  sleep(1)
4975
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4591
4976
  rescue
4592
4977
  begin
4593
4978
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4594
4979
  sleep(1)
4980
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4595
4981
  rescue
4596
4982
  begin
4597
4983
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4598
4984
  sleep(1)
4985
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4599
4986
  rescue
4600
4987
  begin
4601
4988
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4602
4989
  sleep(1)
4990
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4603
4991
  rescue
4604
4992
  begin
4605
4993
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4606
4994
  sleep(1)
4995
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4607
4996
  rescue
4608
4997
  begin
4609
4998
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4610
4999
  sleep(1)
5000
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4611
5001
  rescue
4612
5002
  begin
4613
5003
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4614
5004
  sleep(1)
5005
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4615
5006
  rescue
4616
5007
  begin
4617
5008
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4618
5009
  sleep(1)
5010
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4619
5011
  rescue
4620
5012
  begin
4621
5013
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4624,24 +5016,29 @@ login_url = option['login_url'].to_s
4624
5016
  sleep(1)
4625
5017
  @driver.switch_to.default_content()
4626
5018
  sleep(1)
5019
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4627
5020
  rescue
4628
5021
  begin
4629
5022
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4630
5023
  sleep(1)
5024
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4631
5025
  rescue
4632
5026
  begin
4633
5027
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4634
5028
  sleep(1)
5029
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4635
5030
  rescue
4636
5031
  begin
4637
5032
  @driver.find_element(:xpath, '//*[@id="banner"]/div[3]/div/div[1]').click
4638
5033
  sleep(1)
5034
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4639
5035
  rescue
4640
5036
  begin
4641
5037
  @driver.find_element(:xpath, '//*[@id="hd_pops_3"]/div[2]/button[1]').click
4642
5038
  sleep(1)
5039
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4643
5040
  rescue
4644
- puts '.......'.yellow
5041
+
4645
5042
 
4646
5043
  end
4647
5044
 
@@ -4671,63 +5068,77 @@ login_url = option['login_url'].to_s
4671
5068
  end
4672
5069
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4673
5070
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4674
- puts '-[√] 팝업 여부 확인 체크 04.......'.yellow
5071
+
4675
5072
 
4676
5073
  begin
4677
5074
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4678
5075
  sleep(1)
5076
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4679
5077
  rescue
4680
5078
  begin
4681
5079
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4682
5080
  sleep(1)
5081
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4683
5082
  rescue
4684
5083
  begin
4685
5084
  @driver.find_element(:xpath, '//*[@class="close"]').click
4686
5085
  sleep(1)
5086
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4687
5087
  rescue
4688
5088
  begin
4689
5089
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4690
5090
  sleep(1)
5091
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4691
5092
  rescue
4692
5093
  begin
4693
5094
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4694
5095
  sleep(1)
5096
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4695
5097
  rescue
4696
5098
  begin
4697
5099
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4698
5100
  sleep(1)
5101
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4699
5102
  rescue
4700
5103
  begin
4701
5104
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4702
5105
  sleep(1)
5106
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4703
5107
  rescue
4704
5108
  begin
4705
5109
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4706
5110
  sleep(1)
5111
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4707
5112
  rescue
4708
5113
  begin
4709
5114
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4710
5115
  sleep(1)
5116
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4711
5117
  rescue
4712
5118
  begin
4713
5119
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4714
5120
  sleep(1)
5121
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4715
5122
  rescue
4716
5123
  begin
4717
5124
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4718
5125
  sleep(1)
5126
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4719
5127
  rescue
4720
5128
  begin
4721
5129
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4722
5130
  sleep(1)
5131
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4723
5132
  rescue
4724
5133
  begin
4725
5134
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4726
5135
  sleep(1)
5136
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4727
5137
  rescue
4728
5138
  begin
4729
5139
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4730
5140
  sleep(1)
5141
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4731
5142
  rescue
4732
5143
  begin
4733
5144
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4736,24 +5147,29 @@ login_url = option['login_url'].to_s
4736
5147
  sleep(1)
4737
5148
  @driver.switch_to.default_content()
4738
5149
  sleep(1)
5150
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4739
5151
  rescue
4740
5152
  begin
4741
5153
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4742
5154
  sleep(1)
5155
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4743
5156
  rescue
4744
5157
  begin
4745
5158
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4746
5159
  sleep(1)
5160
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4747
5161
  rescue
4748
5162
  begin
4749
5163
  @driver.find_element(:xpath, '//*[@id="banner"]/div[4]/div/div[1]').click
4750
5164
  sleep(1)
5165
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4751
5166
  rescue
4752
5167
  begin
4753
5168
  @driver.find_element(:xpath, '//*[@id="hd_pops_4"]/div[2]/button[1]').click
4754
5169
  sleep(1)
5170
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4755
5171
  rescue
4756
- puts '.......'.yellow
5172
+
4757
5173
 
4758
5174
  end
4759
5175
 
@@ -4783,63 +5199,77 @@ login_url = option['login_url'].to_s
4783
5199
  end
4784
5200
  ##<─────────────────────────────────────────────────────────────────────팝업 코드 확인 및 제거 부분
4785
5201
  ##팝업 코드 확인 및 제거 부분─────────────────────────────────────────────────────────────────────>
4786
- puts '-[√] 팝업 여부 확인 체크 05.......'.yellow
5202
+
4787
5203
 
4788
5204
  begin
4789
5205
  @driver.find_element(:partial_link_text, '더 이상 보지 않기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4790
5206
  sleep(1)
5207
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4791
5208
  rescue
4792
5209
  begin
4793
5210
  @driver.find_element(:xpath, '//*[@class="permanentClose"]').click
4794
5211
  sleep(1)
5212
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4795
5213
  rescue
4796
5214
  begin
4797
5215
  @driver.find_element(:xpath, '//*[@class="close"]').click
4798
5216
  sleep(1)
5217
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4799
5218
  rescue
4800
5219
  begin
4801
5220
  @driver.find_element(:partial_link_text, '닫기').click #요소같고 텍스트가 다를때 텍스트로 타겟
4802
5221
  sleep(1)
5222
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4803
5223
  rescue
4804
5224
  begin
4805
5225
  @driver.find_element(:xpath, '//*[@class="fas fa-angle-down"]').click
4806
5226
  sleep(1)
5227
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4807
5228
  rescue
4808
5229
  begin
4809
5230
  @driver.find_element(:xpath, '//*[@class="fa fa-check-square-o"]').click
4810
5231
  sleep(1)
5232
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4811
5233
  rescue
4812
5234
  begin
4813
5235
  @driver.find_element(:xpath, '//*[@title="Close"]').click
4814
5236
  sleep(1)
5237
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4815
5238
  rescue
4816
5239
  begin
4817
5240
  @driver.find_element(:xpath, '//*[@alt="Close"]').click
4818
5241
  sleep(1)
5242
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4819
5243
  rescue
4820
5244
  begin
4821
5245
  @driver.find_element(:xpath, '//*[@class="sgpb-popup-close-button-1"]').click
4822
5246
  sleep(1)
5247
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4823
5248
  rescue
4824
5249
  begin
4825
5250
  @driver.find_element(:partial_link_text, '시간 동안 다시 열람하지 않습니다.').click
4826
5251
  sleep(1)
5252
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4827
5253
  rescue
4828
5254
  begin
4829
5255
  @driver.find_element(:xpath, '//*[@class="btn skip"]').click
4830
5256
  sleep(1)
5257
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4831
5258
  rescue
4832
5259
  begin
4833
5260
  @driver.find_element(:xpath, '//*[@stroke="#FAFAFA"]').click
4834
5261
  sleep(1)
5262
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4835
5263
  rescue
4836
5264
  begin
4837
5265
  @driver.find_element(:xpath, '//*[@fill="#FAFAFA"]').click
4838
5266
  sleep(1)
5267
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4839
5268
  rescue
4840
5269
  begin
4841
5270
  @driver.find_element(:xpath, '//*[@stroke-linecap="square"]').click
4842
5271
  sleep(1)
5272
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4843
5273
  rescue
4844
5274
  begin
4845
5275
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="Advertisement"]'))
@@ -4848,22 +5278,27 @@ login_url = option['login_url'].to_s
4848
5278
  sleep(1)
4849
5279
  @driver.switch_to.default_content()
4850
5280
  sleep(1)
5281
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4851
5282
  rescue
4852
5283
  begin
4853
5284
  @driver.find_element(:xpath, '//*[@id="footer-btn-icon"]').click
4854
5285
  sleep(1)
5286
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4855
5287
  rescue
4856
5288
  begin
4857
5289
  @driver.find_element(:xpath, '//*[@id="dismiss-button"]').click
4858
5290
  sleep(1)
5291
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4859
5292
  rescue
4860
5293
  begin
4861
5294
  @driver.find_element(:xpath, '//*[@id="banner"]/div[5]/div/div[1]').click
4862
5295
  sleep(1)
5296
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4863
5297
  rescue
4864
5298
  begin
4865
5299
  @driver.find_element(:xpath, '//*[@id="hd_pops_5"]/div[2]/button[1]').click
4866
5300
  sleep(1)
5301
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4867
5302
  rescue
4868
5303
  begin
4869
5304
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@id="aswift_1"]'))
@@ -4872,8 +5307,9 @@ login_url = option['login_url'].to_s
4872
5307
  sleep(1)
4873
5308
  @driver.switch_to.default_content
4874
5309
  sleep(1)
5310
+ puts '-[√] 팝업 여부 확인 체크.......'.yellow
4875
5311
  rescue
4876
- puts '.......'.yellow
5312
+
4877
5313
 
4878
5314
  end
4879
5315
 
@@ -4911,7 +5347,7 @@ login_url = option['login_url'].to_s
4911
5347
 
4912
5348
 
4913
5349
  ##닉네임 입력 코드 부분─────────────────────────────────────────────────────────────────────>
4914
- puts '-[√] 닉네임 입력 가능 여부 체크.......'.yellow
5350
+
4915
5351
 
4916
5352
  begin
4917
5353
  @driver.find_element(:xpath, '//*[@id="wr_name"]').send_keys(user_id)
@@ -4924,115 +5360,114 @@ begin
4924
5360
  puts '-[√] 닉네임 2코드 타겟.......'.yellow
4925
5361
  rescue
4926
5362
  begin
4927
- begin
4928
- @driver.find_element(:xpath, '//*[@name="member_display"]').send_keys(user_id)
4929
- sleep(1)
4930
- puts '-[√] 닉네임 3-1코드 타겟.......'.yellow
4931
- rescue
4932
- rows = @driver.find_elements(class: 'kboard-attr-row')
4933
- rows.each do |row|
4934
- begin
4935
- input_element = row.find_element(xpath: './/input[@name="member_display"]')
4936
- input_element.send_keys(user_id)
4937
- sleep(1)
4938
- puts '-[√] 닉네임 3-2코드 타겟.......'.yellow
4939
- rescue
4940
- next
4941
- end
4942
- end
4943
- end
5363
+ @driver.find_element(:xpath, '//*[@name="member_display"]').send_keys(user_id)
5364
+ sleep(1)
5365
+ puts '-[√] 닉네임 3-1코드 타겟.......'.yellow
4944
5366
  rescue
4945
5367
  begin
4946
- @driver.find_element(:xpath, '//*[@title="닉네임"]').send_keys(user_id)
5368
+ @driver.find_element(xpath: '//input[@name="member_display"]').send_keys(user_id)
4947
5369
  sleep(1)
4948
- puts '-[√] 닉네임 4코드 타겟.......'.yellow
5370
+ puts '-[√] 닉네임 3-2코드 타겟.......'.yellow
4949
5371
  rescue
4950
5372
  begin
4951
- @driver.find_element(:xpath, '//*[@name="name"]').send_keys(user_id)
5373
+ @driver.find_element(:xpath, '//*[@title="닉네임"]').send_keys(user_id)
4952
5374
  sleep(1)
4953
- puts '-[√] 닉네임 5코드 타겟.......'.yellow
5375
+ puts '-[√] 닉네임 4코드 타겟.......'.yellow
4954
5376
  rescue
4955
5377
  begin
4956
- @driver.find_element(:xpath, '//*[@name="writer"]').send_keys(user_id)
5378
+ @driver.find_element(:xpath, '//*[@name="name"]').send_keys(user_id)
4957
5379
  sleep(1)
4958
- puts '-[√] 닉네임 6코드 타겟.......'.yellow
5380
+ puts '-[√] 닉네임 5코드 타겟.......'.yellow
4959
5381
  rescue
4960
5382
  begin
4961
- @driver.find_element(:xpath, '//*[@name="hname"]').send_keys(user_id)
5383
+ @driver.find_element(:xpath, '//*[@name="writer"]').send_keys(user_id)
4962
5384
  sleep(1)
4963
- puts '-[√] 닉네임 7코드 타겟.......'.yellow
5385
+ puts '-[√] 닉네임 6코드 타겟.......'.yellow
4964
5386
  rescue
4965
5387
  begin
4966
- @driver.find_element(:xpath, '//*[@name="wr_name"]').send_keys(user_id)
5388
+ @driver.find_element(:xpath, '//*[@name="hname"]').send_keys(user_id)
4967
5389
  sleep(1)
4968
- puts '-[√] 닉네임 8코드 타겟.......'.yellow
5390
+ puts '-[√] 닉네임 7코드 타겟.......'.yellow
4969
5391
  rescue
4970
5392
  begin
4971
- @driver.find_element(:xpath, '//*[@name="post_nickname"]').send_keys(user_id)
5393
+ @driver.find_element(:xpath, '//*[@name="wr_name"]').send_keys(user_id)
4972
5394
  sleep(1)
4973
- puts '-[√] 닉네임 9코드 타겟.......'.yellow
5395
+ puts '-[√] 닉네임 8코드 타겟.......'.yellow
4974
5396
  rescue
4975
5397
  begin
4976
- @driver.find_element(:xpath, '//*[@name="user_name"]').send_keys(user_id)
5398
+ @driver.find_element(:xpath, '//*[@name="post_nickname"]').send_keys(user_id)
4977
5399
  sleep(1)
4978
- puts '-[√] 닉네임 10코드 타겟.......'.yellow
5400
+ puts '-[√] 닉네임 9코드 타겟.......'.yellow
4979
5401
  rescue
4980
5402
  begin
4981
- @driver.find_element(:xpath, '//*[@class="mb-user-name"]').send_keys(user_id)
5403
+ @driver.find_element(:xpath, '//*[@name="user_name"]').send_keys(user_id)
4982
5404
  sleep(1)
4983
- puts '-[√] 닉네임 11코드 타겟.......'.yellow
5405
+ puts '-[√] 닉네임 10코드 타겟.......'.yellow
4984
5406
  rescue
4985
5407
  begin
4986
- @driver.find_element(:xpath, '//*[@placeholder="비회원 닉네임"]').send_keys(user_id)
5408
+ @driver.find_element(:xpath, '//*[@class="mb-user-name"]').send_keys(user_id)
4987
5409
  sleep(1)
4988
- puts '-[√] 닉네임 12코드 타겟.......'.yellow
5410
+ puts '-[√] 닉네임 11코드 타겟.......'.yellow
4989
5411
  rescue
4990
5412
  begin
4991
- @driver.find_element(:xpath, '//*[@placeholder="이름"]').send_keys(user_id)
5413
+ @driver.find_element(:xpath, '//*[@placeholder="비회원 닉네임"]').send_keys(user_id)
4992
5414
  sleep(1)
4993
- puts '-[√] 닉네임 13코드 타겟.......'.yellow
5415
+ puts '-[√] 닉네임 12코드 타겟.......'.yellow
4994
5416
  rescue
4995
5417
  begin
4996
- @driver.find_element(:xpath, '//*[@name="nickname"]').send_keys(user_id)
5418
+ @driver.find_element(:xpath, '//*[@placeholder="이름"]').send_keys(user_id)
4997
5419
  sleep(1)
4998
- puts '-[√] 닉네임 14코드 타겟.......'.yellow
5420
+ puts '-[√] 닉네임 13코드 타겟.......'.yellow
4999
5421
  rescue
5000
5422
  begin
5001
- @driver.find_element(:xpath, '//*[@name="nick"]').send_keys(user_id)
5423
+ @driver.find_element(:xpath, '//*[@name="nickname"]').send_keys(user_id)
5002
5424
  sleep(1)
5003
- puts '-[√] 닉네임 15코드 타겟.......'.yellow
5425
+ puts '-[√] 닉네임 14코드 타겟.......'.yellow
5004
5426
  rescue
5005
5427
  begin
5006
- @driver.find_element(:xpath, '//*[@placeholder="작성자 이름"]').send_keys(user_id)
5428
+ @driver.find_element(:xpath, '//*[@name="nick"]').send_keys(user_id)
5007
5429
  sleep(1)
5008
- puts '-[√] 닉네임 16코드 타겟.......'.yellow
5430
+ puts '-[√] 닉네임 15코드 타겟.......'.yellow
5009
5431
  rescue
5010
5432
  begin
5011
- @driver.find_element(:xpath, '//*[@id="reg_name"]').send_keys(user_id)
5433
+ @driver.find_element(:xpath, '//*[@placeholder="작성자 이름"]').send_keys(user_id)
5012
5434
  sleep(1)
5013
- puts '-[√] 닉네임 17코드 타겟.......'.yellow
5435
+ puts '-[√] 닉네임 16코드 타겟.......'.yellow
5014
5436
  rescue
5015
5437
  begin
5016
- @driver.find_element(:xpath, '//*[@id="postWriter"]').send_keys(user_id)
5438
+ @driver.find_element(:xpath, '//*[@id="reg_name"]').send_keys(user_id)
5017
5439
  sleep(1)
5018
- puts '-[√] 닉네임 18코드 타겟.......'.yellow
5440
+ puts '-[√] 닉네임 17코드 타겟.......'.yellow
5019
5441
  rescue
5020
5442
  begin
5021
- @driver.find_element(:xpath, '//*[@id="kboard-input-member-display"]').send_keys(user_id)
5443
+ @driver.find_element(:xpath, '//*[@id="postWriter"]').send_keys(user_id)
5022
5444
  sleep(1)
5023
- puts '-[√] 닉네임 19코드 타겟.......'.yellow
5445
+ puts '-[√] 닉네임 18코드 타겟.......'.yellow
5024
5446
  rescue
5025
5447
  begin
5026
- @driver.find_element(:xpath, '//*[@name="nick_name"]').send_keys(user_id)
5448
+ @driver.find_element(:xpath, '//*[@id="kboard-input-member-display"]').send_keys(user_id)
5027
5449
  sleep(1)
5028
- puts '-[√] 닉네임 20코드 타겟.......'.yellow
5450
+ puts '-[√] 닉네임 19코드 타겟.......'.yellow
5029
5451
  rescue
5030
5452
  begin
5031
- @driver.find_element(:xpath, '//*[@name="write_name"]').send_keys(user_id)
5453
+ @driver.find_element(:xpath, '//*[@name="nick_name"]').send_keys(user_id)
5032
5454
  sleep(1)
5033
- puts '-[√] 닉네임 21코드 타겟.......'.yellow
5455
+ puts '-[√] 닉네임 20코드 타겟.......'.yellow
5034
5456
  rescue
5035
-
5457
+ begin
5458
+ @driver.find_element(:xpath, '//*[@name="write_name"]').send_keys(user_id)
5459
+ sleep(1)
5460
+ puts '-[√] 닉네임 21코드 타겟.......'.yellow
5461
+ rescue
5462
+ begin
5463
+ @driver.find_element(:xpath, '//*[@placeholder="작성자"]').send_keys(user_id)
5464
+ sleep(1)
5465
+ puts '-[√] 닉네임 22코드 타겟.......'.yellow
5466
+ rescue
5467
+
5468
+ end
5469
+
5470
+ end
5036
5471
  end
5037
5472
  end
5038
5473
  end
@@ -5053,13 +5488,13 @@ begin
5053
5488
  end
5054
5489
  end
5055
5490
  end
5056
- puts '-[√] 닉네임 입력 가능 여부 종료.......'.yellow
5491
+
5057
5492
  end
5058
5493
  ##<─────────────────────────────────────────────────────────────────────닉네임 입력 코드 부분
5059
5494
 
5060
5495
 
5061
5496
  ##패스워드 입력 코드 부분─────────────────────────────────────────────────────────────────────>
5062
- puts '-[√] 패스워드 입력 가능 여부 체크.......'.yellow
5497
+
5063
5498
  begin
5064
5499
  @driver.find_element(:xpath, '//*[@id="wr_password"]').send_keys(user_pw)
5065
5500
  sleep(1)
@@ -5150,7 +5585,7 @@ begin
5150
5585
  end
5151
5586
  end
5152
5587
  end
5153
- puts '-[√] 패스워드 입력 가능 여부 종료.......'.yellow
5588
+
5154
5589
  sleep(1)
5155
5590
  end
5156
5591
  ##<─────────────────────────────────────────────────────────────────────패스워드 입력 코드 부분
@@ -5195,7 +5630,7 @@ begin
5195
5630
  @driver.find_element(:xpath, '//*[@name="wr_10"]').send_keys(more_txt1)
5196
5631
  sleep(1)
5197
5632
  rescue
5198
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5633
+
5199
5634
 
5200
5635
  end
5201
5636
 
@@ -5231,7 +5666,7 @@ begin
5231
5666
  @driver.find_element(:xpath, '//*[@name="wr_11"]').send_keys(more_txt1)
5232
5667
  sleep(1)
5233
5668
  rescue
5234
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5669
+
5235
5670
 
5236
5671
  end
5237
5672
 
@@ -5267,7 +5702,7 @@ begin
5267
5702
  @driver.find_element(:xpath, '//*[@name="wr_12"]').send_keys(more_txt1)
5268
5703
  sleep(1)
5269
5704
  rescue
5270
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5705
+
5271
5706
 
5272
5707
  end
5273
5708
 
@@ -5303,7 +5738,7 @@ begin
5303
5738
  @driver.find_element(:xpath, '//*[@name="wr_13"]').send_keys(more_txt1)
5304
5739
  sleep(1)
5305
5740
  rescue
5306
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5741
+
5307
5742
 
5308
5743
  end
5309
5744
 
@@ -5339,7 +5774,7 @@ begin
5339
5774
  @driver.find_element(:xpath, '//*[@name="wr_14"]').send_keys(more_txt1)
5340
5775
  sleep(1)
5341
5776
  rescue
5342
- puts '-[√] 기타 입력 부분 탐색 1차 코드 탐색 종료.......'.yellow
5777
+
5343
5778
 
5344
5779
  end
5345
5780
 
@@ -5454,7 +5889,7 @@ begin
5454
5889
 
5455
5890
 
5456
5891
  ##체크박스 코드 부분─────────────────────────────────────────────────────────────────────>
5457
- puts '-[√] 체크 항목 탐색 시작.......'.yellow
5892
+ #puts '-[√] 체크 항목 탐색 시작.......'.yellow
5458
5893
  begin
5459
5894
  @driver.find_element(:xpath, '//*[@fw-label="개인정보보호정책"]').click
5460
5895
  sleep(1)
@@ -5532,12 +5967,12 @@ begin
5532
5967
 
5533
5968
  title = title.strip
5534
5969
  ##제목 입력 코드 부분─────────────────────────────────────────────────────────────────────>
5535
- puts '-[√] 제목 입력 필드 탐색 시작.......'.yellow
5970
+ #puts '-[√] 제목 입력 필드 탐색 시작.......'.yellow
5536
5971
 
5537
5972
  begin
5538
5973
  @driver.find_element(:xpath, '//*[@id="wr_subject"]').click
5539
5974
  sleep(1)
5540
- @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(:title)
5975
+ @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(title)
5541
5976
  puts '-[√] 제목 code 1.......'.yellow
5542
5977
  rescue
5543
5978
  begin
@@ -5640,7 +6075,7 @@ begin
5640
6075
  ########################################################2차@#######################################
5641
6076
  begin
5642
6077
 
5643
- @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(:title)
6078
+ @driver.find_element(:xpath, '//*[@id="wr_subject"]').send_keys(title)
5644
6079
  puts '-[√] 제목 code 19.......'.yellow
5645
6080
  rescue
5646
6081
  begin
@@ -5801,14 +6236,14 @@ begin
5801
6236
  end
5802
6237
  end
5803
6238
 
5804
- puts '-[√] 제목 입력 필드 탐색 종료.......'.yellow
6239
+ #puts '-[√] 제목 입력 필드 탐색 종료.......'.yellow
5805
6240
  sleep(1)
5806
6241
  ##<─────────────────────────────────────────────────────────────────────제목 입력 코드 부분
5807
6242
 
5808
6243
 
5809
6244
  ##HTML 버튼 코드 부분─────────────────────────────────────────────────────────────────────>
5810
- puts '-[√] HTML 코드 변경 버튼 탐색 시작.......'.yellow
5811
- sleep(1)
6245
+ # puts '-[√] HTML 코드 변경 버튼 탐색 시작.......'.yellow
6246
+
5812
6247
  begin
5813
6248
  #아이프레임에서 코드 선택
5814
6249
  @driver.switch_to.frame(@driver.find_element(:xpath, '//*[@scrolling="no"]'))
@@ -6068,13 +6503,12 @@ begin
6068
6503
  end
6069
6504
  end
6070
6505
 
6071
- puts '-[√] HTML 코드 변경 버튼 탐색 종료.......'.yellow
6072
- sleep(1)
6073
-
6506
+
6074
6507
 
6075
6508
  begin
6076
6509
  sleep(2)
6077
6510
  @driver.switch_to.alert.accept
6511
+ sleep(1)
6078
6512
  rescue
6079
6513
  sleep(1)
6080
6514
  end
@@ -6086,8 +6520,8 @@ begin
6086
6520
 
6087
6521
 
6088
6522
  ##내용 입력 필드 코드 부분─────────────────────────────────────────────────────────────────────>
6089
- puts '-[√] 내용 입력 부분 탐색 시작.......'.yellow
6090
- sleep(1)
6523
+ #puts '-[√] 내용 입력 부분 탐색 시작.......'.yellow
6524
+ #sleep(1)
6091
6525
  begin
6092
6526
  @driver.find_element(:xpath, '//*[@name="content"]').click
6093
6527
  sleep(1)
@@ -6311,20 +6745,7 @@ rescue
6311
6745
  sleep(1)
6312
6746
  puts '내용 항목 코드 타겟 39.......'.red
6313
6747
  rescue
6314
- begin
6315
- dev_tools = driver.execute_cdp_cmd('Emulate.DeviceMetrics', {
6316
- 'width' => 375, # 모바일 화면 너비 (예: iPhone X 너비)
6317
- 'height' => 667, # 모바일 화면 높이
6318
- 'deviceScaleFactor' => 3.0, # 화면 비율
6319
- 'mobile' => true # 모바일 모드 활성화
6320
- })
6321
- sleep(1)
6322
- @driver.find_element(:xpath, '//textarea[@name="kboard_content"]').click
6323
- sleep(1)
6324
- puts '내용 항목 코드 타겟 40.......'.red
6325
- rescue
6326
-
6327
- end
6748
+
6328
6749
  end
6329
6750
  end
6330
6751
  end
@@ -6366,9 +6787,9 @@ rescue
6366
6787
  end
6367
6788
  end
6368
6789
 
6369
- puts '-[√] 내용 입력 부분 탐색 종료.......'.yellow
6370
- end
6371
- sleep(1)
6790
+
6791
+ end
6792
+ sleep(1)
6372
6793
 
6373
6794
  ##<─────────────────────────────────────────────────────────────────────내용 입력 필드 코드 부분
6374
6795
 
@@ -6381,7 +6802,7 @@ rescue
6381
6802
  end
6382
6803
  ##<<─────────────────────────────────────────────────────────────────────내용 임시부분 제거
6383
6804
 
6384
- puts '-[√] 포스팅할 내용 준비.......'.cyan
6805
+
6385
6806
  puts content
6386
6807
  noko = Nokogiri::HTML(content, nil, Encoding::UTF_8.to_s)
6387
6808
  toomung = 0
@@ -6389,7 +6810,7 @@ end
6389
6810
 
6390
6811
  sleep(1)
6391
6812
  data = Hash.new
6392
- puts '-[√] 내용 등록 마무리 진행 중.......'.cyan
6813
+
6393
6814
 
6394
6815
 
6395
6816
 
@@ -7363,42 +7784,106 @@ end
7363
7784
 
7364
7785
 
7365
7786
 
7366
- #@driver.action.key_down(:tab).key_up(:tab).perform #x탭
7787
+ begin
7788
+
7789
+ @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]')
7790
+ check_captcha = 1
7367
7791
 
7792
+ rescue
7793
+ check_captcha = 0
7794
+ end
7368
7795
 
7369
- sleep(1)
7370
- ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
7371
- puts '-[√] 캡챠 유형 탐색.......'.green
7796
+ if check_captcha == 1
7797
+ begin
7798
+ # 타임아웃을 3초로 설정
7799
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
7800
+ # 요소가 나타날 때까지 30초 동안 기다립니다.
7801
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
7802
+ sleep(1)
7372
7803
 
7804
+ el_ready = @driver.find_element(:xpath, '//*[@data-state="ready"]')
7805
+ @driver.action.move_to(el_ready).perform
7806
+ sleep(1)
7373
7807
 
7374
- begin
7375
- @driver.switch_to.default_content()
7376
- #@driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7377
- el = @driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7378
- puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7379
- puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7380
- puts '-[√] 챕챠 코드 code 1.......'.red
7381
- sleep(1)
7382
- @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7383
- sleep(1)
7384
- mouse_move_percentage(0.3,0.02)
7385
- sleep(0.5)
7386
- left_click
7387
- sleep(1)
7388
- @driver.switch_to.window(@driver.window_handle) #핸들 주입
7389
- @driver.action.context_click(el).perform #우 클릭
7390
- sleep(1)
7391
- @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
7392
- sleep(1)
7393
- puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
7394
- rescue
7808
+ puts '-[√] 캡챠 해제 진행 중 (약 30~60 초 소요됩니다).......'.green
7809
+ begin
7810
+ @driver.find_element(:xpath, '//*[@data-state="ready"]').click #캡챠우회버튼
7811
+ rescue
7812
+ begin
7813
+ @driver.find_element(:xpath, '//*[@class="captcha-solver-image"]').click #캡챠우회버튼
7814
+ rescue
7815
+ begin
7816
+ @driver.find_element(:xpath, '//*[@class="captcha-solver-info"]').click #캡챠우회버튼
7817
+ rescue
7818
+ begin
7819
+ @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]').click #캡챠우회버튼
7820
+ rescue
7821
+ end
7822
+ end
7823
+ end
7824
+ end
7825
+
7826
+
7827
+ sleep(10)
7828
+ begin
7829
+ @driver.find_element(:xpath, '//*[@data-state="error"]').click
7830
+ puts '-[√] 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
7831
+ puts '-[√] 캡챠 해제 실패 !! API번호 및 포인트를 체크해주세요.......'.red
7832
+ @driver.window_handles.each do |handle|
7833
+ @driver.switch_to.window(handle)
7834
+ begin
7835
+ # 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
7836
+ @driver.close
7837
+ rescue Selenium::WebDriver::Error::WebDriverError => e
7838
+ puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
7839
+ end
7840
+ end
7841
+ return 0
7842
+ @driver.quit
7843
+ rescue
7844
+ # 타임아웃을 77초로 설정
7845
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
7846
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
7847
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
7848
+ sleep(1)
7849
+ @driver.find_element(:xpath, '//*[@data-state="solved"]').click
7850
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
7851
+ sleep(3)
7852
+ begin
7853
+ @driver.find_element(:xpath, '//*[@name="user_captcha"]').click
7854
+ sleep(1)
7855
+ @driver.action.key_down(:right).key_up(:right).perform
7856
+ rescue
7857
+ begin
7858
+ @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
7859
+ sleep(1)
7860
+ @driver.action.key_down(:right).key_up(:right).perform
7861
+ rescue
7862
+ begin
7863
+ @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
7864
+ sleep(1)
7865
+ @driver.action.key_down(:right).key_up(:right).perform
7866
+ rescue
7867
+ end
7868
+ end
7869
+ end
7870
+ sleep(1)
7871
+ end
7872
+ rescue
7873
+
7874
+ end
7875
+ else
7876
+ end
7877
+
7878
+ if check_captcha == 0
7879
+ puts'캡챠 유무 확인.......'.yellow
7395
7880
  begin
7396
7881
  @driver.switch_to.default_content()
7397
- #@driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7398
- el = @driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7882
+ #@driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7883
+ el = @driver.find_element(:xpath, '//*[@id="mb_kcaptcha"]')
7399
7884
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7400
7885
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7401
- puts '-[√] 챕챠 코드 code 2.......'.red
7886
+ puts '-[√] 챕챠 코드 code 1.......'.red
7402
7887
  sleep(1)
7403
7888
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7404
7889
  sleep(1)
@@ -7415,18 +7900,11 @@ rescue
7415
7900
  rescue
7416
7901
  begin
7417
7902
  @driver.switch_to.default_content()
7418
- sleep(1)
7419
- #@driver.find_element(:xpath, '//*[@id="captcha_img"]').send_keys(:tab)
7420
- el = @driver.find_element(:xpath, '//*[@id="captcha_img"]')
7903
+ #@driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7904
+ el = @driver.find_element(:xpath, '//*[@alt="자동등록방지"]')
7421
7905
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7422
7906
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7423
- puts '-[√] 챕챠 코드 code 3.......'.red
7424
- sleep(1)
7425
- #요소 자체 제거 하기 기능
7426
- chat_box = @driver.find_element(:xpath, '//*[@for="captcha_key"]')
7427
- @driver.execute_script("arguments[0].remove();", chat_box)
7428
- sleep(1)
7429
-
7907
+ puts '-[√] 챕챠 코드 code 2.......'.red
7430
7908
  sleep(1)
7431
7909
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7432
7910
  sleep(1)
@@ -7443,11 +7921,17 @@ rescue
7443
7921
  rescue
7444
7922
  begin
7445
7923
  @driver.switch_to.default_content()
7446
- #@driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7447
- el = @driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7924
+ #@driver.find_element(:xpath, '//*[@id="captcha_img"]').send_keys(:tab)
7925
+ el = @driver.find_element(:xpath, '//*[@id="captcha_img"]')
7448
7926
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7449
7927
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7450
- puts '-[√] 챕챠 코드 code 4.......'.red
7928
+ puts '-[√] 챕챠 코드 code 3.......'.red
7929
+ sleep(1)
7930
+ #요소 자체 제거 하기 기능
7931
+ chat_box = @driver.find_element(:xpath, '//*[@for="captcha_key"]')
7932
+ @driver.execute_script("arguments[0].remove();", chat_box)
7933
+ sleep(1)
7934
+
7451
7935
  sleep(1)
7452
7936
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7453
7937
  sleep(1)
@@ -7464,15 +7948,11 @@ rescue
7464
7948
  rescue
7465
7949
  begin
7466
7950
  @driver.switch_to.default_content()
7467
- @driver.find_elements(:tag_name, 'img').each do |img|
7468
- if img.attribute('src').include?('kboard_captcha')
7469
- el = img # 캡챠 이미지를 el에 저장
7470
- break # 첫 번째 이미지를 찾으면 루프 종료
7471
- end
7472
- end
7951
+ #@driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7952
+ el = @driver.find_element(:xpath, '//*[@id="kcaptcha"]')
7473
7953
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7474
7954
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7475
- puts '-[√] 챕챠 코드 code 5-1.......'.red
7955
+ puts '-[√] 챕챠 코드 code 4.......'.red
7476
7956
  sleep(1)
7477
7957
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7478
7958
  sleep(1)
@@ -7489,11 +7969,10 @@ rescue
7489
7969
  rescue
7490
7970
  begin
7491
7971
  @driver.switch_to.default_content()
7492
- #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
7493
- el = @driver.find_element(:css, 'label[for="kboard-input-captcha"] img')
7972
+ el = @driver.find_element(:xpath, '//img[contains(@src, "kboard_captcha")]')
7494
7973
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7495
7974
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7496
- puts '-[√] 챕챠 코드 code 5-2.......'.red
7975
+ puts '-[√] 챕챠 코드 code 5-1.......'.red
7497
7976
  sleep(1)
7498
7977
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7499
7978
  sleep(1)
@@ -7510,12 +7989,11 @@ rescue
7510
7989
  rescue
7511
7990
  begin
7512
7991
  @driver.switch_to.default_content()
7513
- sleep(1)
7514
- #@driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7515
- el = @driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7992
+ #@driver.find_element(:xpath, '//*[@for="kboard-input-captcha"]')
7993
+ el = @driver.find_element(:xpath, '//*[@for="kboard-input-captcha"] img')
7516
7994
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7517
7995
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7518
- puts '-[√] 챕챠 코드 code 6.......'.red
7996
+ puts '-[√] 챕챠 코드 code 5-2.......'.red
7519
7997
  sleep(1)
7520
7998
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7521
7999
  sleep(1)
@@ -7532,11 +8010,12 @@ rescue
7532
8010
  rescue
7533
8011
  begin
7534
8012
  @driver.switch_to.default_content()
7535
- #@driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
7536
- el = @driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
8013
+ sleep(1)
8014
+ #@driver.find_element(:xpath, '//*[@id="captcha_Write"]')
8015
+ el = @driver.find_element(:xpath, '//*[@id="captcha_Write"]')
7537
8016
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7538
8017
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7539
- puts '-[√] 챕챠 코드 code 7.......'.red
8018
+ puts '-[√] 챕챠 코드 code 6.......'.red
7540
8019
  sleep(1)
7541
8020
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7542
8021
  sleep(1)
@@ -7553,11 +8032,11 @@ rescue
7553
8032
  rescue
7554
8033
  begin
7555
8034
  @driver.switch_to.default_content()
7556
- #@driver.find_element(:xpath, '//*[@id="spamauth"]')
7557
- el = @driver.find_element(:xpath, '//*[@id="spamauth"]')
8035
+ #@driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
8036
+ el = @driver.find_element(:xpath, '//*[@image-reader="in-progress"]')
7558
8037
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7559
8038
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7560
- puts '-[√] 챕챠 코드 code 8.......'.red
8039
+ puts '-[√] 챕챠 코드 code 7.......'.red
7561
8040
  sleep(1)
7562
8041
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7563
8042
  sleep(1)
@@ -7574,11 +8053,11 @@ rescue
7574
8053
  rescue
7575
8054
  begin
7576
8055
  @driver.switch_to.default_content()
7577
- #@driver.find_element(:xpath, '//*[@id="norobot_img"]')
7578
- el = @driver.find_element(:xpath, '//*[@id="norobot_img"]')
8056
+ #@driver.find_element(:xpath, '//*[@id="spamauth"]')
8057
+ el = @driver.find_element(:xpath, '//*[@id="spamauth"]')
7579
8058
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7580
8059
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7581
- puts '-[√] 챕챠 코드 code 9.......'.red
8060
+ puts '-[√] 챕챠 코드 code 8.......'.red
7582
8061
  sleep(1)
7583
8062
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7584
8063
  sleep(1)
@@ -7595,10 +8074,11 @@ rescue
7595
8074
  rescue
7596
8075
  begin
7597
8076
  @driver.switch_to.default_content()
7598
- el = @driver.find_element(:xpath, '//*[@class="CodeImage"]')
8077
+ #@driver.find_element(:xpath, '//*[@id="norobot_img"]')
8078
+ el = @driver.find_element(:xpath, '//*[@id="norobot_img"]')
7599
8079
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7600
8080
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7601
- puts '-[√] 챕챠 코드 code 10.......'.red
8081
+ puts '-[√] 챕챠 코드 code 9.......'.red
7602
8082
  sleep(1)
7603
8083
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7604
8084
  sleep(1)
@@ -7615,10 +8095,10 @@ rescue
7615
8095
  rescue
7616
8096
  begin
7617
8097
  @driver.switch_to.default_content()
7618
- el = @driver.find_element(:xpath, '//*[@id="kcaptcha_image"]')
8098
+ el = @driver.find_element(:xpath, '//*[@class="CodeImage"]')
7619
8099
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7620
8100
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7621
- puts '-[√] 챕챠 코드 code 11.......'.red
8101
+ puts '-[√] 챕챠 코드 code 10.......'.red
7622
8102
  sleep(1)
7623
8103
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7624
8104
  sleep(1)
@@ -7635,10 +8115,10 @@ rescue
7635
8115
  rescue
7636
8116
  begin
7637
8117
  @driver.switch_to.default_content()
7638
- el = @driver.find_element(:xpath, '//*[@class="lazy-loaded"]')
8118
+ el = @driver.find_element(:xpath, '//*[@id="kcaptcha_image"]')
7639
8119
  puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
7640
8120
  puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
7641
- puts '-[√] 챕챠 코드 code 12.......'.red
8121
+ puts '-[√] 챕챠 코드 code 11.......'.red
7642
8122
  sleep(1)
7643
8123
  @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
7644
8124
  sleep(1)
@@ -7653,72 +8133,51 @@ rescue
7653
8133
  sleep(1)
7654
8134
  puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
7655
8135
  rescue
7656
-
7657
- end
7658
- end
7659
-
7660
- end
7661
- end
7662
- end
7663
- end
7664
- end
7665
- end
7666
- end
7667
-
7668
- end
7669
- end
7670
- end
7671
- end
7672
- ##캡챠 이미지,2캡챠,,등등 코드 부분─────────────────────────────────────────────────────────────────────>
7673
-
7674
- sleep(1)
7675
-
7676
- ##캡챠 해제 입력 코드 부분─────────────────────────────────────────────────────────────────────>
7677
- puts '-[√] 캡챠 입력 항목 탐색.......'.green
7678
- begin
7679
- @driver.find_element(:xpath, '//*[@name="captcha_key"]').click
7680
-
7681
- sleep(1)
7682
-
7683
- el2 = @driver.find_element(:xpath, '//*[@name="captcha_key"]')
7684
- @driver.action.context_click(el2).perform
7685
- sleep(1)
7686
- @driver.action.key_stroke('up')
7687
- sleep(1)
7688
- @driver.action.key_stroke('up')
7689
- sleep(1)
7690
- @driver.action.key_stroke('enter')
7691
- sleep(1)
8136
+ begin
8137
+ @driver.switch_to.default_content()
8138
+ el = @driver.find_element(:xpath, '//*[@class="lazy-loaded"]')
8139
+ puts '-[√] 캡챠 발견!! 캡차 해제를 위한 환경설정 약 10초 소요.......'.red
8140
+ puts '-[√] 챕챠 해제 중~ 해제 완료까지 마우스 움직이지 마세요.......'.red
8141
+ puts '-[√] 챕챠 코드 code 12.......'.red
8142
+ sleep(1)
8143
+ @driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center', inline: 'center'});", el) # 화면 가운데
8144
+ sleep(1)
8145
+ mouse_move_percentage(0.3,0.02)
8146
+ sleep(0.5)
8147
+ left_click
8148
+ sleep(1)
8149
+ @driver.switch_to.window(@driver.window_handle) #핸들 주입
8150
+ @driver.action.context_click(el).perform #우 클릭
8151
+ sleep(1)
8152
+ @driver.action.key_down(:shift).key_stroke('m').key_up(:shift).perform #단축키
8153
+ sleep(1)
8154
+ puts '-[√] 캡챠 코드 타겟 완료1.......'.blue
8155
+ rescue
8156
+
8157
+ end
8158
+ end
8159
+ end
8160
+ end
8161
+ end
8162
+ end
8163
+ end
8164
+ end
8165
+ end
8166
+ end
8167
+ end
8168
+ end
8169
+ end
7692
8170
 
7693
- begin
7694
- # 요소 찾기 타임아웃을 7초로 설정
7695
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7696
- #요소가 나타날 때까지 7초 동안 기다립니다.
7697
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7698
- rescue
7699
- sleep(1)
7700
- @driver.action.key_stroke('left')
7701
- sleep(1)
7702
- @driver.action.key_stroke('up')
7703
- sleep(1)
7704
- @driver.action.key_stroke('enter')
7705
- sleep(1)
7706
- # 요소 찾기 타임아웃을 7초로 설정
7707
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7708
- #요소가 나타날 때까지 7초 동안 기다립니다.
7709
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7710
- end
7711
- puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
7712
8171
  sleep(1)
7713
- rescue
8172
+
8173
+ puts '-[√] 캡챠 입력 항목 탐색.......'.green
7714
8174
  begin
7715
- @driver.find_element(:xpath, '//*[@id="captcha_key"]').click
7716
-
7717
- sleep(1)
8175
+ @driver.find_element(:xpath, '//*[@name="captcha_key"]').click
7718
8176
 
7719
- el2 = @driver.find_element(:xpath, '//*[@id="captcha_key"]')
8177
+ sleep(1)
8178
+
8179
+ el2 = @driver.find_element(:xpath, '//*[@name="captcha_key"]')
7720
8180
  @driver.action.context_click(el2).perform
7721
-
7722
8181
  sleep(1)
7723
8182
  @driver.action.key_stroke('up')
7724
8183
  sleep(1)
@@ -7726,33 +8185,34 @@ rescue
7726
8185
  sleep(1)
7727
8186
  @driver.action.key_stroke('enter')
7728
8187
  sleep(1)
8188
+
7729
8189
  begin
7730
- # 요소 찾기 타임아웃을 7초로 설정
7731
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7732
- #요소가 나타날 때까지 7초 동안 기다립니다.
7733
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7734
- rescue
7735
- sleep(1)
7736
- @driver.action.key_stroke('left')
7737
- sleep(1)
7738
- @driver.action.key_stroke('up')
7739
- sleep(1)
7740
- @driver.action.key_stroke('enter')
7741
- sleep(1)
7742
- # 요소 찾기 타임아웃을 7초로 설정
7743
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7744
- #요소가 나타날 때까지 7초 동안 기다립니다.
7745
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7746
- end
8190
+ # 요소 찾기 타임아웃을 7초로 설정
8191
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8192
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8193
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8194
+ rescue
8195
+ sleep(1)
8196
+ @driver.action.key_stroke('left')
8197
+ sleep(1)
8198
+ @driver.action.key_stroke('up')
8199
+ sleep(1)
8200
+ @driver.action.key_stroke('enter')
8201
+ sleep(1)
8202
+ # 요소 찾기 타임아웃을 7초로 설정
8203
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8204
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8205
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8206
+ end
7747
8207
  puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
7748
8208
  sleep(1)
7749
8209
  rescue
7750
8210
  begin
7751
- @driver.find_element(:xpath, '=//*[@id="code"]').click
7752
-
8211
+ @driver.find_element(:xpath, '//*[@id="captcha_key"]').click
8212
+
7753
8213
  sleep(1)
7754
-
7755
- el2 = @driver.find_element(:xpath, '//*[@id="code"]')
8214
+
8215
+ el2 = @driver.find_element(:xpath, '//*[@id="captcha_key"]')
7756
8216
  @driver.action.context_click(el2).perform
7757
8217
 
7758
8218
  sleep(1)
@@ -7784,11 +8244,11 @@ rescue
7784
8244
  sleep(1)
7785
8245
  rescue
7786
8246
  begin
7787
- @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]').click
7788
-
8247
+ @driver.find_element(:xpath, '=//*[@id="code"]').click
8248
+
7789
8249
  sleep(1)
7790
8250
 
7791
- el2 = @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]')
8251
+ el2 = @driver.find_element(:xpath, '//*[@id="code"]')
7792
8252
  @driver.action.context_click(el2).perform
7793
8253
 
7794
8254
  sleep(1)
@@ -7820,13 +8280,13 @@ rescue
7820
8280
  sleep(1)
7821
8281
  rescue
7822
8282
  begin
7823
- @driver.find_element(:xpath, '//*[@fw-label="보안문자"]').click
7824
-
8283
+ @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]').click
8284
+
7825
8285
  sleep(1)
7826
-
7827
- el2 = @driver.find_element(:xpath, '//*[@fw-label="보안문자"]')
8286
+
8287
+ el2 = @driver.find_element(:xpath, '//*[@id="kboard-input-captcha"]')
7828
8288
  @driver.action.context_click(el2).perform
7829
-
8289
+
7830
8290
  sleep(1)
7831
8291
  @driver.action.key_stroke('up')
7832
8292
  sleep(1)
@@ -7856,23 +8316,24 @@ rescue
7856
8316
  sleep(1)
7857
8317
  rescue
7858
8318
  begin
7859
- @driver.find_element(:xpath, '//*[@name="captcha"]').click
8319
+ @driver.find_element(:xpath, '//*[@fw-label="보안문자"]').click
8320
+
7860
8321
  sleep(1)
7861
-
7862
- # CAPTCHA 요소 찾기
7863
- el2 = @driver.find_element(:xpath, '//*[@name="captcha"]')
7864
-
7865
- # 우클릭 (context_click) 실행
8322
+
8323
+ el2 = @driver.find_element(:xpath, '//*[@fw-label="보안문자"]')
7866
8324
  @driver.action.context_click(el2).perform
8325
+
7867
8326
  sleep(1)
7868
8327
  @driver.action.key_stroke('up')
7869
8328
  sleep(1)
7870
8329
  @driver.action.key_stroke('up')
7871
8330
  sleep(1)
7872
8331
  @driver.action.key_stroke('enter')
8332
+ sleep(1)
7873
8333
  begin
8334
+ # 요소 찾기 타임아웃을 7초로 설정
7874
8335
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7875
- # 요소가 나타날 때까지 7초 동안 기다립니다.
8336
+ #요소가 나타날 때까지 7초 동안 기다립니다.
7876
8337
  wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7877
8338
  rescue
7878
8339
  sleep(1)
@@ -7891,24 +8352,23 @@ rescue
7891
8352
  sleep(1)
7892
8353
  rescue
7893
8354
  begin
7894
- @driver.find_element(:xpath, '//*[@id="spamCode"]').click
7895
-
8355
+ @driver.find_element(:xpath, '//*[@name="captcha"]').click
7896
8356
  sleep(1)
7897
-
7898
- el2 = @driver.find_element(:xpath, '//*[@id="spamCode"]')
8357
+
8358
+ # CAPTCHA 요소 찾기
8359
+ el2 = @driver.find_element(:xpath, '//*[@name="captcha"]')
8360
+
8361
+ # 우클릭 (context_click) 실행
7899
8362
  @driver.action.context_click(el2).perform
7900
-
7901
8363
  sleep(1)
7902
8364
  @driver.action.key_stroke('up')
7903
8365
  sleep(1)
7904
8366
  @driver.action.key_stroke('up')
7905
8367
  sleep(1)
7906
8368
  @driver.action.key_stroke('enter')
7907
- sleep(1)
7908
8369
  begin
7909
- # 요소 찾기 타임아웃을 7초로 설정
7910
8370
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7911
- #요소가 나타날 때까지 7초 동안 기다립니다.
8371
+ # 요소가 나타날 때까지 7초 동안 기다립니다.
7912
8372
  wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7913
8373
  rescue
7914
8374
  sleep(1)
@@ -7927,13 +8387,14 @@ rescue
7927
8387
  sleep(1)
7928
8388
  rescue
7929
8389
  begin
7930
- @driver.find_element(:xpath, '//*[@id="norobot_code"]').click
7931
-
8390
+ @driver.find_element(:xpath, '//*[@id="spamCode"]').click
8391
+
7932
8392
  sleep(1)
7933
-
7934
- el2 = @driver.find_element(:xpath, '//*[@id="norobot_code"]')
8393
+
8394
+ el2 = @driver.find_element(:xpath, '//*[@id="spamCode"]')
7935
8395
  @driver.action.context_click(el2).perform
7936
-
8396
+
8397
+ sleep(1)
7937
8398
  @driver.action.key_stroke('up')
7938
8399
  sleep(1)
7939
8400
  @driver.action.key_stroke('up')
@@ -7962,53 +8423,50 @@ rescue
7962
8423
  sleep(1)
7963
8424
  rescue
7964
8425
  begin
7965
- @driver.switch_to.default_content()
7966
- sleep(1)
7967
- @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]').click
7968
-
7969
- sleep(1)
8426
+ @driver.find_element(:xpath, '//*[@id="norobot_code"]').click
7970
8427
 
7971
- el2 = @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]')
7972
- @driver.action.context_click(el2).perform
7973
-
8428
+ sleep(1)
8429
+
8430
+ el2 = @driver.find_element(:xpath, '//*[@id="norobot_code"]')
8431
+ @driver.action.context_click(el2).perform
8432
+
8433
+ @driver.action.key_stroke('up')
8434
+ sleep(1)
8435
+ @driver.action.key_stroke('up')
8436
+ sleep(1)
8437
+ @driver.action.key_stroke('enter')
8438
+ sleep(1)
8439
+ begin
8440
+ # 요소 찾기 타임아웃을 7초로 설정
8441
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8442
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8443
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8444
+ rescue
7974
8445
  sleep(1)
7975
- @driver.action.key_stroke('up')
8446
+ @driver.action.key_stroke('left')
7976
8447
  sleep(1)
7977
8448
  @driver.action.key_stroke('up')
7978
8449
  sleep(1)
7979
8450
  @driver.action.key_stroke('enter')
7980
- sleep(1)
7981
- begin
7982
- # 요소 찾기 타임아웃을 7초로 설정
7983
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7984
- #요소가 나타날 때까지 7초 동안 기다립니다.
7985
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7986
- rescue
7987
- sleep(1)
7988
- @driver.action.key_stroke('left')
7989
- sleep(1)
7990
- @driver.action.key_stroke('up')
7991
- sleep(1)
7992
- @driver.action.key_stroke('enter')
7993
- sleep(1)
7994
- # 요소 찾기 타임아웃을 7초로 설정
7995
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
7996
- #요소가 나타날 때까지 7초 동안 기다립니다.
7997
- wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
7998
- end
7999
- puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8000
- sleep(1)
8451
+ sleep(1)
8452
+ # 요소 찾기 타임아웃을 7초로 설정
8453
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8454
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8455
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8456
+ end
8457
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8458
+ sleep(1)
8001
8459
  rescue
8002
8460
  begin
8003
8461
  @driver.switch_to.default_content()
8004
8462
  sleep(1)
8005
- @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
8006
-
8463
+ @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]').click
8464
+
8007
8465
  sleep(1)
8008
8466
 
8009
- el2 = @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]')
8467
+ el2 = @driver.find_element(:xpath, '//*[@name="kcaptcha_code"]')
8010
8468
  @driver.action.context_click(el2).perform
8011
-
8469
+
8012
8470
  sleep(1)
8013
8471
  @driver.action.key_stroke('up')
8014
8472
  sleep(1)
@@ -8040,13 +8498,13 @@ rescue
8040
8498
  begin
8041
8499
  @driver.switch_to.default_content()
8042
8500
  sleep(1)
8043
- @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
8044
-
8501
+ @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]').click
8502
+
8045
8503
  sleep(1)
8046
8504
 
8047
- el2 = @driver.find_element(:xpath, '//*[@id="user_captcha"]')
8505
+ el2 = @driver.find_element(:xpath, '//*[@title="자동글쓰기방지"]')
8048
8506
  @driver.action.context_click(el2).perform
8049
-
8507
+
8050
8508
  sleep(1)
8051
8509
  @driver.action.key_stroke('up')
8052
8510
  sleep(1)
@@ -8078,13 +8536,13 @@ rescue
8078
8536
  begin
8079
8537
  @driver.switch_to.default_content()
8080
8538
  sleep(1)
8081
- @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]').click
8082
-
8539
+ @driver.find_element(:xpath, '//*[@id="user_captcha"]').click
8540
+
8083
8541
  sleep(1)
8084
8542
 
8085
- el2 = @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]')
8543
+ el2 = @driver.find_element(:xpath, '//*[@id="user_captcha"]')
8086
8544
  @driver.action.context_click(el2).perform
8087
-
8545
+
8088
8546
  sleep(1)
8089
8547
  @driver.action.key_stroke('up')
8090
8548
  sleep(1)
@@ -8116,13 +8574,13 @@ rescue
8116
8574
  begin
8117
8575
  @driver.switch_to.default_content()
8118
8576
  sleep(1)
8119
- @driver.find_element(:xpath, '//*[@name="wr_key"]').click
8120
-
8577
+ @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]').click
8578
+
8121
8579
  sleep(1)
8122
8580
 
8123
- el2 = @driver.find_element(:xpath, '//*[@name="wr_key"]')
8581
+ el2 = @driver.find_element(:xpath, '//*[@itemname="자동등록방지"]')
8124
8582
  @driver.action.context_click(el2).perform
8125
-
8583
+
8126
8584
  sleep(1)
8127
8585
  @driver.action.key_stroke('up')
8128
8586
  sleep(1)
@@ -8151,7 +8609,124 @@ rescue
8151
8609
  puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8152
8610
  sleep(1)
8153
8611
  rescue
8612
+ begin
8613
+ @driver.switch_to.default_content()
8614
+ sleep(1)
8615
+ @driver.find_element(:xpath, '//*[@name="wr_key"]').click
8616
+
8617
+ sleep(1)
8618
+
8619
+ el2 = @driver.find_element(:xpath, '//*[@name="wr_key"]')
8620
+ @driver.action.context_click(el2).perform
8621
+
8622
+ sleep(1)
8623
+ @driver.action.key_stroke('up')
8624
+ sleep(1)
8625
+ @driver.action.key_stroke('up')
8626
+ sleep(1)
8627
+ @driver.action.key_stroke('enter')
8628
+ sleep(1)
8629
+ begin
8630
+ # 요소 찾기 타임아웃을 7초로 설정
8631
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8632
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8633
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8634
+ rescue
8635
+ sleep(1)
8636
+ @driver.action.key_stroke('left')
8637
+ sleep(1)
8638
+ @driver.action.key_stroke('up')
8639
+ sleep(1)
8640
+ @driver.action.key_stroke('enter')
8641
+ sleep(1)
8642
+ # 요소 찾기 타임아웃을 7초로 설정
8643
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8644
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8645
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8646
+ end
8647
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8648
+ sleep(1)
8649
+ rescue
8650
+ begin
8651
+ @driver.switch_to.default_content()
8652
+ sleep(1)
8653
+ @driver.find_element(:xpath, '//*[@title="자동등록방지"]').click
8154
8654
 
8655
+ sleep(1)
8656
+
8657
+ el2 = @driver.find_element(:xpath, '//*[@title="자동등록방지"]')
8658
+ @driver.action.context_click(el2).perform
8659
+
8660
+ sleep(1)
8661
+ @driver.action.key_stroke('up')
8662
+ sleep(1)
8663
+ @driver.action.key_stroke('up')
8664
+ sleep(1)
8665
+ @driver.action.key_stroke('enter')
8666
+ sleep(1)
8667
+ begin
8668
+ # 요소 찾기 타임아웃을 7초로 설정
8669
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8670
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8671
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8672
+ rescue
8673
+ sleep(1)
8674
+ @driver.action.key_stroke('left')
8675
+ sleep(1)
8676
+ @driver.action.key_stroke('up')
8677
+ sleep(1)
8678
+ @driver.action.key_stroke('enter')
8679
+ sleep(1)
8680
+ # 요소 찾기 타임아웃을 7초로 설정
8681
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8682
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8683
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8684
+ end
8685
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8686
+ sleep(1)
8687
+ rescue
8688
+ begin
8689
+ @driver.switch_to.default_content()
8690
+ sleep(1)
8691
+ @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]').click
8692
+
8693
+ sleep(1)
8694
+
8695
+ el2 = @driver.find_element(:xpath, '//input[@name="kcaptcha_img"]')
8696
+ @driver.action.context_click(el2).perform
8697
+
8698
+ sleep(1)
8699
+ @driver.action.key_stroke('up')
8700
+ sleep(1)
8701
+ @driver.action.key_stroke('up')
8702
+ sleep(1)
8703
+ @driver.action.key_stroke('enter')
8704
+ sleep(1)
8705
+ begin
8706
+ # 요소 찾기 타임아웃을 7초로 설정
8707
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8708
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8709
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8710
+ rescue
8711
+ sleep(1)
8712
+ @driver.action.key_stroke('left')
8713
+ sleep(1)
8714
+ @driver.action.key_stroke('up')
8715
+ sleep(1)
8716
+ @driver.action.key_stroke('enter')
8717
+ sleep(1)
8718
+ # 요소 찾기 타임아웃을 7초로 설정
8719
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
8720
+ #요소가 나타날 때까지 7초 동안 기다립니다.
8721
+ wait.until { @driver.find_element(:xpath, '//*[@class="captcha-solver captcha-solver_inner"]') }
8722
+ end
8723
+ puts '-[√] 캡챠 코드 타겟 완료2.......'.blue
8724
+ sleep(1)
8725
+ rescue
8726
+
8727
+ end
8728
+ end
8729
+ end
8155
8730
  end
8156
8731
  end
8157
8732
  end
@@ -8163,9 +8738,8 @@ rescue
8163
8738
  end
8164
8739
  end
8165
8740
  end
8166
- end
8167
- end
8168
- ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
8741
+ end
8742
+
8169
8743
 
8170
8744
 
8171
8745
 
@@ -8259,7 +8833,8 @@ end
8259
8833
 
8260
8834
 
8261
8835
 
8262
-
8836
+ else
8837
+ end
8263
8838
 
8264
8839
 
8265
8840
 
@@ -8287,7 +8862,7 @@ sleep(1)
8287
8862
 
8288
8863
 
8289
8864
  ##등록 버튼 코드 부분─────────────────────────────────────────────────────────────────────>
8290
- puts '-[√] HTML 버튼 복구 여부 체크.......'.yellow
8865
+
8291
8866
  begin
8292
8867
  @driver.find_element(:xpath, '//*[@aria-label="코드 보기"]')
8293
8868
  sleep(1)
@@ -8312,7 +8887,7 @@ rescue
8312
8887
  @driver.find_element(:xpath, '//*[@title="에디터 타입"]').click
8313
8888
  sleep(1)
8314
8889
  rescue
8315
- puts '-[√] HTML 버튼 복구 여부 체크 종료.......'.yellow
8890
+
8316
8891
  end
8317
8892
  end
8318
8893
  end
@@ -8493,6 +9068,8 @@ rescue
8493
9068
  sleep(1)
8494
9069
 
8495
9070
  @driver.find_element(:xpath, '//*[@form="write"]').click
9071
+ sleep(1)
9072
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
8496
9073
  puts '-[√] 등록을 19번 코드로 시도하였습니다.......'.magenta
8497
9074
  sleep(5)
8498
9075
 
@@ -8914,7 +9491,6 @@ end
8914
9491
 
8915
9492
 
8916
9493
 
8917
-
8918
9494
  class Wordpress
8919
9495
  include Glimmer
8920
9496
  def get_mac_address
@@ -8941,39 +9517,6 @@ class Wordpress
8941
9517
  end
8942
9518
  end
8943
9519
 
8944
- # def get_naver_text(q)
8945
- # begin
8946
- # Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
8947
- # @driver = Selenium::WebDriver.for :chrome
8948
- # rescue
8949
- # @driver = Selenium::WebDriver.for :chrome
8950
- # end
8951
- # @driver.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page=3&query='+q.to_s+'&research_url=&sm=tab_pge&start=16&where=web')
8952
- # noko = Nokogiri::HTML(@driver.page_source)
8953
- # tt = noko.xpath('//*[@id="main_pack"]/section/div/ul').text
8954
- # aa33 = '하였습니다,하였어요,하게됬어요,했답니다,했었는데요,하게되었어요,했어요,그랬답니다,그랬어요,합니다,그랬어요,그랬답니다,그랬답니다,그러합니다,좋아요,좋습니다,됬어요,되었어요,되었답니다,되었구요,되었어요,되네요,하네요,해요,할거예요,할수었이요,입니다,인데요,이예요,이랍니다,이였어요,그랬어요,그랬거든요,그랬습니다,었어요,었습니다,있었어요'.split(',')
8955
- # for page in 3..8
8956
- # @driver.get('https://www.google.com/search?q='+q.to_s+'&start='+(page*10).to_s)
8957
- # noko = Nokogiri::HTML(@driver.page_source)
8958
- # for n in 1..15
8959
- # tt2 = noko.xpath('//*[@id="rso"]/div['+n.to_s+']/div/div/div[2]/div').text
8960
- # if tt2.length < 5
8961
-
8962
- # else
8963
- # tt2 = tt2.split('...').join('')+aa3.sample
8964
- # tt += tt2
8965
- # end
8966
- # end
8967
- # end
8968
- # @driver.close
8969
- # tt = tt.split(' ').shuffle.join(' ')[0..1000]
8970
- # m = Array.new
8971
- # for n in 0..19
8972
- # m << tt[(n*100)..(n*100+100)]
8973
- # end
8974
- # return m.join("\n")
8975
- # end
8976
-
8977
9520
  def get_naver_text(q)
8978
9521
  puts '자동 글 생성을 시작합니다.......'.green
8979
9522
  text_array = Array.new
@@ -9350,64 +9893,36 @@ class Wordpress
9350
9893
  puts table[10]
9351
9894
  if table[8].to_i > table[10].to_i
9352
9895
  if @data['포스트설정']['테더링'].checked?
9353
- puts 'Tethering IP change...'
9354
-
9896
+ puts 'tedering ip change...'
9355
9897
  stdout, stderr, status = Open3.capture3('./adb devices')
9356
-
9357
9898
  if status.success?
9358
- device_id = stdout.split("\n")[1].split("\t")[0]
9359
- puts device_id
9360
-
9361
- # ADB 서버 초기화
9362
- puts 'adb kill-server'
9363
- Open3.capture3('./adb kill-server')
9364
- sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
9365
-
9366
- # 다시 ADB 서버 실행
9367
- puts 'adb start-server'
9368
- Open3.capture3('./adb start-server')
9369
- sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
9370
-
9371
- # 데이터를 끄고 켜기
9372
- puts 'adb -s ' + device_id + ' shell svc data disable'
9373
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
9374
- puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
9375
- sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
9376
- puts 'adb -s ' + device_id + ' shell svc data enable'
9377
- stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
9378
- puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
9379
- sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
9380
- puts 'adb ok'
9381
- sleep(8)
9382
-
9383
- # IP 변경 확인을 위한 람다 함수
9384
- robot_ip = lambda do
9385
- begin
9386
- # IP 변경 확인
9387
- http = HTTP.get('https://www.findip.kr/')
9388
- noko = Nokogiri::HTML(http.to_s)
9389
-
9390
- current_ip = noko.xpath('/html/body/header/h2').text.strip
9391
- if current_ip != @my_ip
9392
- @my_ip = current_ip
9393
- puts "IP 변경됨[ #{@my_ip} ]"
9394
- else
9395
- puts "현재 IP: #{@my_ip}"
9396
- puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
9397
- sleep(5) # 여유롭게 대기 시간 증가
9398
- robot_ip[] # 재시도
9399
- end
9400
- rescue HTTP::ConnectionError => e
9401
- puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
9402
- sleep(5) # 재시도 간 여유 시간 추가
9403
- retry # 재시도
9899
+ device_id = stdout.split("\n")[1].split("\t")[0]
9900
+ puts device_id
9901
+ puts 'adb -s '+device_id+' shell svc data disable'
9902
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
9903
+ sleep(3)
9904
+ puts 'adb -s '+device_id+' shell svc data enable'
9905
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
9906
+ sleep(3)
9907
+ puts 'adb ok'
9908
+ sleep(8)
9909
+ robot_ip = lambda do
9910
+ http = HTTP.get('https://www.findip.kr/')
9911
+ noko = Nokogiri::HTML(http.to_s)
9912
+ if noko.xpath('/html/body/header/h2').text != @my_ip
9913
+ @my_ip = noko.xpath('/html/body/header/h2').text
9914
+ else
9915
+ puts @my_ip
9916
+ puts '재시도...'
9917
+ sleep(3)
9918
+ robot_ip[]
9919
+ end
9404
9920
  end
9405
- end
9406
- robot_ip[] # IP 확인 시작
9921
+ robot_ip[]
9407
9922
  else
9408
- puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
9923
+ puts 'adb error pass'
9409
9924
  end
9410
- end
9925
+ end
9411
9926
 
9412
9927
  check_success = 1
9413
9928
  @data['table'][index][-1] = 0
@@ -9485,7 +10000,7 @@ class Wordpress
9485
10000
  @data['table'].pop
9486
10001
 
9487
10002
  #네이버로그인
9488
- login_check = naver.login(option['proxy'])
10003
+ login_check = naver.login(option['proxy'],captcha_key)
9489
10004
  if login_check == 0
9490
10005
  black_users << table[1].to_s
9491
10006
  next