cafe_buy_duo 0.0.11 → 0.0.15

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 +206 -68
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62b5bdbc76a52f74d44f933c96ca76668575b5ad009d7d6f565c4915dee8f846
4
- data.tar.gz: 4b23f2d5714c23cbc8df08e04c94fc7c92f7da6bf2eae3bdbb7a6389b9601215
3
+ metadata.gz: 36b4b834d11812846aac4f7ffcf7e25dd1acf42c42208b10c0028ca4933a82d7
4
+ data.tar.gz: 5b1386b8aa40d9c57677e36ca0b34fc41711bb7417c97e386927e31873116e4b
5
5
  SHA512:
6
- metadata.gz: 5de9d54b03e3777c2f9f9d4fff197c4a6a8c66fc13b0967a116b06caadc62f03013d0c156857bb85dcd1481fd57e83fc32faa13ba4c2c8d783e87a080586d86a
7
- data.tar.gz: 30e2304ac80f250ce69be1f4bbb8d3e8c94f062bc9cac1f981f2518f100ba01459509c1826b1444dbc31a2198e5c6583f8c999e0f1d149de524c83bf2a93639a
6
+ metadata.gz: 2e59c88da41c5cfe8e445c65c77995c39d13adfc9cefb6eeb64a79b94e35a3868aa43bb7a6e5591f89a93c698ff7ccec3dbc5b6632a8e674fd5511815f61b49a
7
+ data.tar.gz: 48410279650ff588a39632266ec8f8b1a62922816b483ac413d2b8117ee54a3073f63bc2b2be2857fe2c50a435ab95fbbf565d81b75b9c4da06fa3fd036d5df3
data/lib/cafe_buy_duo.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'
@@ -219,55 +219,71 @@ class Naver
219
219
  def chrome_start(proxy, user_id)
220
220
  naver_cookie_dir = "C:/naver_cookie"
221
221
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
222
+
222
223
  if proxy == ''
223
- begin
224
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
225
- options = Selenium::WebDriver::Chrome::Options.new
226
- options.page_load_strategy = :normal
227
- options.timeouts = {page_load: 20_000}
228
- options.page_load_strategy = 'none'
229
- options.add_argument('--remote-debugging-port=9222')
230
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
231
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
232
- rescue
233
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
234
- end
224
+ begin
225
+ # webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
226
+ options = Selenium::WebDriver::Chrome::Options.new
227
+ options.page_load_strategy = :normal
228
+ options.timeouts = { page_load: 20_000 }
229
+ options.page_load_strategy = 'none'
230
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
231
+
232
+
233
+
234
+ options.add_argument('--remote-debugging-port=9222')
235
+ options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
236
+
237
+ # :capabilities에 options를 배열로 전달
238
+ capabilities = [options]
239
+
240
+ # Selenium WebDriver에서 options를 capabilities로 전달
241
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
242
+ rescue
243
+ # 예외 발생 시 다른 방법으로 셀레니움 실행
244
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
245
+ end
235
246
  else
247
+ begin
248
+ # Proxy를 사용하는 경우
249
+ options = Selenium::WebDriver::Chrome::Options.new
250
+ options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
251
+ options.page_load_strategy = :normal
252
+ options.timeouts = { page_load: 20_000 }
253
+ options.page_load_strategy = 'none'
254
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
255
+
256
+ options.add_argument('--remote-debugging-port=9222')
257
+ options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
258
+
259
+ # :capabilities에 options를 배열로 전달
260
+ capabilities = [options]
261
+
262
+ # Selenium WebDriver에서 options를 capabilities로 전달
263
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
264
+ rescue => e
265
+ puts 'proxy error...'
236
266
  begin
