cafe_basics 0.0.59 → 0.0.72
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 +71 -29
- 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: e4dd58b908a30bd1095d4487525d083799dd02dc4702dd8e2319d57fbdfa7c4e
|
4
|
+
data.tar.gz: 478fb032646f928837e14467433af72d0a734113659e914d073a5858d69c2f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52dbfe596f01d104dc4be41d925c900714c0e287489a37e1084a65020a629ef835a4a0cbf91552ea0133326113cdc43cea2469f25a6a1204aa993463f443274
|
7
|
+
data.tar.gz: 5fea1449ab3b2a55c72039993b380864b99db8a97a5cdc1c11e671be3892219ceebc11789c3662c14faceff84fd48c2362d045438fa28740e652f3d61f4c045e
|
data/lib/cafe_basics.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
|
-
|
3
|
+
require 'webdrivers'
|
4
4
|
require 'iconv'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'http'
|
@@ -241,7 +241,28 @@ end
|
|
241
241
|
class Naver
|
242
242
|
def initialize
|
243
243
|
@seed = 1
|
244
|
+
|
245
|
+
begin
|
246
|
+
# webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
|
247
|
+
|
248
|
+
# Webdrivers가 드라이버를 다운로드할 경로를 설정
|
249
|
+
Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
|
250
|
+
Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
|
251
|
+
# 크롬드라이버 자동 업데이트 시도
|
252
|
+
Webdrivers::Chromedriver.update
|
253
|
+
puts "chromedriver 자동 다운로드 성공"
|
254
|
+
rescue => e
|
255
|
+
puts "chromedriver 자동 다운로드 실패: #{e.message}"
|
256
|
+
puts "폴더내 크롬드라이버를 사용합니다."
|
257
|
+
puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
|
258
|
+
puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
|
259
|
+
chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
|
260
|
+
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
261
|
+
end
|
262
|
+
|
244
263
|
end
|
264
|
+
|
265
|
+
|
245
266
|
def chrome_setup(user_id, proxy)
|
246
267
|
naver_cookie_dir = "C:/naver_cookie"
|
247
268
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
@@ -260,10 +281,9 @@ class Naver
|
|
260
281
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
261
282
|
if proxy == ''
|
262
283
|
begin
|
263
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
264
284
|
options = Selenium::WebDriver::Chrome::Options.new
|
265
285
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
266
|
-
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
286
|
+
#options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
267
287
|
options.add_argument('--disable-sync') # Chrome 동기화 비활성화
|
268
288
|
options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
|
269
289
|
options.add_argument('--no-default-browser-check')
|
@@ -288,7 +308,7 @@ class Naver
|
|
288
308
|
end
|
289
309
|
else
|
290
310
|
begin
|
291
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
311
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
292
312
|
options = Selenium::WebDriver::Chrome::Options.new
|
293
313
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
294
314
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -315,7 +335,7 @@ class Naver
|
|
315
335
|
puts e
|
316
336
|
puts 'proxy error...'
|
317
337
|
begin
|
318
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
338
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
319
339
|
options = Selenium::WebDriver::Chrome::Options.new
|
320
340
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
321
341
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -348,6 +368,7 @@ class Naver
|
|
348
368
|
|
349
369
|
|
350
370
|
|
371
|
+
|
351
372
|
def login(user_id, user_pw, proxy)
|
352
373
|
@user_id = user_id
|
353
374
|
@user_id11 = user_id
|
@@ -2205,7 +2226,7 @@ class Wordpress
|
|
2205
2226
|
puts 'Tethering IP change...'
|
2206
2227
|
|
2207
2228
|
stdout, stderr, status = Open3.capture3('./adb devices')
|
2208
|
-
|
2229
|
+
|
2209
2230
|
if status.success?
|
2210
2231
|
device_id = stdout.split("\n")[1].split("\t")[0]
|
2211
2232
|
puts device_id
|
@@ -2213,42 +2234,53 @@ class Wordpress
|
|
2213
2234
|
# ADB 서버 초기화
|
2214
2235
|
puts 'adb kill-server'
|
2215
2236
|
Open3.capture3('./adb kill-server')
|
2216
|
-
sleep(
|
2237
|
+
sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
|
2217
2238
|
|
2218
2239
|
# 다시 ADB 서버 실행
|
2219
2240
|
puts 'adb start-server'
|
2220
2241
|
Open3.capture3('./adb start-server')
|
2221
|
-
sleep(
|
2242
|
+
sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
|
2222
2243
|
|
2223
2244
|
# 데이터를 끄고 켜기
|
2224
2245
|
puts 'adb -s ' + device_id + ' shell svc data disable'
|
2225
|
-
stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
|
2226
|
-
|
2246
|
+
stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
|
2247
|
+
puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
|
2248
|
+
sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
|
2227
2249
|
puts 'adb -s ' + device_id + ' shell svc data enable'
|
2228
|
-
Open3.capture3('./adb -s '+device_id+' shell svc data enable')
|
2229
|
-
|
2250
|
+
stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
|
2251
|
+
puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
|
2252
|
+
sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
|
2230
2253
|
puts 'adb ok'
|
2231
2254
|
sleep(8)
|
2232
|
-
|
2255
|
+
|
2256
|
+
# IP 변경 확인을 위한 람다 함수
|
2233
2257
|
robot_ip = lambda do
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2258
|
+
begin
|
2259
|
+
# IP 변경 확인
|
2260
|
+
http = HTTP.get('https://www.findip.kr/')
|
2261
|
+
noko = Nokogiri::HTML(http.to_s)
|
2262
|
+
|
2263
|
+
current_ip = noko.xpath('/html/body/header/h2').text.strip
|
2264
|
+
if current_ip != @my_ip
|
2265
|
+
@my_ip = current_ip
|
2238
2266
|
puts "IP 변경됨[ #{@my_ip} ]"
|
2239
|
-
|
2240
|
-
puts @my_ip
|
2241
|
-
puts '
|
2242
|
-
sleep(
|
2243
|
-
robot_ip[]
|
2267
|
+
else
|
2268
|
+
puts "현재 IP: #{@my_ip}"
|
2269
|
+
puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
|
2270
|
+
sleep(5) # 여유롭게 대기 시간 증가
|
2271
|
+
robot_ip[] # 재시도
|
2272
|
+
end
|
2273
|
+
rescue HTTP::ConnectionError => e
|
2274
|
+
puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
|
2275
|
+
sleep(5) # 재시도 간 여유 시간 추가
|
2276
|
+
retry # 재시도
|
2244
2277
|
end
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2278
|
+
end
|
2279
|
+
robot_ip[] # IP 확인 시작
|
2248
2280
|
else
|
2249
|
-
|
2281
|
+
puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
|
2250
2282
|
end
|
2251
|
-
|
2283
|
+
end
|
2252
2284
|
|
2253
2285
|
|
2254
2286
|
check_success = 1
|
@@ -3181,9 +3213,19 @@ class Wordpress
|
|
3181
3213
|
end
|
3182
3214
|
|
3183
3215
|
|
3216
|
+
#if @data['포스트설정']['내용첫줄제목에입력'].checked?
|
3217
|
+
# title = content.split("\n")[0]
|
3218
|
+
#end
|
3184
3219
|
if @data['포스트설정']['내용첫줄제목에입력'].checked?
|
3185
|
-
|
3186
|
-
|
3220
|
+
# 콘텐츠를 줄 단위로 분리
|
3221
|
+
content_lines = content.split("\n")
|
3222
|
+
|
3223
|
+
# 첫 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
|
3224
|
+
title = content_lines.find { |line| !line.start_with?('<img src=') }
|
3225
|
+
|
3226
|
+
# 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
|
3227
|
+
title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
|
3228
|
+
|
3187
3229
|
end
|
3188
3230
|
|
3189
3231
|
if @data['포스트설정']['제목을내용첫줄입력'].checked?
|
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.72
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|