cafe_buy 0.0.70 → 0.0.73

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/cafe_buy.rb +139 -63
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f21c93d6014e668db4ff0b7edf914253e31a08d25a57ea9ccde05dc84407c91
4
- data.tar.gz: a3173f5fc9b1f966b9c32fde08cae1446f01458534d8b303b6b67e0544fae3cd
3
+ metadata.gz: 3b274fe3e16c9e4379fc9b3eec01304ecd52a533066ce999aff957eaad68795f
4
+ data.tar.gz: ddc3f3fd2b6e60e1bb6bd8551df2712ab78b1a67de1bc03993b0630542904f26
5
5
  SHA512:
6
- metadata.gz: 3009c57671b922b89087b7fd3e344fe8e24485ffafeed2598855688df7de68f349d482b78999b9b1f40cf769646f65ddc3f6cd9a3cb4278614c93ab4d5fbc833
7
- data.tar.gz: '082f7bcf0b02e400d44c8ef51419884de23aa399234a35a942e813ee8abdeb116c76349c27cda6b2116de4237e67cfd07cdf6dab06b96446c92e5f0f6409b227'
6
+ metadata.gz: 81a9eb971593a5bd2a5c7a4c0b0164309e20ccdd31a7bf8598a3174a1b3a4729909eb08eac1018e966ba73211a18bb6e9cb3733abb7a3db6780f7f0ffe16ca6f
7
+ data.tar.gz: c0254398da2cbed7e04f46b3c0c43ad882f23e0d47dd6c2dce253211b10b51933e80b0bead6bdb54810065a466f08fba87c8926244c7697cb5888e1450395fc3
data/lib/cafe_buy.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 'http'
@@ -241,7 +241,31 @@ end
241
241
  class Naver
242
242
  def initialize
243
243
  @seed = 1
244
+
245
+ begin
246
+ # 캐시를 지워서 이전에 다운로드된 chromedriver를 제거
247
+ Webdrivers.cache_clear
248
+
249
+ # 웹드라이버가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
250
+ Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
251
+ Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
252
+
253
+ # 크롬드라이버 자동 업데이트 시도
254
+ Webdrivers::Chromedriver.update
255
+ puts "chromedriver 자동 다운로드 성공"
256
+ rescue => e
257
+ puts "chromedriver 자동 다운로드 실패: #{e.message}"
258
+ puts "폴더내 크롬드라이버를 사용합니다."
259
+ puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
260
+ puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
261
+ chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
262
+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
263
+ end
264
+
265
+
244
266
  end
267
+
268
+
245
269
  def chrome_setup(user_id, proxy)
246
270
  naver_cookie_dir = "C:/naver_cookie"
247
271
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
@@ -260,10 +284,9 @@ class Naver
260
284
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
261
285
  if proxy == ''
262
286
  begin
263
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
264
287
  options = Selenium::WebDriver::Chrome::Options.new
265
288
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
266
- options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
289
+ #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
267
290
  options.add_argument('--disable-sync') # Chrome 동기화 비활성화
268
291
  options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
269
292
  options.add_argument('--no-default-browser-check')
@@ -288,7 +311,7 @@ class Naver
288
311
  end
289
312
  else
290
313
  begin
291
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
314
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
292
315
  options = Selenium::WebDriver::Chrome::Options.new
293
316
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
294
317
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -315,7 +338,7 @@ class Naver
315
338
  puts e
316
339
  puts 'proxy error...'
317
340
  begin
318
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
341
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
319
342
  options = Selenium::WebDriver::Chrome::Options.new
320
343
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
321
344
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -348,6 +371,7 @@ class Naver
348
371
 
349
372
 
350
373
 
374
+
351
375
  def login(user_id, user_pw, proxy)
352
376
  @user_id = user_id
353
377
  @user_id11 = user_id
@@ -1031,54 +1055,80 @@ end
1031
1055
 
1032
1056
 
1033
1057
  #######################################
1034
-
1035
-
1036
-
1037
- if option['결제'][0] == false
1038
- puts '결제1'
1039
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[2]/div[5]/div/div/div[1]/div[1]/div/label').click
1040
- sleep(1)
1041
- end
1042
-
1043
- if option['결제'][1] == true
1044
- puts '결제2'
1058
+ if option['pay안전결제'] == 'true'
1045
1059
  begin
1046
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[2]/div[5]/div/div/div[1]/div[2]/div/label').click
1047
- sleep(1)
1060
+ # 'selected' 클래스가 없는 첫 번째 deal_item 요소를 찾아 그 안의 label을 클릭
1061
+ @driver.find_element(:xpath, "//div[@class='deal_item' and not(contains(@class, 'selected'))]//label[@for='deal1']").click
1062
+ puts '안전결제 가능 클릭'
1063
+ rescue
1064
+ end
1065
+ sleep(1)
1066
+ elsif option['pay안전결제'] == 'false'
1067
+ puts 'pay안전결제 선택 해제'
1068
+ begin
1069
+ # 'selected' 클래스가 있는 첫 번째 deal_item 요소를 찾아 그 안의 label을 클릭
1070
+ @driver.find_element(:xpath, "//div[@class='deal_item selected']//label[@for='deal1']").click
1048
1071
  rescue