237
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
238
- options = Selenium::WebDriver::Chrome::Options.new
239
- # profile = Selenium::WebDriver::Chrome::Profile.new
240
- # profile['network.proxy.type'] = 1
241
- # profile['network.proxy.http'] = proxy.split(':')[0]
242
- # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
243
- # options = Selenium::WebDriver::Chrome::Options.new
244
- # options.profile = profile
245
- options = Selenium::WebDriver::Chrome::Options.new
246
- options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
247
- options.page_load_strategy = :normal
248
- options.timeouts = {page_load: 20_000}
249
- options.page_load_strategy = 'none'
250
- options.add_argument('--remote-debugging-port=9222')
251
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
252
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
253
- rescue => e
254
- puts e
255
- puts 'proxy error...'
256
- begin
257
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
258
- options = Selenium::WebDriver::Chrome::Options.new
259
- options.page_load_strategy = :normal
260
- options.timeouts = {page_load: 20_000}
261
- options.page_load_strategy = 'none'
262
- options.add_argument('--remote-debugging-port=9222')
263
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
264
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
265
- rescue
266
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
267
- end
267
+ # Proxy가 실패할 경우 예외 처리
268
+ options = Selenium::WebDriver::Chrome::Options.new
269
+ options.page_load_strategy = :normal
270
+ options.timeouts = { page_load: 20_000 }
271
+ options.page_load_strategy = 'none'
272
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
273
+ options.add_argument('--remote-debugging-port=9222')
274
+ options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
275
+
276
+ # :capabilities에 options 배열로 전달
277
+ capabilities = [options]
278
+
279
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
280
+ rescue
281
+ # 예외 발생 시 다른 방법으로 셀레니움 실행
282
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
268
283
  end
284
+ end
269
285
  end
270
- end
286
+ end
271
287
 
272
288
 
273
289
 
@@ -1951,10 +1967,18 @@ class Wordpress
1951
1967
 
1952
1968
  def get_naver_text(q)
1953
1969
  begin
1954
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1955
- @driver = Selenium::WebDriver.for :chrome
1970
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1971
+ options = Selenium::WebDriver::Chrome::Options.new
1972
+ capabilities = [options]
1973
+
1974
+ # Selenium WebDriver에서 options를 capabilities로 전달
1975
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1956
1976
  rescue
1957
- @driver = Selenium::WebDriver.for :chrome
1977
+ # :capabilities에 options를 배열로 전달
1978
+ capabilities = [options]
1979
+
1980
+ # Selenium WebDriver에서 options를 capabilities로 전달
1981
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1958
1982
  end
1959
1983
  @driver.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page=3&query='+q.to_s+'&research_url=&sm=tab_pge&start=16&where=web')
1960
1984
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1984,10 +2008,18 @@ class Wordpress
1984
2008
 
1985
2009
  def get_naver_text2(keyword)
1986
2010
  begin
1987
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1988
- @driver = Selenium::WebDriver.for :chrome
2011
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
2012
+ options = Selenium::WebDriver::Chrome::Options.new
2013
+ capabilities = [options]
2014
+
2015
+ # Selenium WebDriver에서 options를 capabilities로 전달
2016
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1989
2017
  rescue
1990
- @driver = Selenium::WebDriver.for :chrome
2018
+ # :capabilities에 options를 배열로 전달
2019
+ capabilities = [options]
2020
+
2021
+ # Selenium WebDriver에서 options를 capabilities로 전달
2022
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1991
2023
  end
1992
2024
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1993
2025
  for n3 in 1..10
@@ -2024,6 +2056,7 @@ class Wordpress
2024
2056
 
2025
2057
 
2026
2058
 
2059
+
2027
2060
  #def chrome_start(url, user_id, user_pw)
2028
2061
  # @url = url
2029
2062
  # @user_id = user_id
@@ -3075,10 +3108,36 @@ class Wordpress
3075
3108
  end
3076
3109
 
3077
3110
  if @data['포스트설정']['인용구변경'].checked?
