cafe_buy_duo 0.0.23 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_buy_duo.rb +106 -32
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7639af0261a14854ff48b5b7cd5ae08dd5bb2c5d1b836de091d0e2c0eeb08d9
4
- data.tar.gz: 435bbf352065f577bb4507991c6a3ccf76a023cfd62dcfa329f020debdbb7a66
3
+ metadata.gz: 3f684c0bfb04fc7b144040a0244ad2e38d4003b29715405cc17b68f2c0761c83
4
+ data.tar.gz: c190ddc479bdd400946adc46c69e2761478ef44b592ca112321d01bc3e4ad634
5
5
  SHA512:
6
- metadata.gz: 4e9bc99605e2b33bb98ff072055dd5ea6b547662bc42fdcfdfc029b8c5e7b9bf60db1c69d4958fb86aff0da980336ef5867e4080b334631f2e095327c056c6c7
7
- data.tar.gz: 0d6ee0c53ec2801df192486244b3775b2f8594397dc5ffdf76bd2758f36e4c027f2a549d442c5470aa77c36d480c9f66008f4ba4101e6f280d93cb37e06abed4
6
+ metadata.gz: 54f44a431fce551f24cd4c2ae2517481dad6e72aff009c5ce97d8ca86f249daf8d2dcdf4f682d99462aaf86b41d01a5f5fd010c129949c4dbebb4f9f800e74ac
7
+ data.tar.gz: 3433e62c6c647ee6ef15aac73063592a69b5d87f2a10a6db410da5c48800312824883ca2b44371698c3f4d8e1495acc7262d23acf30b762d2c38bb574c76c898
data/lib/cafe_buy_duo.rb CHANGED
@@ -210,11 +210,14 @@ class Naver
210
210
  def initialize
211
211
  @seed = 1
212
212
  end
213
- def chrome_setup(user_id)
213
+ def chrome_setup(user_id, proxy)
214
214
  naver_cookie_dir = "C:/naver_cookie"
215
215
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
216
+ if proxy == ''
216
217
  system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
217
-
218
+ else
219
+ 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}})
220
+ end
218
221
  end
219
222
  def chrome_start(proxy, user_id)
220
223
  naver_cookie_dir = "C:/naver_cookie"
@@ -295,7 +298,7 @@ class Naver
295
298
  end
296
299
 
297
300
  # 새로운 스레드 생성 및 실행
298
- Thread.new { chrome_setup(user_id) }
301
+ Thread.new { chrome_setup(user_id, proxy) }
299
302
  sleep(3)
300
303
 
301
304
 
@@ -1046,10 +1049,18 @@ end
1046
1049
  if i2.to_s.include?('<img')
1047
1050
  path = i2.to_s.split('src="')[1].split('"')[0]
1048
1051
  path = URI.decode_www_form(path)[0][0]
1052
+
1053
+ @driver.execute_script(<<~JS)
1054
+ window.URL.createObjectURL = function() {};
1055
+ HTMLInputElement.prototype.click = function() {
1056
+ console.log("File dialog suppressed");
1057
+ };
1058
+ JS
1059
+ sleep(1)
1049
1060
  # 이미지 등록 버튼 클릭
1050
1061
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
1051
1062
  sleep(3)
1052
- key_stroke('escape')
1063
+ #key_stroke('escape')
1053
1064
 
1054
1065
  # 파일 경로 변환 (슬래시 -> 백슬래시)
1055
1066
  file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
@@ -1060,9 +1071,43 @@ end
1060
1071
  # send_keys로 파일 경로를 직접 입력하여 파일 업로드
1061
1072
  file_input.send_keys(file_path)
1062
1073
  sleep(3)
1063
-
1064
1074
 
1065
-
1075
+ @driver.action.key_down(:up).key_up(:up).perform
1076
+ sleep(1)
1077
+
1078
+ begin
1079
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1080
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1081
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]') }
1082
+ sleep(1)
1083
+ @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]').click
1084
+
1085
+ sleep(1)
1086
+ begin
1087
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1088
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1089
+ wait.until { @driver.find_element(:xpath, '//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//button[@class="se-custom-layer-resizing-reset-button"]') }
1090
+ sleep(1)
1091
+ @driver.find_element(:xpath, '//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//button[@class="se-custom-layer-resizing-reset-button"]').click
1092
+ sleep(1)
1093
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1094
+ sleep(1)
1095
+ rescue
1096
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1097
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1098
+ wait.until { @driver.find_element(:xpath, '//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]') }
1099
+ sleep(1)
1100
+ @driver.find_element(:xpath, '//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]').click
1101
+ sleep(1)
1102
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1103
+ sleep(1)
1104
+ end
1105
+ rescue
1106
+ @driver.action.key_down(:down).key_up(:down).perform
1107
+
1108
+ end
1109
+
1110
+
1066
1111
  if option['사진타이틀'] == 'true'