1049
-
1050
1072
  end
1051
1073
  end
1052
-
1053
- if option['결제'][2] == false
1054
- puts '결제3'
1055
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[2]/div[5]/div/div/div[2]/div/div/label').click
1056
- sleep(1)
1074
+
1075
+ if option['pay송금'] == 'true'
1076
+ begin
1077
+ # 'selected' 클래스가 없는 첫 번째 deal_item 요소를 찾아 그 안의 label을 클릭
1078
+ @driver.find_element(:xpath, "//div[@class='deal_item' and not(contains(@class, 'selected'))]//label[@for='deal2']").click
1079
+ puts '안전결제 클릭'
1080
+ rescue
1081
+ end
1082
+ sleep(1)
1083
+ elsif option['pay송금'] == 'false'
1084
+ begin
1085
+ # 'selected' 클래스가 있는 첫 번째 deal_item 요소를 찾아 그 안의 label을 클릭
1086
+ @driver.find_element(:xpath, "//div[@class='deal_item selected']//label[@for='deal2']").click
1087
+ puts 'pay송금 해제'
1088
+ rescue
1089
+ end
1057
1090
  end
1058
1091
 
1059
- if option['결제'][3] == true
1060
- puts '결제4'
1061
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[2]/div[6]/div[2]/div/div/div/label').click
1092
+ if option['휴대전화번호노출동의'] == 'true'
1093
+ begin
1094
+ # 부모 요소 .check_area 안에 .safe_number가 없는 경우에만 클릭
1095
+ @driver.find_element(:xpath, '//*[@class="check_area"]//*[@for="agree1"]').click
1096
+ puts '휴대전화번호 노출 동의 클릭'
1097
+ sleep(1)
1098
+ if option['안심번호'] == 'true'
1099
+ begin
1100
+ @driver.find_element(:xpath, '//*[@class="safe_number"]//*[@for="agree2"]').click
1101
+ puts '안심번호 클릭'
1102
+ rescue
1103
+ end
1104
+ sleep(1)
1105
+ end
1106
+ rescue
1107
+ end
1108
+
1109
+ elsif option['휴대전화번호노출동의'] == 'false'
1110
+ begin
1111
+ puts '휴대전화번호 노출 동의 해제'
1112
+ rescue
1113
+ end
1062
1114
  sleep(1)
1063
1115
  end
1064
-
1065
- if option['결제'][4] == true
1066
- puts '결제5'
1116
+
1117
+ if option['워터마크'] == 'true'
1118
+ begin
1119
+ puts '워터마크 클릭 된 상태'
1120
+ rescue
1121
+ end
1122
+ sleep(1)
1123
+ elsif option['워터마크'] == 'false'
1067
1124
  begin
1068
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[2]/div[6]/div[2]/div/div[2]/div/label').click
1069
- sleep(1)
1125
+ # 'selected' 클래스가 있는 첫 번째 deal_item 요소를 찾아 그 안의 label을 클릭
1126
+ @driver.find_element(:xpath, '//*[@for="watermark"]').click
1127
+ puts '워터마크 해제 클릭'
1070
1128
  rescue
1071
-
1072
1129
  end
1073
1130
  end
1074
-
1075
- if option['결제'][5] == false
1076
- puts '결제6'
1077
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[2]/div[7]/div/div/label').click
1078
-
1079
- end
1080
1131
 
1081
-
1082
1132
 
1083
1133
 
1084
1134
 
@@ -2480,13 +2530,7 @@ class Wordpress
2480
2530
  product_category1 << @data['포스트설정']['카테고리대1'].text.to_s.force_encoding('utf-8')
2481
2531
  product_category1 << @data['포스트설정']['카테고리중2'].text.to_s.force_encoding('utf-8')
2482
2532
  product_category1 << @data['포스트설정']['카테고리소3'].text.to_s.force_encoding('utf-8')
2483
- payment = Array.new
2484
- payment << @data['포스트설정']['pay안전결제 가능'].checked?
2485
- payment << @data['포스트설정']['상품등록정보의 거래업체 제공 동의'].checked?
2486
- payment << @data['포스트설정']['pay송금 가능'].checked?
2487
- payment << @data['포스트설정']['휴대전화번호 노출동의'].checked?
2488
- payment << @data['포스트설정']['안심번호 이용'].checked?
2489
- payment << @data['포스트설정']['워터마크'].checked?
2533
+
2490
2534
 
2491
2535
  while true
2492
2536
  for n in 0..@data['table'].length-1
@@ -3467,7 +3511,34 @@ class Wordpress
3467
3511
  option['클릭항목'] = [@data['포스트설정']['미개봉'].checked?,@data['포스트설정']['거의 새 것'].checked?,@data['포스트설정']['사용감있음'].checked?]
