cafe_basics 0.0.57 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cafe_basics.rb +73 -36
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad4f7a53e1b546e0244461f472a88a9b99f8992c76f5091e24cdc5e6c3e72f90
|
4
|
+
data.tar.gz: b787f0ee128a6593d06bec033aab1dec9b9479f55c844ac9bb8f579f18a1535a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d072a3fd1b64a08d9a46245428df3d5c1ee82884355927479b13ebd9ae118652a13b3ee55a9f0cfef9c8987404f9a937c28c560f023b2c0c07f900befb9ba79e
|
7
|
+
data.tar.gz: 976d16e29a83f007f58c79279a4610dbe31655d32b942fcf9d8cc6b898d20fb473aa40cd908fada6c12559b29e88971ce0f04409f326918cfc5046746b67330c
|
data/lib/cafe_basics.rb
CHANGED
@@ -246,9 +246,13 @@ class Naver
|
|
246
246
|
naver_cookie_dir = "C:/naver_cookie"
|
247
247
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
248
248
|
if proxy == ''
|
249
|
-
|
249
|
+
|
250
|
+
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --no-first-run --no-default-browser-check --disable-sync})
|
251
|
+
|
250
252
|
else
|
251
|
-
|
253
|
+
|
254
|
+
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync})
|
255
|
+
|
252
256
|
end
|
253
257
|
end
|
254
258
|
def chrome_start(proxy, user_id)
|
@@ -260,6 +264,9 @@ class Naver
|
|
260
264
|
options = Selenium::WebDriver::Chrome::Options.new
|
261
265
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
262
266
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
267
|
+
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
268
|
+
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
269
|
+
options.add_argument('--no-default-browser-check')
|
263
270
|
options.page_load_strategy = :normal
|
264
271
|
options.timeouts = {page_load: 20_000}
|
265
272
|
options.page_load_strategy = 'none'
|
@@ -285,6 +292,9 @@ class Naver
|
|
285
292
|
options = Selenium::WebDriver::Chrome::Options.new
|
286
293
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
287
294
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
295
|
+
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
296
|
+
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
297
|
+
options.add_argument('--no-default-browser-check')
|
288
298
|
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
289
299
|
options.page_load_strategy = :normal
|
290
300
|
options.timeouts = {page_load: 20_000}
|
@@ -309,6 +319,9 @@ class Naver
|
|
309
319
|
options = Selenium::WebDriver::Chrome::Options.new
|
310
320
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
311
321
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
322
|
+
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
323
|
+
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
324
|
+
options.add_argument('--no-default-browser-check')
|
312
325
|
options.page_load_strategy = :normal
|
313
326
|
options.timeouts = {page_load: 20_000}
|
314
327
|
options.page_load_strategy = 'none'
|
@@ -333,6 +346,8 @@ class Naver
|
|
333
346
|
|
334
347
|
|
335
348
|
|
349
|
+
|
350
|
+
|
336
351
|
def login(user_id, user_pw, proxy)
|
337
352
|
@user_id = user_id
|
338
353
|
@user_id11 = user_id
|
@@ -371,13 +386,20 @@ class Naver
|
|
371
386
|
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
372
387
|
sleep(2.5)
|
373
388
|
rescue
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
389
|
+
begin
|
390
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
391
|
+
# 요소가 나타날 때까지 기다립니다.
|
392
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
|
393
|
+
sleep(1.5)
|
394
|
+
|
395
|
+
# 요소가 있으면 클릭
|
396
|
+
@driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
|
397
|
+
check_cookie_login = 0
|
398
|
+
sleep(1)
|
399
|
+
rescue
|
400
|
+
@driver.quit
|
401
|
+
return 0
|
402
|
+
end
|
381
403
|
end
|
382
404
|
|
383
405
|
if check_cookie_login == 0
|
@@ -412,8 +434,9 @@ class Naver
|
|
412
434
|
puts "Failed to close tab: #{e.message}"
|
413
435
|
end
|
414
436
|
end
|
415
|
-
return 0
|
416
437
|
@driver.quit
|
438
|
+
return 0
|
439
|
+
|
417
440
|
end
|
418
441
|
|
419
442
|
else
|
@@ -436,8 +459,9 @@ class Naver
|
|
436
459
|
puts "Failed to close tab: #{e.message}"
|
437
460
|
end
|
438
461
|
end
|
439
|
-
return 0
|
440
462
|
@driver.quit
|
463
|
+
return 0
|
464
|
+
|
441
465
|
end
|
442
466
|
end
|
443
467
|
|
@@ -763,8 +787,9 @@ class Naver
|
|
763
787
|
puts "Failed to close tab: #{e.message}"
|
764
788
|
end
|
765
789
|
end
|
766
|
-
|
767
|
-
|
790
|
+
@driver.quit
|
791
|
+
return 0
|
792
|
+
|
768
793
|
end
|
769
794
|
|
770
795
|
|
@@ -792,8 +817,9 @@ class Naver
|
|
792
817
|
puts "Failed to close tab: #{e.message}"
|
793
818
|
end
|
794
819
|
end
|
795
|
-
return 0
|
796
820
|
@driver.quit
|
821
|
+
return 0
|
822
|
+
|
797
823
|
end
|
798
824
|
sleep(2)
|
799
825
|
@driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
|
@@ -2179,7 +2205,7 @@ class Wordpress
|
|
2179
2205
|
puts 'Tethering IP change...'
|
2180
2206
|
|
2181
2207
|
stdout, stderr, status = Open3.capture3('./adb devices')
|
2182
|
-
|
2208
|
+
|
2183
2209
|
if status.success?
|
2184
2210
|
device_id = stdout.split("\n")[1].split("\t")[0]
|
2185
2211
|
puts device_id
|
@@ -2187,42 +2213,53 @@ class Wordpress
|
|
2187
2213
|
# ADB 서버 초기화
|
2188
2214
|
puts 'adb kill-server'
|
2189
2215
|
Open3.capture3('./adb kill-server')
|
2190
|
-
sleep(
|
2216
|
+
sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
|
2191
2217
|
|
2192
2218
|
# 다시 ADB 서버 실행
|
2193
2219
|
puts 'adb start-server'
|
2194
2220
|
Open3.capture3('./adb start-server')
|
2195
|
-
sleep(
|
2221
|
+
sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
|
2196
2222
|
|
2197
2223
|
# 데이터를 끄고 켜기
|
2198
2224
|
puts 'adb -s ' + device_id + ' shell svc data disable'
|
2199
|
-
stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
|
2200
|
-
|
2225
|
+
stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
|
2226
|
+
puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
|
2227
|
+
sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
|
2201
2228
|
puts 'adb -s ' + device_id + ' shell svc data enable'
|
2202
|
-
Open3.capture3('./adb -s '+device_id+' shell svc data enable')
|
2203
|
-
|
2229
|
+
stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
|
2230
|
+
puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
|
2231
|
+
sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
|
2204
2232
|
puts 'adb ok'
|
2205
2233
|
sleep(8)
|
2206
|
-
|
2234
|
+
|
2235
|
+
# IP 변경 확인을 위한 람다 함수
|
2207
2236
|
robot_ip = lambda do
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2237
|
+
begin
|
2238
|
+
# IP 변경 확인
|
2239
|
+
http = HTTP.get('https://www.findip.kr/')
|
2240
|
+
noko = Nokogiri::HTML(http.to_s)
|
2241
|
+
|
2242
|
+
current_ip = noko.xpath('/html/body/header/h2').text.strip
|
2243
|
+
if current_ip != @my_ip
|
2244
|
+
@my_ip = current_ip
|
2212
2245
|
puts "IP 변경됨[ #{@my_ip} ]"
|
2213
|
-
|
2214
|
-
puts @my_ip
|
2215
|
-
puts '
|
2216
|
-
sleep(
|
2217
|
-
robot_ip[]
|
2246
|
+
else
|
2247
|
+
puts "현재 IP: #{@my_ip}"
|
2248
|
+
puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
|
2249
|
+
sleep(5) # 여유롭게 대기 시간 증가
|
2250
|
+
robot_ip[] # 재시도
|
2251
|
+
end
|
2252
|
+
rescue HTTP::ConnectionError => e
|
2253
|
+
puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
|
2254
|
+
sleep(5) # 재시도 간 여유 시간 추가
|
2255
|
+
retry # 재시도
|
2218
2256
|
end
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2257
|
+
end
|
2258
|
+
robot_ip[] # IP 확인 시작
|
2222
2259
|
else
|
2223
|
-
|
2260
|
+
puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
|
2224
2261
|
end
|
2225
|
-
|
2262
|
+
end
|
2226
2263
|
|
2227
2264
|
|
2228
2265
|
check_success = 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.70
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|