3078
- @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3079
- content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+@data['포스트설정']['인용구'].sample+'</inyonggoo>'+"")
3111
+ if @data['포스트설정']['인용구문구설정'].checked?
3112
+ # 인용구순서 사용
3113
+ if @data['포스트설정']['인용구순서'].checked?
3114
+ quote_index = 0
3115
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3116
+ content = content.gsub(i.force_encoding('utf-8')) {
3117
+ quote = "<inyonggoo src=''>" + @data['포스트설정']['인용구'][quote_index] + "</inyonggoo>"
3118
+ quote_index = (quote_index + 1) % @data['포스트설정']['인용구'].length
3119
+ quote
3120
+ }
3121
+ end
3122
+ elsif @data['포스트설정']['인용구랜덤'].checked?
3123
+ # 인용구랜덤 사용 시
3124
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3125
+ # 랜덤으로 인용구를 선택하여 각 단어마다 다른 인용구가 적용되도록 함
3126
+ content = content.gsub(i.force_encoding('utf-8')) {
3127
+ # 랜덤으로 인용구를 선택
3128
+ chosen_quote = @data['포스트설정']['인용구'].sample
3129
+ "<inyonggoo src=''>" + chosen_quote + "</inyonggoo>"
3130
+ }
3131
+ end
3132
+ end
3133
+ elsif @data['포스트설정']['인용구제목사용'].checked?
3134
+ # 제목으로 적용할 경우, 특정 단어가 포함된 위치에 제목 스타일을 적용
3135
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3136
+ # i는 '특정단어'입니다. 이 단어가 content에 여러 번 있을 수 있습니다.
3137
+ content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+title+'</inyonggoo>'+"")
3080
3138
  end
3081
3139
  end
3140
+ end
3082
3141
 
3083
3142
  @data['table'][index][-1] = 80
3084
3143
  @data['table'] << []
@@ -3218,8 +3277,14 @@ class Wordpress
3218
3277
  end
3219
3278
 
3220
3279
 
3221
- if @data['포스트설정']['제목내용설정'].checked?
3222
- title = content.split("\n")[0]
3280
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
3281
+ title = content.split("\n")[0]
3282
+
3283
+ end
3284
+
3285
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
3286
+
3287
+ content = "#{title}\n" + content
3223
3288
  end
3224
3289
 
3225
3290
  if @data['포스트설정']['중앙정렬'].checked?
@@ -4564,21 +4629,29 @@ class Wordpress
4564
4629
  top 5
4565
4630
  left 0
4566
4631
  on_toggled{
4567
- if @data['포스트설정']['제목을랜덤'].checked? == true
4568
- if @data['포스트설정']['제목내용설정'].checked?
4569
- @data['포스트설정']['제목내용설정'].checked = false
4570
- end
4632
+ if @data['포스트설정']['제목을랜덤'].checked?
4633
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4634
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4571
4635
  end
4572
4636
  }
4573
4637
  }
4574
- @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4638
+ @data['포스트설정']['내용첫줄제목에입력'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4575
4639
  top 6
4576
4640
  left 0
4577
4641
  on_toggled{
4578
- if @data['포스트설정']['제목내용설정'].checked? == true
4579
- if @data['포스트설정']['제목을랜덤'].checked?
4580
- @data['포스트설정']['제목을랜덤'].checked = false
4581
- end
4642
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
4643
+ @data['포스트설정']['제목을랜덤'].checked = false
4644
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4645
+ end
4646
+ }
4647
+ }
4648
+ @data['포스트설정']['제목을내용첫줄입력'] = checkbox('제목을 내용 첫 줄에 넣기'){
4649
+ top 6
4650
+ left 1
4651
+ on_toggled{
4652
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
4653
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4654
+ @data['포스트설정']['제목을랜덤'].checked = false
4582
4655
  end
4583
4656
  }
4584
4657
  }
@@ -4858,22 +4931,66 @@ class Wordpress
4858
4931
  left 1
4859
4932
  text 'ex) OO시 OO구 OO동 270-68'
4860
4933
  }