3468
3512
  option['배달'] = [@data['포스트설정']['직거래'].checked?, @data['포스트설정']['택배 거래'].checked?, @data['포스트설정']['온라인전송'].checked?]
3469
3513
  option['직 거래 카테고리'] = product_category1
3470
- option['결제'] = payment
3514
+
3515
+
3516
+ if @data['포스트설정']['pay안전결제'].checked?
3517
+ option['pay안전결제'] = 'true'
3518
+ else
3519
+ option['pay안전결제'] = 'false'
3520
+ end
3521
+ if @data['포스트설정']['pay송금'].checked?
3522
+ option['pay송금'] = 'true'
3523
+ else
3524
+ option['pay송금'] = 'false'
3525
+ end
3526
+ if @data['포스트설정']['휴대전화번호노출동의'].checked?
3527
+ option['휴대전화번호노출동의'] = 'true'
3528
+ else
3529
+ option['휴대전화번호노출동의'] = 'false'
3530
+ end
3531
+ if @data['포스트설정']['안심번호'].checked?
3532
+ option['안심번호'] = 'true'
3533
+ else
3534
+ option['안심번호'] = 'false'
3535
+ end
3536
+ if @data['포스트설정']['워터마크'].checked?
3537
+ option['워터마크'] = 'true'
3538
+ else
3539
+ option['워터마크'] = 'false'
3540
+ end
3541
+
3471
3542
 
3472
3543
  if @data['포스트설정']['전체공개'].checked?
3473
3544
  option['전체공개'] = 'true'
@@ -3524,9 +3595,19 @@ class Wordpress
3524
3595
  end
3525
3596
 
3526
3597
 
3598
+ #if @data['포스트설정']['내용첫줄제목에입력'].checked?
3599
+ # title = content.split("\n")[0]
3600
+ #end
3527
3601
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3528
- title = content.split("\n")[0]
3529
-
3602
+ # 콘텐츠를 단위로 분리
3603
+ content_lines = content.split("\n")
3604
+
3605
+ # 첫 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3606
+ title = content_lines.find { |line| !line.start_with?('<img src=') }
3607
+
3608
+ # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3609
+ title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3610
+
3530
3611
  end
3531
3612
 
3532
3613
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3624,7 +3705,7 @@ class Wordpress
3624
3705
  @data['포스트설정']['막글'] = ''
3625
3706
  @data['포스트설정']['프록시리스트'] = Array.new
3626
3707
  @data['포스트설정']['인용구'] = Array.new
3627
- @user_login_ok = "1"
3708
+ @user_login_ok = "0"
3628
3709
  window('카페 상품 게시판 등록기', 800, 570) {
3629
3710
  margined true
3630
3711
 
@@ -5711,28 +5792,24 @@ class Wordpress
5711
5792
  top 2
5712
5793
  left 0
5713
5794
  }
5714
- @data['포스트설정']['pay안전결제 가능'] = checkbox('pay안전결제 가능'){
5795
+ @data['포스트설정']['pay안전결제'] = checkbox('pay안전결제 가능'){
5715
5796
  top 2
5716
5797
  left 1
5717
5798
  }
5799
+
5718
5800
 
5719
- @data['포스트설정']['pay안전결제 가능'].checked = true
5720
-
5721
- @data['포스트설정']['상품등록정보의 거래업체 제공 동의'] = checkbox('상품등록정보의 거래업체 제공 동의'){
5801
+ @data['포스트설정']['pay송금'] = checkbox('pay송금 가능'){
5722
5802
  top 2
5723
5803
  left 2
5724
5804
  }
5725
- @data['포스트설정']['pay송금 가능'] = checkbox('pay송금 가능'){
5726
- top 2
5727
- left 3
5728
- }
5729
- @data['포스트설정']['pay송금 가능'].checked = true
5730
5805
 
5731
- @data['포스트설정']['휴대전화번호 노출동의'] = checkbox('휴대전화번호 노출동의'){
5806
+
5807
+ @data['포스트설정']['휴대전화번호노출동의'] = checkbox('휴대전화번호 노출동의'){
5732
5808
  top 3
5733
5809
  left 1
5734
5810
  }
5735
- @data['포스트설정']['안심번호 이용'] = checkbox('안심번호 이용'){
5811
+
5812
+ @data['포스트설정']['안심번호'] = checkbox('안심번호 이용'){
5736
5813
  top 3
5737
5814
  left 2
5738
5815
  }
@@ -5768,7 +5845,6 @@ class Wordpress
5768
5845
  stretchy false
5769
5846
  }
5770
5847
 
5771
- @data['포스트설정']['워터마크'].checked = true
5772
5848
  }
5773
5849
  }
5774
5850
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.70
4
+ version: 0.0.73
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-21 00:00:00.000000000 Z
11
+ date: 2025-03-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com