deltago4 0.0.1

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 +7 -0
  2. data/lib/deltago4.rb +1748 -0
  3. metadata +43 -0
data/lib/deltago4.rb ADDED
@@ -0,0 +1,1748 @@
1
+ require 'glimmer-dsl-libui'
2
+ require 'http'
3
+ require 'nokogiri'
4
+ require 'selenium-webdriver'
5
+ require 'rest-client'
6
+ require 'open-uri'
7
+ require 'open3'
8
+
9
+ class Soonje
10
+ def robot
11
+ if @post_counter.text.to_i == 0
12
+ msg_box('수량을 적어주세요')
13
+ else
14
+ @word = Hash.new
15
+ @coupang = Coupang.new
16
+ @coupang.login(@coupang_id.text, @coupang_password.text)
17
+ @naver_keyword = naver_get_item()
18
+ for counter100 in 1..@post_counter.text.to_i
19
+ if @tedering.checked?
20
+ puts 'tedering ip change...'
21
+ stdout, stderr, status = Open3.capture3('adb devices')
22
+ if status.success?
23
+ device_id = stdout.split("\n")[1].split("\t")[0]
24
+ puts device_id
25
+ puts 'adb -s '+device_id+' shell svc data disable'
26
+ stdout2, stderr2, status2 = Open3.capture3('adb -s '+device_id+' shell svc data disable')
27
+ sleep(3)
28
+ puts 'adb -s '+device_id+' shell svc data enable'
29
+ Open3.capture3('adb -s '+device_id+' shell svc data enable')
30
+ sleep(3)
31
+ puts 'adb ok'
32
+ else
33
+ puts 'adb error pass'
34
+ end
35
+ end
36
+
37
+ @search_text = ''
38
+ s2 = @counter_start.text.to_i
39
+ e2 = @counter_end.text.to_i
40
+ if s2 == e2
41
+ counter7 = s2
42
+ else
43
+ counter7 = rand(s2..e2)
44
+ end
45
+ if @update_type == 1
46
+ rand_search_memory = Array.new
47
+ if @update_keyword['랜덤'] == 1
48
+ ['패션의류', '패션잡화', '화장품/미용', '디지털/가전', '출산/육아', '식품', '스포츠/레저', '역사/생활편의', '면세점', '도서'].each do |key|
49
+ @update_keyword[key] = 1
50
+ end
51
+ end
52
+ p @update_keyword
53
+ @naver_keyword.each do |key,v|
54
+ if @update_keyword[key] == 1
55
+ v.each do |i|
56
+ rand_search_memory << i
57
+ end
58
+ end
59
+ end
60
+ @search_text = rand_search_memory.shuffle
61
+ p @search_text
62
+ elsif @update_type == 2
63
+ if @where_search == 'random'
64
+ @search_text = ['goldbox', 'rocket-fresh', 'most-discounted', 'most-sold'].shuffle
65
+ else
66
+ @search_text = [@where_search]
67
+ end
68
+ elsif @update_type == 3
69
+ @search_text = @user_keyword.shuffle
70
+ end
71
+
72
+ if @update_type == 2
73
+ product_data = @coupang.get_product_data2(@search_text)
74
+ product_data2 = product_data.sample(counter7)
75
+ else
76
+ puts '검색중 ==> '+@search_text[0]
77
+ product_data = @coupang.get_product_data(@search_text[0])
78
+ if product_data.length == 0
79
+ puts '쿠팡 검색 갯수 = 0 다시검색'
80
+ product_data = @coupang.get_product_data(@search_text[1])
81
+ end
82
+
83
+ product_data2 = product_data.sample(counter7)
84
+ end
85
+
86
+ url_memory = Hash.new
87
+
88
+ puts '쿠팡 파트너스 상품 url 얻는중 ...'
89
+ product_data2.each do |data3|
90
+ url_memory[data3['productId']] = @coupang.get_product_url(data3)
91
+ end
92
+
93
+ puts product_data2
94
+ puts url_memory
95
+
96
+ if @title_file.length == 0
97
+ title = ''
98
+
99
+ if @title_setting1 == true
100
+ title = product_data2[0]['title'] + ' ' +title
101
+ end
102
+
103
+ if @keyword_setting1 == true
104
+ title = @search_text[0] + ' ' + title
105
+ end
106
+
107
+ if @change_text_setting1 == true
108
+ @change_memory1.each do |key,v|
109
+ title = (title+'_').split(key).join(v.shuffle[0])
110
+ end
111
+ end
112
+ else
113
+ title = @title_file.shuffle[0]
114
+
115
+ if @title_setting1 == true
116
+ title = product_data2[0]['title'] + ' ' +title
117
+ end
118
+
119
+ if @keyword_setting1 == true
120
+ title = @search_text[0] + ' ' + title
121
+ end
122
+
123
+ if @change_text_setting1 == true
124
+ @change_memory1.each do |key,v|
125
+ title = (title+'_').split(key).join(v.shuffle[0])
126
+ end
127
+ end
128
+ end
129
+
130
+ text_top = @text_top.to_s.force_encoding('utf-8')+'_'
131
+ if text_top != ''
132
+ if @tt1.checked?
133
+ @change_memory2.each do |key,v|
134
+ text_top = text_top.split(key).join(v.shuffle[0])
135
+ end
136
+ end
137
+
138
+ if @point_change_text1
139
+ text_top = text_top.split(@point_keyword1.text.force_encoding('utf-8')).join(@search_text[0].force_encoding('utf-8'))
140
+ end
141
+
142
+ if @point_product_name1
143
+ text_top = text_top.split(@point_keyword2.text.force_encoding('utf-8')).join(product_data2[0]['title'].force_encoding('utf-8'))
144
+ end
145
+ end
146
+
147
+ text_bottom = '_'+@text_bottom.to_s.force_encoding('utf-8')+'_'
148
+ if text_bottom != ''
149
+ if @change_text_setting3
150
+ @change_memory3.each do |key,v|
151
+ text_bottom = text_bottom.split(key).join(v.shuffle[0])
152
+ end
153
+ end
154
+
155
+ if @point_change_text2
156
+ text_bottom = text_bottom.split(@point_keyword11.text.force_encoding('utf-8')).join(@search_text[0].force_encoding('utf-8'))
157
+ end
158
+
159
+ if @point_product_name2
160
+ text_bottom = text_bottom.split(@point_keyword22.text.force_encoding('utf-8')).join(product_data2[0]['title'].force_encoding('utf-8'))
161
+ end
162
+ end
163
+
164
+ add_text = ''
165
+ if @add_text_setting1
166
+ add_text = naver_text(@search_text[0])
167
+ end
168
+
169
+ add_text_check = @add_text_setting2
170
+
171
+ if @tag_setting
172
+ search_text = @search_text[0]
173
+ else
174
+ search_text = ''
175
+ end
176
+
177
+ title = title.to_s.split('_').join('')
178
+ text_top = text_top.to_s.split('_').join('')
179
+ text_bottom = text_bottom.to_s.split('_').join('')
180
+
181
+ #@word[blog[1]].update(product_data2, url_memory, title, text_top, text_bottom, add_text, add_text_check, category, @tag_setting ,@search_text[0], @url_change_setting, @proxy_check2.checked?, @proxy_list.shuffle[0])
182
+ html_maker(title, text_top, text_bottom, product_data2, add_text, add_text_check, url_memory, @url_change_setting)
183
+ @code_text << Time.now.to_s+ ' => ' + product_data2[0]['productId'].to_s+'.html 생성완료'
184
+ @code_entry.text = @code_text.join("\n")
185
+ #blog[5] = (blog[5].to_i+1).to_s
186
+ #puts blog[1].to_s.force_encoding('utf-8')+' => 상품등록완료 누적 등록 수 ('+blog[5].to_s.force_encoding('utf-8')+')'
187
+ sleep(@post_delay.text.to_s.to_i)
188
+ end
189
+ end
190
+ end
191
+
192
+ def stop
193
+ begin
194
+ @thread.kill
195
+ rescue
196
+
197
+ end
198
+ end
199
+
200
+ def change_url(url)
201
+ begin
202
+ http = HTTP.post('http://www.linkduo.co.kr/action', :json => {'url' => url})
203
+ rescue
204
+ puts '링크체인저 http 일시적 error 10 초후 재시도'
205
+ sleep(10)
206
+ retry
207
+ end
208
+
209
+ json = JSON.parse(http.to_s)
210
+ return json['result']
211
+ end
212
+
213
+ def html_maker(title, text_top, text_bottom, product, add_text, add_text_check, url_memory, url_change_check)
214
+ vv2 = '<div style="text-align: center;" align="center"><span style="font-size: 23pt;">'+title+'</span></div><br>'
215
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
216
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
217
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
218
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
219
+ vv2 += '<div style="text-align: center;" align="center">'+text_top.split("\n").join('<br>')+'</div><br>'
220
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
221
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
222
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
223
+
224
+ product.each do |dd|
225
+ link_url = url_memory[dd['productId']]
226
+ if url_change_check
227
+ link_url = change_url(link_url)
228
+ end
229
+
230
+ vv = '<center><img style="text-align: center;" align="center" src="'+dd['image'].to_s.split('212x212').join('500x500')+'"></center>'
231
+ vv = vv+ '<p style="text-align: center;" align="center">'+dd['productId'].to_s+' => 파일사진위치</p>'
232
+ vv = vv+ '<div style="text-align: center;" align="center"><span style="font-size: 18pt;">'+dd['title']+'</span></div>'
233
+ vv = vv+ '<div style="text-align: center;" align="center"><span style="font-size: 18pt; color: #ff4b4b;">'+dd['salesPrice'].to_s+' 원</span></div>'
234
+ vv = vv+ '<div style="text-align: center;" align="center"><span style="font-size: 10pt;">무료배송</span></div>'
235
+ vv = vv+ '<p style="font-size: 13pt; text-align: center;" align="center"><a style="text-align: center;" href="'+link_url+'"><span style="font-size: 18pt;">상품보기</span></a></p>'
236
+ vv2 += vv
237
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
238
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
239
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
240
+ end
241
+
242
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
243
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
244
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
245
+ vv2 += '<div style="text-align: center;" align="center">'+text_bottom.split("\n").join('<br>')+'</div><br>'
246
+
247
+ hidden_text = '<canvas width="0" height="0"><table width="165" style="width: 124pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"><tbody><tr height="22" style="height: 16.5pt;"><td width="165" height="22" style="width: 124pt; text-align: center; font-size: 8pt; vertical-align: bottom; white-space: nowrap;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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p;&nbsp;&nbsp;&nbsp;&nbsp; '
248
+ hidden_text2 = '<div id="ssp-bottom"></div></td></tr></tbody></table></canvas>'
249
+
250
+ if add_text_check
251
+ vv2 += '<div style="text-align: center;" align="center">'+hidden_text+add_text+hidden_text2+'</div><br>'
252
+ else
253
+ vv2 += '<div style="text-align: center;" align="center">'+add_text+'</div><br>'
254
+ end
255
+
256
+ begin
257
+ Dir.mkdir('./data/'+title)
258
+ rescue
259
+
260
+ end
261
+ File.open('./data/'+title+'/'+product[0]['productId'].to_s+'.html', 'w') do |f|
262
+ f.write(vv2)
263
+ end
264
+
265
+
266
+ product.each do |dd|
267
+ begin
268
+ http_image = HTTP.get(dd['image'].to_s.split('212x212').join('500x500'))
269
+ rescue
270
+ puts '쿠팡 이미지 가저오는중 http error 10초후 재시도'
271
+ sleep(10)
272
+ retry
273
+ end
274
+ File.open('./data/'+title+'/'+dd['productId'].to_s+'.jpg', 'wb') do |f|
275
+ f.write(http_image.body)
276
+ end
277
+ end
278
+ end
279
+
280
+
281
+
282
+ def naver_get_item
283
+ answer = Hash.new
284
+ mem = Hash.new
285
+ mem['패션의류'] = '50000000'
286
+ mem['패션잡화'] = '50000001'
287
+ mem['화장품/미용'] = '50000002'
288
+ mem['디지털/가전'] = '50000003'
289
+ mem['가구/인테리어'] = '50000004'
290
+ mem['출산/육아'] = '50000005'
291
+ mem['식품'] = '50000006'
292
+ mem['스포츠/레저'] = '50000007'
293
+ mem['생활/건강'] = '50000008'
294
+ mem['여가/생활편의'] = '50000009'
295
+ mem['면세점'] = '50000010'
296
+ mem['도서'] = '50005542'
297
+ mem.each do |key,code|
298
+ sleep(1)
299
+ head = Hash.new
300
+ head[:authority] = 'datalab.naver.com'
301
+ head[:method] = 'POST'
302
+ head[:path] = '/shoppingInsight/getKeywordRank.naver?timeUnit=date&cid='+code.to_s
303
+ head[:scheme] = 'https'
304
+ head['accept'] = '*/*'
305
+ head['accept-encoding'] = 'gzip, deflate, br'
306
+ head['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
307
+ head['content-length'] = 0
308
+ head['origin'] = 'https://datalab.naver.com'
309
+ head['referer'] = 'https://datalab.naver.com/'
310
+ head['sec-ch-ua'] = '" Not A;Brand";v="99", "Chromium";v="101", "Google Chrome";v="101"'
311
+ head['sec-ch-ua-mobile'] = '?0'
312
+ head['sec-ch-ua-platform'] = '"Windows"'
313
+ head['sec-fetch-dest'] = 'empty'
314
+ head['sec-fetch-mode'] = 'cors'
315
+ head['sec-fetch-site'] = 'same-origin'
316
+ head['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36'
317
+ head['x-requested-with'] = 'XMLHttpRequest'
318
+ begin
319
+ http = HTTP.headers(head).post('https://datalab.naver.com/shoppingInsight/getKeywordRank.naver?timeUnit=date&cid='+code.to_s)
320
+ rescue => exception
321
+ puts exception
322
+ puts 'http error 10초후 재시도'
323
+ sleep(10)
324
+ retry
325
+ end
326
+ data = JSON.parse(http.to_s)
327
+ keyword = Array.new
328
+ data[-1]['ranks'].each do |i|
329
+ keyword << i['keyword']
330
+ end
331
+ p keyword
332
+ answer[key] = keyword
333
+ end
334
+ puts answer
335
+ return answer
336
+ end
337
+
338
+ def naver_text(t)
339
+ text1 = Array.new
340
+ text2 = Array.new
341
+ text3 = ''
342
+ for page in 2..3
343
+ error = 0
344
+ counter = 0
345
+ begin
346
+ http = HTTP.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page='+page.to_s+'&query='+t.to_s+'&research_url=&sm=tab_pge&start='+(1+(page-2)*15).to_s+'&where=web')
347
+ rescue
348
+ puts '네이버 문자열 수집중 http error 10초후 재시도 -> ('+counter.to_s+')'
349
+ sleep(10)
350
+ counter += 1
351
+ if counter > 3
352
+ retry
353
+ else
354
+ error = 1
355
+ puts '네이버 문자열 수집 http pass'
356
+ end
357
+ end
358
+ if error == 0
359
+ noko = Nokogiri::HTML(http.to_s)
360
+ for y in 1..15
361
+ begin
362
+ t = noko.xpath('//*[@id="web_'+y.to_s+'"]/div/div[3]/div/a/div').to_s.split('">')[1].split('</div>')[0].to_s
363
+ rescue
364
+ t = ''
365
+ end
366
+ if t != ''
367
+ t.split(' ').each do |i|
368
+ if i[-2..-1] == '요.' or i[-2..-1] == '다.'
369
+ text2 << i
370
+ else
371
+ text1 << i
372
+ end
373
+ end
374
+ end
375
+ end
376
+ end
377
+ end
378
+
379
+ for n in 0..100
380
+ begin
381
+ text3 += text1.shuffle[0..5].join(' ')+text2.shuffle[0]
382
+ rescue
383
+
384
+ end
385
+ end
386
+
387
+ max_text = rand(900)+600
388
+ text3 = text3[0..max_text]
389
+ return text3
390
+ end
391
+
392
+ def login_check(user_id, user_pw)
393
+ json = Hash.new
394
+ json['url'] = '%2Fbbs%2FbuyListManager7.php'
395
+ json['mb_id'] = user_id.to_s
396
+ json['mb_password'] = user_pw.to_s
397
+ http = HTTP.post('http://marketingduo.co.kr/bbs/login_check.php', :form => json)
398
+ if http.to_s.length == 0
399
+ http = HTTP.get('http://marketingduo.co.kr/bbs/buyListManager7.php')
400
+ noko = Nokogiri::HTML(http.to_s)
401
+ c = noko.xpath('//*[@id="at-main"]/div/table/tbody').to_s.split('<tr>').length-1
402
+ for n in 1..c
403
+ tt = noko.xpath('//*[@id="at-main"]/div/table/tbody/tr['+n.to_s+']').to_s
404
+ if tt.include?(user_id.to_s) and tt.include?('오토팡 [원고 자동 생성]')
405
+ if noko.xpath('//*[@id="at-main"]/div/table/tbody/tr['+n.to_s+']/td[7]/label[1]/input').to_s.include?('checked')
406
+ if mac_check(user_id) == 1
407
+ return 1
408
+ else
409
+ return 44
410
+ end
411
+ else
412
+ return 22
413
+ end
414
+ end
415
+ end
416
+ else
417
+ return 33
418
+ end
419
+ end
420
+
421
+ def mac_check(userid)
422
+ json = Hash.new
423
+ json['mb_id'] = 'marketingduo'
424
+ json['mb_password'] = 'mhhs0201'
425
+
426
+ http = HTTP.post('http://marketingduo.co.kr/bbs/login_check.php', :form => json)
427
+ cookie = Hash.new
428
+ http.cookies.each do |i|
429
+ cookie[i.to_s.split('=')[0]] = i.to_s.split('=')[1]
430
+ end
431
+
432
+ http = HTTP.cookies(cookie).get('http://marketingduo.co.kr/bbs/board.php?bo_table=product&sca=&sfl=wr_subject&sop=and&stx='+userid)
433
+ noko = Nokogiri::HTML(http.to_s)
434
+ mac_history = Array.new
435
+ mac_url = Array.new
436
+ for n in 1..5
437
+ begin
438
+ url = noko.css('#fboardlist > div.list-board > ul > li:nth-child('+n.to_s+') > div.wr-subject > a').to_s.split('href="')[1].split('"')[0]
439
+ url = url.split('amp;').join('')
440
+ mac_url << url
441
+ rescue
442
+ break
443
+ end
444
+ end
445
+
446
+ mac_url.each do |i|
447
+ http = HTTP.cookies(cookie).get(i)
448
+ noko = Nokogiri::HTML(http.to_s)
449
+ title = noko.css('#at-main > div > section:nth-child(1) > article > div:nth-child(3) > div.view-content').to_s
450
+ title = title.split('>')[1].split('<')[0].split("\t").join('').split("\n").join('').split(' ').join('')
451
+ p title
452
+ mac_history << title
453
+ end
454
+
455
+ mac_address, stderr, status = Open3.capture3('getmac /v')
456
+ mac_address = mac_address.force_encoding('cp949').encode('utf-8').split('이더넷')[1]
457
+ mac_address = mac_address.split("\n").join('').split(' ').join
458
+ puts mac_address
459
+ if mac_history.length >= 5
460
+ puts '최대 5대 기기 사용가능 로그인실패'
461
+ return 3
462
+ else
463
+ if mac_history.include?(mac_address)
464
+ puts '등록 맥주소 확인 완료'
465
+ return 1
466
+ else
467
+ puts '신규 기기 등록'
468
+ http = HTTP.cookies(cookie).post('http://marketingduo.co.kr/bbs/write_token.php', :form => {'bo_table' => 'product'})
469
+ token = http.to_s.split('token":"')[1].split('"')[0]
470
+ year = Time.now.to_s.split(' ')[0].split('-').join('')
471
+ year2 = Time.now.to_s.split(' ')[1].split(':').join('')
472
+ uid = year+year2
473
+ puts uid
474
+ json = {'token' => token, 'uid' => uid, 'bo_table' => 'product', 'wr_id' => '0', 'wr_subject' => userid, 'wr_content' => mac_address}
475
+ http = HTTP.cookies(cookie).post('http://marketingduo.co.kr/bbs/write_update.php', :form => json)
476
+ return 1
477
+ end
478
+ end
479
+ end
480
+
481
+ include Glimmer
482
+ attr_accessor :user_id, :user_password
483
+ def launch
484
+ @proxy_check = false
485
+ @tedering_check = false
486
+ @update_type = 1
487
+ @update_keyword = Hash.new
488
+ @blog_data = [[false, '0', '0', '0', '0', '0']]
489
+ @keyword_setting1 = false
490
+ @title_file = []
491
+ @title_setting1 = false
492
+ @change_text_setting1 = false
493
+ @change_text_setting2 = false
494
+ @change_memory1 = Hash.new
495
+ @change_memory2 = Hash.new
496
+ @change_memory3 = Hash.new
497
+ @text_top = ''
498
+ @point_change_text1 = false
499
+ @point_change_text2 = false
500
+ @point_product_name1 = false
501
+ @point_product_name2 = false
502
+ @text_bottom = ''
503
+ @add_text_setting1 = false
504
+ @add_text_setting2 = false
505
+ @user_keyword = Array.new
506
+ @where_search = 'goldbox'
507
+ @proxy_list = Array.new
508
+ @change_text_setting3 = false
509
+ @user_login_ok = 0
510
+ @code_text = Array.new
511
+
512
+
513
+ window('Contacts', 1000, 450) {
514
+ margined true
515
+ vertical_box {
516
+ horizontal_box {
517
+ stretchy false
518
+ form {
519
+ @user_id = entry{
520
+ label 'ID'
521
+ text
522
+ }
523
+
524
+ @user_password = password_entry{
525
+ label 'PW'
526
+ text
527
+ }
528
+ }
529
+
530
+ button('로그인') {
531
+ on_clicked {
532
+ @user_login_ok = login_check(@user_id.text.to_s, @user_password.text.to_s)
533
+ if @user_login_ok == 1
534
+ msg_box('로그인 성공')
535
+ elsif @user_login_ok == 33
536
+ msg_box('로그인 실패')
537
+ elsif @user_login_ok == 22
538
+ msg_box('권한 없음')
539
+ elsif @user_login_ok == 44
540
+ msg_box('등록 기기 초과')
541
+ else
542
+ msg_box('실패')
543
+ end
544
+ }
545
+ }
546
+
547
+ button('세팅저장') {
548
+ on_clicked {
549
+ begin
550
+ dd = Hash.new
551
+ dd['프록시'] = @proxy_check2.checked?
552
+ dd['프록시아이피'] = @proxy_list
553
+ dd['테더링'] = @tedering.checked?
554
+ @blog_data.each_with_index do |i,index1|
555
+ i.each_with_index do |j,index2|
556
+ if j.class == String
557
+ begin
558
+ @blog_data[index1][index2] = j.to_s.force_encoding('utf-8')
559
+ rescue
560
+ puts j
561
+ end
562
+ end
563
+ end
564
+ end
565
+ dd['쿠팡아이디'] = @coupang_id.text.to_s
566
+ dd['쿠팡비번'] = @coupang_password.text.to_s
567
+ dd['포스팅딜레이'] = @post_delay.text.to_s
568
+ dd['포스팅수량'] = @post_counter.text.to_s
569
+ dd['포스팅갯수1'] = @counter_start.text.to_s
570
+ dd['포스닝갯수2'] = @counter_end.text.to_s
571
+ dd['포스팅타입1'] = @update_type
572
+ dd['포스팅키워드1'] = @update_keyword
573
+ dd['포스팅추천상품'] = @where_search
574
+ dd['원하는상품키워드'] = @user_keyword
575
+ dd['제목파일'] = @title_file
576
+ dd['제목사용한키워드'] = @keyword_setting1
577
+ dd['사용한상품명'] = @title_setting1
578
+ dd['제목치환단어사용'] = @change_text_setting1
579
+ dd['제목치환파일'] = @change_memory1
580
+ dd['내용상단'] = @text_top
581
+ dd['내용친환단어사용'] = @change_text_setting2
582
+ dd['내용치환파일'] = @change_memory2
583
+ dd['내용특정단어키워드'] = @point_change_text1
584
+ dd['내용특정단어키워드값'] = @point_keyword1.text.to_s
585
+ dd['내용특정단어상품명'] = @point_product_name1
586
+ dd['내용특정단어상품명값'] = @point_keyword2.text.to_s
587
+ dd['링크우회'] = @url_change_setting
588
+ dd['@text_bottom'] = @text_bottom
589
+ dd['@change_text_setting3'] = @change_text_setting3
590
+ dd['@change_memory3'] = @change_memory3
591
+ dd['@point_change_text2'] = @point_change_text2
592
+ dd['@point_keyword11'] = @point_keyword11.text.to_s
593
+ dd['@point_product_name2'] = @point_product_name2
594
+ dd['@point_keyword22'] = @point_keyword22.text.to_s
595
+ dd['@add_text_setting1'] = @add_text_setting1
596
+ dd['@add_text_setting2'] = @add_text_setting2
597
+ dd['@tag_setting'] = @tag_setting
598
+ f = save_file
599
+ dd.each do |key,v|
600
+ if v.class == String
601
+ dd[key] = v.force_encoding('utf-8')
602
+ end
603
+ end
604
+ puts dd
605
+ File.open(f, 'w') do |ff|
606
+ ff.write(dd.to_json)
607
+ end
608
+ rescue
609
+
610
+ end
611
+ }
612
+ }
613
+
614
+ button('세팅로드') {
615
+ on_clicked {
616
+ begin
617
+ f = open_file
618
+ ff = File.open(f,'r').read
619
+ json = JSON.parse(ff)
620
+ @proxy_check2.checked = json['프록시']
621
+ @proxy_check = json['프록시']
622
+ @proxy_list = json['프록시아이피']
623
+ @tedering.checked = json['테더링']
624
+ @coupang_id.text = json['쿠팡아이디']
625
+ @coupang_password.text = json['쿠팡비번']
626
+ @post_delay.text = json['포스팅딜레이']
627
+ @post_counter.text = json['포스팅수량']
628
+ @counter_start.text = json['포스팅갯수1']
629
+ @counter_end.text = json['포스닝갯수2']
630
+ @update_type = json['포스팅타입1']
631
+ @update_keyword = json['포스팅키워드1']
632
+ @update_keyword.each do |key,v|
633
+ @kk1.checked = true if key == '패션의류'
634
+ @kk2.checked = true if key == '패션잡화'
635
+ @kk3.checked = true if key == '화장품/미용'
636
+ @kk4.checked = true if key == '디지털/가전'
637
+ @kk5.checked = true if key == '출산/육아'
638
+ @kk6.checked = true if key == '식품'
639
+ @kk7.checked = true if key == '스포츠/레저'
640
+ @kk8.checked = true if key == '역사/생활편의'
641
+ @kk9.checked = true if key == '면세점'
642
+ @kk10.checked = true if key == '도서'
643
+ @kk11.checked = true if key == '랜덤'
644
+ end
645
+
646
+ if @update_type == 1
647
+ @update1.checked = true
648
+ elsif @update_type == 2
649
+ @update2.checked = true
650
+ elsif @update_type == 3
651
+ @update3.checked = true
652
+ end
653
+
654
+ @where_search = json['포스팅추천상품']
655
+ if @update_type == 2
656
+ i22 = @where_search
657
+ @ss1.checked = true if i22 == 'goldbox'
658
+ @ss2.checked = true if i22 == 'rocket-fresh'
659
+ @ss3.checked = true if i22 == 'most-discounted'
660
+ @ss4.checked = true if i22 == 'most-sold'
661
+ @ss5.checked = true if i22 == 'random'
662
+ end
663
+
664
+ @user_keyword = json['원하는상품키워드']
665
+ @title_file = json['제목파일']
666
+ @keyword_setting1 = json['제목사용한키워드']
667
+ @title_keyword.checked = true if @keyword_setting1
668
+ @title_setting1 = json['사용한상품명']
669
+ @title_product_name.checked = true if @title_setting1
670
+ @change_text_setting1 = json['제목치환단어사용']
671
+ @title_change_text.checked = true if @change_text_setting1
672
+ @change_memory1 = json['제목치환파일']
673
+ @text_top = json['내용상단']
674
+ @change_text_setting2 = json['내용친환단어사용']
675
+ @tt1.checked = @change_text_setting2
676
+ @change_memory2 = json['내용치환파일']
677
+ @point_change_text1 = json['내용특정단어키워드']
678
+ @tt2.checked = true if @point_change_text1
679
+ @point_keyword1.text = json['내용특정단어키워드값']
680
+ @point_product_name1 = json['내용특정단어상품명']
681
+ @tt3.checked = @point_product_name1
682
+ @point_keyword2.text = json['내용특정단어상품명값']
683
+ @url_change_setting = json['링크우회']
684
+ @tt4.checked = @url_change_setting
685
+ @text_bottom = json['@text_bottom']
686
+ @change_text_setting3 = json['@change_text_setting3']
687
+ @tt5.checked = @change_text_setting3
688
+ @change_memory3 = json['@change_memory3']
689
+ @point_change_text2 = json['@point_change_text2']
690
+ @tt6.checked = @point_change_text2
691
+ @point_keyword11.text = json['@point_keyword11']
692
+ @point_product_name2 = json['@point_product_name2']
693
+ @tt7.checked = json['@point_product_name2']
694
+ @point_keyword22.text = json['@point_keyword22']
695
+ @add_text_setting1 = json['@add_text_setting1']
696
+ @tt8.checked = @add_text_setting1
697
+ @add_text_setting2 = json['@add_text_setting2']
698
+ @tt9.checked = @add_text_setting2
699
+ @tag_setting = json['@tag_setting']
700
+ #@tt10.checked = @tag_setting
701
+ rescue
702
+
703
+ end
704
+ }
705
+ }
706
+ }
707
+
708
+ tab {
709
+ tab_item('실행설정'){
710
+ vertical_box {
711
+ grid{
712
+ stretchy false
713
+ @coupang_id = entry{
714
+ top 0
715
+ left 0
716
+ text '쿠팡 파트너스 ID(이메일) 입력'
717
+ }
718
+
719
+ @coupang_password = entry{
720
+ top 0
721
+ left 1
722
+ text 'PW 입력'
723
+ }
724
+ } #grid
725
+
726
+ @code_entry = non_wrapping_multiline_entry{
727
+ text 'init'
728
+ }
729
+
730
+ @blog_data.shift
731
+
732
+
733
+ horizontal_box {
734
+ stretchy false
735
+ @proxy_check2 = checkbox('프록시 사용'){
736
+ stretchy false
737
+ on_toggled do |c|
738
+ @proxy_check = c.checked?
739
+ end
740
+ }
741
+
742
+ button('IP 불러오기'){
743
+ stretchy false
744
+ on_clicked {
745
+ begin
746
+ file = open_file
747
+ if file != nil
748
+ file_data = File.open(file, 'r').read
749
+ file_data.split("\n").each do |i|
750
+ @proxy_list << i
751
+ end
752
+ end
753
+ rescue
754
+
755
+ end
756
+ }
757
+ }
758
+
759
+ @tedering = checkbox('테더링 사용'){
760
+ stretchy false
761
+ on_toggled do |c|
762
+
763
+ end
764
+ }
765
+
766
+ label('생성 딜레이'){
767
+ stretchy false
768
+ }
769
+
770
+ @post_delay = entry{
771
+ stretchy false
772
+ }
773
+
774
+ label('생성 수량'){
775
+ stretchy false
776
+ }
777
+
778
+ @post_counter = entry{
779
+ stretchy false
780
+ }
781
+
782
+ button('자동 생성 시작'){
783
+ stretchy false
784
+ on_clicked do
785
+ if @user_login_ok == 1
786
+ @thread = Thread.new do
787
+ robot()
788
+ end
789
+ end
790
+ end
791
+ }
792
+
793
+ button('자동 생성 정지'){
794
+ stretchy false
795
+ on_clicked do
796
+ stop()
797
+ end
798
+ }
799
+ }
800
+ }
801
+ }
802
+
803
+ tab_item('상품설정'){
804
+ vertical_box{
805
+ horizontal_box{
806
+ stretchy false
807
+ label('★ 한 포스팅에 등록할 상품 갯수'){
808
+ stretchy false
809
+ }
810
+ @counter_start = entry{
811
+ stretchy false
812
+ }
813
+
814
+ label(' ~ '){
815
+ stretchy false
816
+ }
817
+
818
+ @counter_end = entry{
819
+ stretchy false
820
+ }
821
+ label('※ 1~1 입력시 1개/ 2~2 입력시 2개/ 1~3 입력시 3개 이하 랜덤 적용'){
822
+ stretchy false
823
+ }
824
+ }
825
+
826
+ vertical_separator {
827
+ stretchy false
828
+ }
829
+
830
+ horizontal_box{
831
+ stretchy false
832
+ @update1 = checkbox(' 쇼핑 인기 검색어 사용 (복수 체크 가능)'){
833
+ stretchy false
834
+ on_toggled do |c|
835
+ check = c.checked?
836
+ if check == true
837
+ @update_type = 1
838
+ end
839
+ end
840
+ }
841
+ }
842
+
843
+ grid {
844
+ stretchy false
845
+ @kk1 = checkbox('패션의류'){
846
+ top 0
847
+ left 0
848
+ on_toggled do |c|
849
+ check = c.checked?
850
+ if check == true
851
+ @update_keyword['패션의류'] = 1
852
+ else
853
+ @update_keyword['패션의류'] = nil
854
+ end
855
+ end
856
+ }
857
+
858
+ @kk2 = checkbox('패션잡화'){
859
+ top 0
860
+ left 1
861
+ on_toggled do |c|
862
+ check = c.checked?
863
+ if check == true
864
+ @update_keyword['패션잡화'] = 1
865
+ else
866
+ @update_keyword['패션잡화'] = nil
867
+ end
868
+ end
869
+ }
870
+
871
+ @kk3 = checkbox('화장품/미용'){
872
+ top 0
873
+ left 2
874
+ on_toggled do |c|
875
+ check = c.checked?
876
+ if check == true
877
+ @update_keyword['화장품/미용'] = 1
878
+ else
879
+ @update_keyword['화장품/미용'] = nil
880
+ end
881
+ end
882
+ }
883
+
884
+ @kk4 = checkbox('디지털/가전'){
885
+ top 0
886
+ left 3
887
+ on_toggled do |c|
888
+ check = c.checked?
889
+ if check == true
890
+ @update_keyword['디지털/가전'] = 1
891
+ else
892
+ @update_keyword['디지털/가전'] = nil
893
+ end
894
+ end
895
+ }
896
+
897
+ @kk5 = checkbox('출산/육아'){
898
+ top 0
899
+ left 4
900
+ on_toggled do |c|
901
+ check = c.checked?
902
+ if check == true
903
+ @update_keyword['출산/육아'] = 1
904
+ else
905
+ @update_keyword['출산/육아'] = nil
906
+ end
907
+ end
908
+ }
909
+
910
+ @kk6 = checkbox('식품'){
911
+ top 0
912
+ left 5
913
+ on_toggled do |c|
914
+ check = c.checked?
915
+ if check == true
916
+ @update_keyword['식품'] = 1
917
+ else
918
+ @update_keyword['식품'] = nil
919
+ end
920
+ end
921
+ }
922
+
923
+ @kk7 = checkbox('스포츠/레저'){
924
+ top 0
925
+ left 6
926
+ on_toggled do |c|
927
+ check = c.checked?
928
+ if check == true
929
+ @update_keyword['스포츠/레저'] = 1
930
+ else
931
+ @update_keyword['스포츠/레저'] = nil
932
+ end
933
+ end
934
+ }
935
+
936
+ @kk8 = checkbox('역사/생활편의'){
937
+ top 1
938
+ left 0
939
+ on_toggled do |c|
940
+ check = c.checked?
941
+ if check == true
942
+ @update_keyword['역사/생활편의'] = 1
943
+ else
944
+ @update_keyword['역사/생활편의'] = nil
945
+ end
946
+ end
947
+ }
948
+
949
+ @kk9 = checkbox('면세점'){
950
+ top 1
951
+ left 1
952
+ on_toggled do |c|
953
+ check = c.checked?
954
+ if check == true
955
+ @update_keyword['면세점'] = 1
956
+ else
957
+ @update_keyword['면세점'] = nil
958
+ end
959
+ end
960
+ }
961
+
962
+ @kk10 = checkbox('도서'){
963
+ top 1
964
+ left 2
965
+ on_toggled do |c|
966
+ check = c.checked?
967
+ if check == true
968
+ @update_keyword['도서'] = 1
969
+ else
970
+ @update_keyword['도서'] = nil
971
+ end
972
+ end
973
+ }
974
+
975
+ @kk11 = checkbox('랜덤'){
976
+ top 1
977
+ left 3
978
+ on_toggled do |c|
979
+ check = c.checked?
980
+ if check == true
981
+ @update_keyword['랜덤'] = 1
982
+ else
983
+ @update_keyword['랜덤'] = nil
984
+ end
985
+ end
986
+ }
987
+ }
988
+
989
+ vertical_separator {
990
+ stretchy false
991
+ }
992
+
993
+ horizontal_box{
994
+ stretchy false
995
+ @update2 = checkbox(' 추천 상품 (복수 체크 가능)'){
996
+ stretchy false
997
+ on_toggled do |c|
998
+ check = c.checked?
999
+ if check == true
1000
+ @update_type = 2
1001
+ end
1002
+ end
1003
+ }
1004
+ }
1005
+
1006
+ grid{
1007
+ stretchy false
1008
+ @ss1 = checkbox('골드박스'){
1009
+ top 0
1010
+ left 0
1011
+ on_toggled do |c|
1012
+ if c.checked?
1013
+ @where_search = 'goldbox'
1014
+ end
1015
+ end
1016
+ }
1017
+
1018
+ @ss2 = checkbox('로켓프레시'){
1019
+ top 0
1020
+ left 1
1021
+ on_toggled do |c|
1022
+ if c.checked?
1023
+ @where_search = 'rocket-fresh'
1024
+ end
1025
+ end
1026
+ }
1027
+
1028
+ @ss3 = checkbox('할인율 높은 상품'){
1029
+ top 0
1030
+ left 2
1031
+ on_toggled do |c|
1032
+ if c.checked?
1033
+ @where_search = 'most-discounted'
1034
+ end
1035
+ end
1036
+ }
1037
+
1038
+ @ss4 = checkbox('최근 많이 팔린 상품'){
1039
+ top 0
1040
+ left 3
1041
+ on_toggled do |c|
1042
+ if c.checked?
1043
+ @where_search = 'most-sold'
1044
+ end
1045
+ end
1046
+ }
1047
+
1048
+ @ss5 = checkbox('랜덤'){
1049
+ top 0
1050
+ left 4
1051
+ on_toggled do |c|
1052
+ if c.checked?
1053
+ @where_search = 'random'
1054
+ end
1055
+ end
1056
+ }
1057
+ }
1058
+ vertical_separator {
1059
+ stretchy false
1060
+
1061
+ }
1062
+
1063
+ horizontal_box{
1064
+ stretchy false
1065
+ @update3 = checkbox(' 원하는 상품 키워드 삽입'){
1066
+ stretchy false
1067
+ on_toggled do |c|
1068
+ check = c.checked?
1069
+ if check == true
1070
+ @update_type = 3
1071
+ end
1072
+ end
1073
+ }
1074
+ button('파일 불러오기'){
1075
+ stretchy false
1076
+ on_clicked do
1077
+ begin
1078
+ f2 = open_file
1079
+ if f2 != nil
1080
+ if @user_keyword == nil
1081
+ @user_keyword = Array.new
1082
+ end
1083
+ file_data = File.open(f2, 'r').read
1084
+ file_data.split("\n").each do |i|
1085
+ @user_keyword << i
1086
+ end
1087
+ end
1088
+ rescue
1089
+
1090
+ end
1091
+ end
1092
+ }
1093
+ }
1094
+
1095
+ vertical_separator {
1096
+ stretchy false
1097
+ }
1098
+
1099
+ horizontal_box{
1100
+ stretchy false
1101
+
1102
+ #checkbox('이미지 형식'){
1103
+ # stretchy false
1104
+ #}
1105
+
1106
+ #checkbox('링크 이미지 형식'){
1107
+ # stretchy false
1108
+ #}
1109
+
1110
+ }
1111
+ }
1112
+ }
1113
+
1114
+ tab_item('내용설정'){
1115
+ vertical_box{
1116
+ horizontal_box{
1117
+ stretchy false
1118
+ label('★ 제목에 설정'){
1119
+ stretchy false
1120
+ }
1121
+
1122
+ button('제목 파일 불러오기'){
1123
+ stretchy false
1124
+ on_clicked do
1125
+ begin
1126
+ f2 = open_file
1127
+ if f2 != nil
1128
+ file_data = File.open(f2, 'r').read
1129
+ @title_file = file_data.split("\n")
1130
+ puts @title_file
1131
+ end
1132
+ rescue
1133
+
1134
+ end
1135
+ end
1136
+ }
1137
+
1138
+ @title_keyword = checkbox('사용한 키워드 넣기'){
1139
+ stretchy false
1140
+ on_toggled do |c|
1141
+ @keyword_setting1 = c.checked?
1142
+ end
1143
+ }
1144
+
1145
+ @title_product_name = checkbox('사용한 상품명 넣기'){
1146
+ stretchy false
1147
+ on_toggled do |c|
1148
+ @title_setting1 = c.checked?
1149
+ end
1150
+ }
1151
+
1152
+ @title_change_text = checkbox('치환 단어 사용'){
1153
+ stretchy false
1154
+ on_toggled do |c|
1155
+ @change_text_setting1 = c.checked?
1156
+ end
1157
+ }
1158
+
1159
+ button('치환 파일 불러오기'){
1160
+ stretchy false
1161
+ on_clicked do
1162
+ begin
1163
+ f2 = open_file
1164
+ if f2 != nil
1165
+ file_data = File.open(f2, 'r').read
1166
+ file_data.split("\n").each do |i|
1167
+ @change_memory1[i.split('>')[0]] = i.split('>')[1].split(',')
1168
+ puts @change_memory1
1169
+ end
1170
+ end
1171
+ rescue
1172
+
1173
+ end
1174
+ end
1175
+ }
1176
+
1177
+
1178
+ }
1179
+
1180
+ vertical_separator {
1181
+ stretchy false
1182
+ }
1183
+
1184
+ grid{
1185
+ stretchy false
1186
+
1187
+ label('★ 내용 상단 설정'){
1188
+ top 0
1189
+ left 0
1190
+ }
1191
+
1192
+ button('내용 파일 불러오기'){
1193
+ top 0
1194
+ left 1
1195
+ on_clicked do
1196
+ f2 = open_file
1197
+ if f2 != nil
1198
+ file_data = File.open(f2, 'r').read
1199
+ @text_top = file_data.to_s
1200
+ end
1201
+ end
1202
+ }
1203
+
1204
+ @tt1 = checkbox('치환(변경)단어 적용'){
1205
+ top 0
1206
+ left 2
1207
+ on_toggled do |c|
1208
+ @change_text_setting2 = c.checked?
1209
+ end
1210
+ }
1211
+
1212
+ button('치환 파일 불러오기'){
1213
+ top 0
1214
+ left 3
1215
+ on_clicked do
1216
+ begin
1217
+ f2 = open_file
1218
+ if f2 != nil
1219
+ @change_memory2 = Hash.new
1220
+ file_data = File.open(f2, 'r').read
1221
+ file_data.split("\n").each do |i|
1222
+ @change_memory2[i.split('>')[0]] = i.split('>')[1].split(',')
1223
+ puts @change_memory2
1224
+ end
1225
+ end
1226
+ rescue
1227
+
1228
+ end
1229
+ end
1230
+ }
1231
+
1232
+ @tt2 = checkbox('특정단어에 사용한 키워드로 변경'){
1233
+ top 1
1234
+ left 0
1235
+ on_toggled do |c|
1236
+ @point_change_text1 = c.checked?
1237
+ end
1238
+ }
1239
+
1240
+ @point_keyword1 = entry{
1241
+ top 1
1242
+ left 1
1243
+ }
1244
+
1245
+ @tt3 = checkbox('특정단어에 사용한 상품명으로 변경'){
1246
+ top 1
1247
+ left 2
1248
+ on_toggled do |c|
1249
+ @point_product_name1 = c.checked?
1250
+ end
1251
+ }
1252
+
1253
+ @point_keyword2 = entry{
1254
+ top 1
1255
+ left 3
1256
+ }
1257
+ }
1258
+
1259
+ vertical_separator {
1260
+ stretchy false
1261
+ }
1262
+
1263
+ horizontal_box{
1264
+ stretchy false
1265
+ label('★ 내용 중앙 쿠팡 광고 삽입 부분'){
1266
+ stretchy false
1267
+ }
1268
+
1269
+ @tt4 = checkbox(' 쿠팡파트너스 링크우회/단축도메인 사용'){
1270
+ stretchy false
1271
+ on_toggled do |c|
1272
+ @url_change_setting = c.checked?
1273
+ end
1274
+ }
1275
+ }
1276
+
1277
+ vertical_separator {
1278
+ stretchy false
1279
+ }
1280
+
1281
+ grid{
1282
+ stretchy false
1283
+
1284
+ label('★ 내용 하단 설정'){
1285
+ top 0
1286
+ left 0
1287
+ }
1288
+
1289
+ button('내용 파일 불러오기'){
1290
+ top 0
1291
+ left 1
1292
+ on_clicked do
1293
+ begin
1294
+ f2 = open_file
1295
+ if f2 != nil
1296
+ file_data = File.open(f2, 'r').read
1297
+ @text_bottom = file_data.to_s
1298
+ end
1299
+ rescue
1300
+
1301
+ end
1302
+ end
1303
+ }
1304
+
1305
+ @tt5 = checkbox('치환(변경)단어 적용'){
1306
+ top 0
1307
+ left 2
1308
+ on_toggled do |c|
1309
+ @change_text_setting3 = c.checked?
1310
+ end
1311
+ }
1312
+
1313
+ button('치환 파일 불러오기'){
1314
+ top 0
1315
+ left 3
1316
+ on_clicked do
1317
+ begin
1318
+ f2 = open_file
1319
+ if f2 != nil
1320
+ @chnage_memory3 = Hash.new
1321
+ file_data = File.open(f2, 'r').read
1322
+ file_data.split("\n").each do |i|
1323
+ @change_memory3[i.split('>')[0]] = i.split('>')[1].split(',')
1324
+ end
1325
+ end
1326
+ puts @change_memory3
1327
+ rescue
1328
+
1329
+ end
1330
+ end
1331
+ }
1332
+
1333
+ @tt6 = checkbox('특정단어에 사용한 키워드로 변경'){
1334
+ top 1
1335
+ left 0
1336
+ on_toggled do |c|
1337
+ @point_change_text2 = c.checked?
1338
+ end
1339
+ }
1340
+
1341
+ @point_keyword11 = entry{
1342
+ top 1
1343
+ left 1
1344
+ }
1345
+
1346
+ @tt7 = checkbox('특정단어에 사용한 상품명으로 변경'){
1347
+ top 1
1348
+ left 2
1349
+ on_toggled do |c|
1350
+ @point_product_name2 = c.checked?
1351
+ end
1352
+ }
1353
+
1354
+ @point_keyword22 = entry{
1355
+ top 1
1356
+ left 3
1357
+ }
1358
+ }
1359
+
1360
+ vertical_separator {
1361
+ stretchy false
1362
+ }
1363
+
1364
+ horizontal_box{
1365
+ stretchy false
1366
+ label('★ 내용 하단 추가 설정'){
1367
+ stretchy false
1368
+ }
1369
+
1370
+ @tt8 = checkbox('자동원고 덧붙임 ('){
1371
+ stretchy false
1372
+ on_toggled do |c|
1373
+ @add_text_setting1 = c.checked?
1374
+ end
1375
+ }
1376
+
1377
+ @tt9 = checkbox('자동원고 안보이게 히든 적용)'){
1378
+ stretchy false
1379
+ on_toggled do |c|
1380
+ @add_text_setting2 = c.checked?
1381
+ end
1382
+ }
1383
+ }
1384
+
1385
+ vertical_separator {
1386
+ stretchy false
1387
+ }
1388
+
1389
+
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+ }.show
1395
+ end
1396
+ end
1397
+
1398
+ class Coupang
1399
+ def initialize
1400
+ @start_chrome = Thread.new do
1401
+ begin
1402
+ system('"'+"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"+'"'+" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/ChromeTEMP")
1403
+ system('"'+"C:/Program Files/Google/Chrome/Application/chrome.exe"+'"'+" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/ChromeTEMP")
1404
+ rescue => exception
1405
+ puts exception
1406
+ end
1407
+ end
1408
+ sleep(3)
1409
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1410
+ options = Selenium::WebDriver::Chrome::Options.new
1411
+ options.add_option("debuggerAddress", "127.0.0.1:9222")
1412
+ @driver = Selenium::WebDriver.for :chrome, options: options
1413
+ @driver.manage.window.maximize
1414
+ @wait = Selenium::WebDriver::Wait.new(:timeout => 5)
1415
+ end
1416
+
1417
+ def login(user_id,user_pw)
1418
+ @driver.get('https://partners.coupang.com/')
1419
+ begin
1420
+ sleep(3)
1421
+ element = @wait.until { @driver.find_element(:xpath, '//*[@id="app-header"]/div[2]/div/button[1]') }
1422
+ element.click
1423
+
1424
+ e = @wait.until { @driver.find_element(:xpath, '//*[@id="login-email-input"]') }
1425
+ e.send_keys(user_id)
1426
+ @driver.find_element(:xpath, '//*[@id="login-password-input"]').send_keys(user_pw)
1427
+ sleep(1)
1428
+ #@driver.find_element(:xpath, '/html/body/div[1]/div/div/form/div[4]/label/span').click
1429
+ #sleep(1)
1430
+ @driver.find_element(:xpath, '/html/body/div[1]/div/div/form/div[5]/button').click
1431
+ sleep(5)
1432
+
1433
+ rescue => exception
1434
+ puts exception
1435
+ puts 'logined'
1436
+ end
1437
+ sleep(2)
1438
+ @cookie = Hash.new
1439
+ @driver.manage.all_cookies.each do |cookie|
1440
+ @cookie[cookie[:name]] = cookie[:value]
1441
+ end
1442
+ puts @cookie
1443
+ sleep(2)
1444
+ @driver.close
1445
+ end
1446
+
1447
+ def get_product_data(name)
1448
+ json = {
1449
+ 'page' => {
1450
+ 'pageNumber' => 0,
1451
+ 'size' => 36
1452
+ },
1453
+ 'deliveryTypes' => [],
1454
+ 'filter' => name
1455
+ }
1456
+
1457
+ http = HTTP.cookies(@cookie).post('https://partners.coupang.com/api/v1/search', :json => json)
1458
+ data = JSON.parse(http.to_s)['data']['products']
1459
+ puts data
1460
+ return data
1461
+ end
1462
+
1463
+ def get_product_data2(where)
1464
+ http = HTTP.cookies(@cookie).get('https://partners.coupang.com/api/v1/discovery/'+where[0]+'?limit=20')
1465
+ puts http.to_s
1466
+ data = JSON.parse(http.to_s)['data']['products']
1467
+ puts data
1468
+ return data
1469
+ end
1470
+
1471
+ def get_product_url(product_data)
1472
+ json = {
1473
+ 'product' => {
1474
+ 'deliveryBadgeImage' => product_data['deliveryBadgeImage'],
1475
+ 'discountRate' => nil,
1476
+ 'image' => product_data['image'],
1477
+ 'itemId' => product_data['itemId'],
1478
+ 'originPrice' => product_data['originPrice'],
1479
+ 'productId' => product_data['productId'],
1480
+ 'salesPrice' => product_data['salesPrice'],
1481
+ 'title' => product_data['title'],
1482
+ 'type' => product_data['type'],
1483
+ 'vendorItemId' => product_data['vendorItemId']
1484
+ }
1485
+ }
1486
+ begin
1487
+ http = http = HTTP.headers('x-token' => @cookie['AFATK']).cookies(@cookie).post('https://partners.coupang.com/api/v1/banner/iframe/url', :json => json)
1488
+ json = JSON.parse(http.to_s)
1489
+ puts json
1490
+ url = json['data']['shortUrl']
1491
+ rescue => exception
1492
+ puts exception
1493
+ puts '10초후 재시도 http error...'
1494
+ sleep(10)
1495
+ retry
1496
+ end
1497
+ puts url
1498
+ return url
1499
+ end
1500
+ end
1501
+
1502
+
1503
+ class WordLib
1504
+ def initialize(user_id, user_pw, url)
1505
+ @url = url
1506
+ @form2 = {'log' => user_id,
1507
+ 'pwd' => user_pw,
1508
+ 'wp-submit' => '로그인',
1509
+ 'redirect_to' => url+'/wp-admin/',
1510
+ 'testcookie' => 1}
1511
+
1512
+ @header_value = {
1513
+ 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
1514
+ 'Accept-Encoding' => 'gzip, deflate',
1515
+ 'Accept-Language' => 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
1516
+ 'Cache-Control' => 'max-age=0',
1517
+ 'Connection' => 'keep-alive',
1518
+ 'Content-Type' => 'application/x-www-form-urlencoded',
1519
+ 'Host' => url.split('//')[1],
1520
+ 'Origin' => url,
1521
+ 'Referer' => url+'/wp-login.php?loggedout=true&wp_lang=ko_KR',
1522
+ 'Upgrade-Insecure-Requests' => 1,
1523
+ 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36'
1524
+ }
1525
+
1526
+ http = HTTP.headers(@header_value).post(url+'/wp-login.php', :form => @form2)
1527
+ answer = Hash.new
1528
+ @cookie2 = ''
1529
+ http.cookies.each do |v|
1530
+ @cookie2 += v.to_s.split('=')[0] + '=' + v.to_s.split('=')[1] +'; '
1531
+ answer[v.to_s.split('=')[0]] = v.to_s.split('=')[1]
1532
+ end
1533
+ puts answer
1534
+ @cookie = answer
1535
+ return answer
1536
+ end
1537
+
1538
+ def word_image_update(image_path, wpnonce, post_id, product_id)
1539
+ begin
1540
+ http_image = HTTP.get(image_path.to_s.split('212x212').join('500x500'))
1541
+ rescue
1542
+ puts '쿠팡 이미지 가저오는중 http error 10초후 재시도'
1543
+ sleep(10)
1544
+ retry
1545
+ end
1546
+ File.open('./image/'+product_id.to_s+'.jpg', 'wb') do |f|
1547
+ f.write(http_image.body)
1548
+ end
1549
+
1550
+ file_size = File.size('./image/'+product_id.to_s+'.jpg')
1551
+
1552
+ @h = Hash.new
1553
+ @h['Host'] = @url.split('//')[1]
1554
+ @h['Accept'] = '*/*'
1555
+ @h['Connection'] = 'keep-alive'
1556
+ @h['Accept-Encoding'] = 'gzip, deflate, br'
1557
+ @h['Accept-Language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
1558
+ @h['Content-Length'] = File.size('./image/'+product_id.to_s+'.jpg')+602
1559
+ @h['Content-Type'] = 'multipart/form-data; boundary=----WebKitFormBoundaryNbi1Vusy7cc25XJq'
1560
+ @h['Origin'] = @url
1561
+ @h['Referer'] = @url+'/wp-admin/post-new.php'
1562
+ @h['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36'
1563
+ puts @cookie2
1564
+ @h['Cookie'] = @cookie2
1565
+
1566
+
1567
+ image_json = {
1568
+ 'name' => product_id.to_s+'.jpg',
1569
+ 'action' => 'upload-attachment',
1570
+ '_wpnonce' => wpnonce,
1571
+ 'post_id' => post_id.to_i,
1572
+ 'async-upload' => File.new('./image/'+product_id.to_s+'.jpg')
1573
+ }
1574
+
1575
+ puts image_json
1576
+ puts @url.split('ttps://').join('ttp://')+'/wp-admin/async-upload.php'
1577
+ begin
1578
+ r = RestClient.post(@url.split('ttps://').join('ttp://')+'/wp-admin/async-upload.php', image_json ,headers=@h)
1579
+ rescue
1580
+ puts '워드프레스 이미지 올리는중 http error 10초후 재시도'
1581
+ sleep(10)
1582
+ retry
1583
+ end
1584
+ json = JSON.parse(r.body)
1585
+ return json['data']['url']
1586
+ end
1587
+
1588
+ def update(product, url_memory, title, text_top, text_bottom, add_text, add_text_check, category, tag_setting, search, url_change_check, proxy_check, proxy_ip)
1589
+ http = HTTP.cookies(@cookie).get(@url+'/wp-admin/post-new.php')
1590
+ http.cookies.each do |v|
1591
+ @cookie2 += v.to_s.split('=')[0] + '=' + v.to_s.split('=')[1] + '; '
1592
+ @cookie[v.to_s.split('=')[0]] = v.to_s.split('=')[1]
1593
+ end
1594
+ noko = Nokogiri::HTML(http.to_s)
1595
+ wpnonce2 = noko.to_s.split('_wpnonce":"')[1].split('"')[0]
1596
+ puts category
1597
+ cmm = Hash.new
1598
+ giri = noko.xpath('//*[@id="categorychecklist"]').to_s.split('<li')
1599
+ giri.shift
1600
+ giri.each do |kk|
1601
+ name = kk.split('in-category')[1].split('>')[1].split('<')[0].split(' ').join('').split('"').join('').force_encoding('utf-8')
1602
+ value = kk.split('value="')[1].split('"')[0]
1603
+ cmm[name] = value.to_i
1604
+ end
1605
+ puts cmm
1606
+
1607
+ if category == '새 카테고리 이름'
1608
+ category_value = 1
1609
+ else
1610
+ begin
1611
+ category_value = cmm[category.to_s.force_encoding('utf-8')].to_i
1612
+ rescue => exception
1613
+ puts exception
1614
+ category_value = 1
1615
+ end
1616
+ end
1617
+
1618
+
1619
+ vv2 = '<div style="text-align: center;" align="center">'+text_top+'</div><br>'
1620
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1621
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1622
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1623
+
1624
+ product.each do |dd|
1625
+ link_url = url_memory[dd['productId']]
1626
+ if url_change_check
1627
+ link_url = change_url(link_url)
1628
+ end
1629
+ vv = '<a href="'+link_url+'"><img class="aligncenter size-full wp-image-175" src="'+word_image_update(dd['image'], wpnonce2 , noko.xpath('//*[@id="post_ID"]').to_s.split('value="')[1].split('"')[0], dd['productId'])+'" alt="" width="410" height="410" /></a>'
1630
+ vv = vv+ '<div style="text-align: center;" align="center"><span style="font-size: 18pt;">'+dd['title']+'</span></div>'
1631
+ vv = vv+ '<div style="text-align: center;" align="center"><span style="font-size: 18pt; color: #ff4b4b;">'+dd['salesPrice'].to_s+' 원</span></div>'
1632
+ vv = vv+ '<div style="text-align: center;" align="center"><span style="font-size: 10pt;">무료배송</span></div>'
1633
+ vv = vv+ '<p style="font-size: 13pt; text-align: center;" align="center"><a style="text-align: center;" href="'+link_url+'"><span style="font-size: 18pt;">상품보기</span></a></p>'
1634
+ vv2 += vv
1635
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1636
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1637
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1638
+ end
1639
+
1640
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1641
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1642
+ vv2 += '<div style="text-align: center;" align="center"> </div><br>'
1643
+ vv2 += '<div style="text-align: center;" align="center">'+text_bottom+'</div><br>'
1644
+
1645
+ hidden_text = '<canvas width="0" height="0"><table width="165" style="width: 124pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"><tbody><tr height="22" style="height: 16.5pt;"><td width="165" height="22" style="width: 124pt; text-align: center; font-size: 8pt; vertical-align: bottom; white-space: nowrap;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '
1646
+ hidden_text2 = '<div id="ssp-bottom"></div></td></tr></tbody></table></canvas>'
1647
+
1648
+ if add_text_check
1649
+ vv2 += '<div style="text-align: center;" align="center">'+hidden_text+add_text+hidden_text2+'</div><br>'
1650
+ else
1651
+ vv2 += '<div style="text-align: center;" align="center">'+add_text+'</div><br>'
1652
+ end
1653
+
1654
+ time = Time.now.to_s.split(' ')[0]
1655
+ time2 = Time.now.to_s.split(' ')[1]
1656
+
1657
+ data2 = Hash.new
1658
+ data2['_wpnonce'] = noko.xpath('//*[@id="_wpnonce"]').to_s.split('value="')[1].split('"')[0]
1659
+ data2['_wp_http_referer'] = '/wp-admin/post.php?post='+noko.xpath('//*[@id="post_ID"]').to_s.split('value="')[1].split('"')[0]+'&action=edit'
1660
+ data2['user_ID'] = 1
1661
+ data2['action'] = 'editpost'
1662
+ data2['originalaction'] = 'editpost'
1663
+ data2['post_author'] = 1
1664
+ data2['post_type'] = 'post'
1665
+ data2['original_post_status'] = 'draft'
1666
+ data2['referredby'] = @url+'/wp-admin/edit.php'
1667
+ data2['post_ID'] = noko.xpath('//*[@id="post_ID"]').to_s.split('value="')[1].split('"')[0]
1668
+ data2['post_title'] = title
1669
+ data2['content'] = vv2
1670
+ data2['hidden_post_status'] = 'draft'
1671
+ data2['post_status'] = 'draft'
1672
+ data2['hidden_post_visibility'] = 'public'
1673
+ data2['visibility'] = 'public'
1674
+ data2['meta-box-order-nonce'] = noko.xpath('//*[@id="meta-box-order-nonce"]').to_s.split('value="')[1].split('"')[0]
1675
+ data2['closedpostboxesnonce'] = noko.xpath('//*[@id="closedpostboxesnonce"]').to_s.split('value="')[1].split('"')[0]
1676
+ data2['samplepermalinknonce'] = noko.xpath('//*[@id="samplepermalinknonce"]').to_s.split('value="')[1].split('"')[0]
1677
+ data2['_ajax_nonce-add-category'] = noko.xpath('//*[@id="_ajax_nonce-add-category"]').to_s.split('value="')[1].split('"')[0]
1678
+ data2['_ajax_nonce-add-meta'] = noko.xpath('//*[@id="_ajax_nonce-add-meta"]').to_s.split('value="')[1].split('"')[0]
1679
+ data2['mm'] = time.split('-')[1]
1680
+ data2['jj'] = time.split('-')[2]
1681
+ data2['aa'] = time.split('-')[0]
1682
+ data2['hh'] = time2.split('-')[0]
1683
+ data2['mn'] = time2.split('-')[1]
1684
+ data2['ss'] = time2.split('-')[2]
1685
+ data2['hidden_mm'] = data2['mm']
1686
+ data2['cur_mm'] = data2['mm']
1687
+ data2['hidden_jj'] = data2['jj']
1688
+ data2['cur_jj'] = data2['jj']
1689
+ data2['hidden_aa'] = data2['aa']
1690
+ data2['cur_aa'] = data2['aa']
1691
+ data2['hidden_hh'] = data2['hh']
1692
+ data2['cur_hh'] = data2['hh']
1693
+ data2['hidden_mn'] = data2['mn']
1694
+ data2['cur_mn'] = data2['mn']
1695
+ data2['original_publish'] = '공개'
1696
+ data2['publish'] = '공개'
1697
+ data2['post_format'] = 0
1698
+ data2['post_category[]'] = 0
1699
+ data2['post_category[]'] = category_value
1700
+ data2['newcategory'] = '새 카테고리 이름'
1701
+ data2['newcategory_parent'] = -1
1702
+ data2['_thumbnail_id'] = -1
1703
+ data2['advanced_view'] = 1
1704
+ data2['comment_status'] = 'open'
1705
+ data2['ping_status'] = 'open'
1706
+ data2['post_author_override'] = 1
1707
+ if tag_setting
1708
+ data2['tax_input[post_tag]'] = search
1709
+ end
1710
+
1711
+ puts data2
1712
+
1713
+ begin
1714
+ if proxy_check
1715
+ begin
1716
+ http = HTTP.via(proxy_ip.split(':')[0], proxy_ip.split(':')[1].to_i).cookies(@cookie).post(@url+'/wp-admin/post.php', :form => data2)
1717
+ rescue
1718
+ puts proxy_ip.to_s+' proxy error 프록시 없이 업로드'
1719
+ http = HTTP.cookies(@cookie).post(@url+'/wp-admin/post.php', :form => data2)
1720
+ end
1721
+ else
1722
+ http = HTTP.cookies(@cookie).post(@url+'/wp-admin/post.php', :form => data2)
1723
+ end
1724
+ rescue
1725
+ puts '워드프레스 포스팅중 http error 10초후 재시도'
1726
+ sleep(10)
1727
+ retry
1728
+ end
1729
+ puts http.to_s
1730
+
1731
+ end
1732
+
1733
+ def change_url(url)
1734
+ begin
1735
+ http = HTTP.post('http://www.linkduo.co.kr/action', :json => {'url' => url})
1736
+ rescue
1737
+ puts '링크체인저 http 일시적 error 10 초후 재시도'
1738
+ sleep(10)
1739
+ retry
1740
+ end
1741
+
1742
+ json = JSON.parse(http.to_s)
1743
+ return json['result']
1744
+ end
1745
+ end
1746
+
1747
+
1748
+ Soonje.new.launch