4861
- @data['포스트설정']['인용구변경'] = checkbox('내용 특정단어를 인용구로 적용'){
4934
+ @data['포스트설정']['인용구변경'] = checkbox('특정단어를 인용구로 적용'){
4862
4935
  top 11
4863
4936
  left 0
4937
+ on_toggled {
4938
+ if @data['포스트설정']['인용구변경'].checked?
4939
+ @data['포스트설정']['인용구제목사용'].enabled = true # '내용투명' 활성화
4940
+ @data['포스트설정']['인용구문구설정'].enabled = true # '내용투명' 활성화
4941
+ else
4942
+ @data['포스트설정']['인용구변경'].checked = false # 체크 해제
4943
+ @data['포스트설정']['인용구제목사용'].enabled = false # 비활성화
4944
+ @data['포스트설정']['인용구문구설정'].enabled = false # 비활성화
4945
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4946
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4947
+ end
4948
+ }
4864
4949
  }
4865
4950
  @data['포스트설정']['인용구변경단어'] = entry{
4866
4951
  top 11
4867
4952
  left 1
4868
4953
  text '특정단어'
4869
4954
  }
4870
- label('ㄴ인용구 사용시 들어갈 문구'){
4955
+ @data['포스트설정']['인용구제목사용'] = checkbox('인용구를 제목으로 삽입 설정'){
4871
4956
  top 12
4872
4957
  left 0
4958
+ enabled false # 기본적으로 비활성화
4959
+ on_toggled {
4960
+ if @data['포스트설정']['인용구제목사용'].checked?
4961
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4962
+ @data['포스트설정']['인용구문구설정'].enabled = false
4963
+ else
4964
+ @data['포스트설정']['인용구문구설정'].enabled = true
4965
+ end
4966
+ }
4967
+
4968
+ }
4969
+ #label('ㄴ인용구 사용시 들어갈 문구'){
4970
+ @data['포스트설정']['인용구문구설정'] = checkbox('인용구에 들어갈 문구 설정'){
4971
+ top 13
4972
+ left 0
4973
+ enabled false # 기본적으로 비활성화
4974
+
4975
+ on_toggled {
4976
+ if @data['포스트설정']['인용구문구설정'].checked?
4977
+ @data['포스트설정']['인용구제목사용'].checked = false
4978
+ @data['포스트설정']['인용구제목사용'].enabled = false
4979
+ @data['포스트설정']['인용구순서'].enabled = true # '내용투명' 활성화
4980
+ @data['포스트설정']['인용구랜덤'].enabled = true # '내용투명' 활성화
4981
+ else
4982
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4983
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4984
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4985
+ @data['포스트설정']['인용구제목사용'].enabled = true
4986
+ end
4987
+ }
4988
+
4873
4989
  }
4874
4990
  button('설정 파일 불러오기'){
4875
- top 12
4991
+ top 13
4876
4992
  left 1
4993
+
4877
4994
  on_clicked{
4878
4995
  file = open_file
4879
4996
  if file != nil
@@ -4881,6 +4998,27 @@ class Wordpress
4881
4998
  @data['포스트설정']['인용구'] = file_data.split(',')
4882
4999
  end
4883
5000
  }
5001
+ }
5002
+ @data['포스트설정']['인용구순서'] = checkbox('인용구 순서 사용'){
5003
+ top 14
5004
+ left 0
5005
+ enabled false # 기본적으로 비활성화
5006
+ on_toggled {
5007
+ if @data['포스트설정']['인용구순서'].checked?
5008
+ @data['포스트설정']['인용구랜덤'].checked = false
5009
+ end
5010
+ }
5011
+
5012
+ }
5013
+ @data['포스트설정']['인용구랜덤'] = checkbox('인용구 랜덤 사용'){
5014
+ top 14
5015
+ left 1
5016
+ enabled false # 기본적으로 비활성화
5017
+ on_toggled {
5018
+ if @data['포스트설정']['인용구랜덤'].checked?
5019
+ @data['포스트설정']['인용구순서'].checked = false
5020
+ end
5021
+ }
4884
5022
  }
4885
5023
  }
4886
5024
  }
@@ -5407,7 +5545,7 @@ class Wordpress
5407
5545
  @data['포스트설정']['복사,저장 허용'].checked = true
5408
5546
  @data['포스트설정']['자동출처 사용'].checked = false
5409
5547
  @data['포스트설정']['CCL사용'].checked = false
5410
-
5548
+ @data['포스트설정']['인용구랜덤'].checked = true
5411
5549
 
5412
5550
  }.show
5413
5551
  end
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.11
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-30 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com