1067
1112
  begin
1068
1113
  @driver.action.key_down(:up).key_up(:up).perform
@@ -1079,7 +1124,7 @@ end
1079
1124
  rescue
1080
1125
  @driver.action.key_down(:down).key_up(:down).perform
1081
1126
  end
1082
- end
1127
+ end
1083
1128
 
1084
1129
 
1085
1130
  if i2.to_s.split('href="')[1] != nil
@@ -1100,38 +1145,67 @@ end
1100
1145
  elsif i2.to_s.include?('<video')
1101
1146
  path = i2.to_s.split('src="')[1].split('"')[0]
1102
1147
  path = URI.decode_www_form(path)[0][0]
1103
-
1148
+
1104
1149
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[3]/button').click
1105
1150
  sleep(3)
1151
+
1152
+
1153
+ @driver.execute_script(<<~JS)
1154
+ window.URL.createObjectURL = function() {};
1155
+ HTMLInputElement.prototype.click = function() {
1156
+ console.log("File dialog suppressed");
1157
+ };
1158
+ JS
1159
+ sleep(1)
1160
+ # 파일 업로드 버튼 클릭 (이제 파일 선택 창이 뜨지 않음)
1106
1161
  @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/fieldset/div[1]/button[1]').click
1107
1162
  sleep(3)
1108
-
1109
- Clipboard.copy(path.split('/').join("\\"))
1110
- key_down('ctrl')
1111
- key_stroke('v')
1112
- key_up('ctrl')
1163
+
1164
+ file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
1165
+ # 파일 입력 필드 찾기 (input[type="file"])
1166
+ file_input = @driver.find_element(:id, "hidden-input")
1167
+
1168
+ # send_keys로 파일 경로를 직접 입력하여 파일 업로드
1169
+ file_input.send_keys(file_path)
1170
+
1113
1171
  sleep(3)
1114
- key_stroke('enter')
1115
- sleep(2)
1116
-
1117
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
1118
- sleep(1)
1119
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
1120
- sleep(1)
1172
+ begin
1173
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
1174
+ sleep(1)
1175
+ rescue
1176
+ end
1177
+
1178
+ begin
1179
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
1180
+ sleep(1)
1181
+ rescue
1182
+ end
1183
+
1184
+ begin
1121
1185
  @driver.find_element(:xpath, '//*[@id="nvu_inp_box_tag"]').send_keys(title)
1122
- sleep(1)
1186
+ sleep(1)
1187
+ rescue
1188
+ end
1123
1189
 
1124
1190
  for n in 1..10
1125
- puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
1126
- if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
1127
- break
1128
- end
1129
- sleep(10)
1191
+ begin
1192
+ puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
1193
+ if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
1194
+ break
1195
+ end
1196
+ sleep(10)
1197
+ rescue
1198
+ end
1130
1199
  end
1131
- @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
1132
- sleep(3)
1133
- @driver.action.key_down(:up).key_up(:up).perform #x탭
1134
- sleep(1)
1200
+
1201
+ begin
1202
+ @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
1203
+ sleep(3)
1204
+ @driver.action.key_down(:up).key_up(:up).perform #x탭
1205
+ sleep(1)
1206
+ rescue
1207
+ end
1208
+
1135
1209
  begin
1136
1210
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1137
1211
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -1146,7 +1220,7 @@ end
1146
1220
  rescue
1147
1221
  @driver.action.key_down(:down).key_up(:down).perform
1148
1222
  end
1149
-
1223
+
1150
1224
  elsif i2.to_s.include?('<inyonggoo')
1151
1225
  if i2.text == ''
1152
1226
 
@@ -2476,7 +2550,7 @@ class Wordpress
2476
2550
  @data['table'] << []
2477
2551
  @data['table'].pop
2478
2552
  #포스팅 get 데이터 가저오기#############################
2479
- proxy = table[3].to_s
2553
+ proxy = table[6].to_s
2480
2554
  user_id = table[1].to_s
2481
2555
  user_pw = table[2].to_s
2482
2556
  naver = Naver.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-20 00:00:00.000000000 Z
11
+ date: 2025-02-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com