cafe_buy 0.0.11 → 0.0.15

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 +206 -68
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '097e3042fa63418919feea30c257d651b94ec2c738660f6a971505b67ff07977'
4
- data.tar.gz: 927dce10fba1243e9ff16ecebf0397389a73e76bf995b26d10953954702f6525
3
+ metadata.gz: 5f6e252546c4944ed1df4d05c1ff3001acb312806aae569aad9c662fecb66270
4
+ data.tar.gz: 32fadd8fcde2f80a988008f70ce1eb943b12b2cd934f252001d07fc272c4ca47
5
5
  SHA512:
6
- metadata.gz: 5cabc0a24a2600dce1e36574ac6731b46403b10bc99656d41f9168802728574e24be19b71e64e0f969c20be8df5853ea404df6bc96d070ecb9e09459e3238776
7
- data.tar.gz: e0f6f7612c879caccec2fcc294f81ebef7777b76052b53136f0b857c081f96c7385adff2435c8ca6fa1ed33178b050243035d309ffe76b9438ae54faac5e7270
6
+ metadata.gz: f9c9974b9fb1c7827846afe3e434b21200e38c44410508fb1b21a906a77a1b19456ded5da43dbaeb9019e21dbf552cec1b5c8eb2ded7ba05cb08362bc4180573
7
+ data.tar.gz: c35a66d0270356ec4229513bf1e56399a6960dfcbfe999c2e3443bbbde371e43735a3c884acc6e4bc829acbe4f32ad1801978aa23a009a64ce28545e58294c4d
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'
@@ -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
 
@@ -1882,10 +1898,18 @@ class Wordpress
1882
1898
 
1883
1899
  def get_naver_text(q)
1884
1900
  begin
1885
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1886
- @driver = Selenium::WebDriver.for :chrome
1901
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1902
+ options = Selenium::WebDriver::Chrome::Options.new
1903
+ capabilities = [options]
1904
+
1905
+ # Selenium WebDriver에서 options를 capabilities로 전달
1906
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1887
1907
  rescue
1888
- @driver = Selenium::WebDriver.for :chrome
1908
+ # :capabilities에 options를 배열로 전달
1909
+ capabilities = [options]
1910
+
1911
+ # Selenium WebDriver에서 options를 capabilities로 전달
1912
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1889
1913
  end
1890
1914
  @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')
1891
1915
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1915,10 +1939,18 @@ class Wordpress
1915
1939
 
1916
1940
  def get_naver_text2(keyword)
1917
1941
  begin
1918
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1919
- @driver = Selenium::WebDriver.for :chrome
1942
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1943
+ options = Selenium::WebDriver::Chrome::Options.new
1944
+ capabilities = [options]
1945
+
1946
+ # Selenium WebDriver에서 options를 capabilities로 전달
1947
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1920
1948
  rescue
1921
- @driver = Selenium::WebDriver.for :chrome
1949
+ # :capabilities에 options를 배열로 전달
1950
+ capabilities = [options]
1951
+
1952
+ # Selenium WebDriver에서 options를 capabilities로 전달
1953
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1922
1954
  end
1923
1955
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1924
1956
  for n3 in 1..10
@@ -1956,6 +1988,7 @@ class Wordpress
1956
1988
 
1957
1989
 
1958
1990
 
1991
+
1959
1992
  #def chrome_start(url, user_id, user_pw)
1960
1993
  # @url = url
1961
1994
  # @user_id = user_id
@@ -3007,10 +3040,36 @@ class Wordpress
3007
3040
  end
3008
3041
 
3009
3042
  if @data['포스트설정']['인용구변경'].checked?
3010
- @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3011
- content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+@data['포스트설정']['인용구'].sample+'</inyonggoo>'+"")
3043
+ if @data['포스트설정']['인용구문구설정'].checked?
3044
+ # 인용구순서 사용
3045
+ if @data['포스트설정']['인용구순서'].checked?
3046
+ quote_index = 0
3047
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3048
+ content = content.gsub(i.force_encoding('utf-8')) {
3049
+ quote = "<inyonggoo src=''>" + @data['포스트설정']['인용구'][quote_index] + "</inyonggoo>"
3050
+ quote_index = (quote_index + 1) % @data['포스트설정']['인용구'].length
3051
+ quote
3052
+ }
3053
+ end
3054
+ elsif @data['포스트설정']['인용구랜덤'].checked?
3055
+ # 인용구랜덤 사용 시
3056
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3057
+ # 랜덤으로 인용구를 선택하여 각 단어마다 다른 인용구가 적용되도록 함
3058
+ content = content.gsub(i.force_encoding('utf-8')) {
3059
+ # 랜덤으로 인용구를 선택
3060
+ chosen_quote = @data['포스트설정']['인용구'].sample
3061
+ "<inyonggoo src=''>" + chosen_quote + "</inyonggoo>"
3062
+ }
3063
+ end
3064
+ end
3065
+ elsif @data['포스트설정']['인용구제목사용'].checked?
3066
+ # 제목으로 적용할 경우, 특정 단어가 포함된 위치에 제목 스타일을 적용
3067
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3068
+ # i는 '특정단어'입니다. 이 단어가 content에 여러 번 있을 수 있습니다.
3069
+ content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+title+'</inyonggoo>'+"")
3012
3070
  end
3013
3071
  end
3072
+ end
3014
3073
 
3015
3074
  @data['table'][index][-1] = 80
3016
3075
  @data['table'] << []
@@ -3150,8 +3209,14 @@ class Wordpress
3150
3209
  end
3151
3210
 
3152
3211
 
3153
- if @data['포스트설정']['제목내용설정'].checked?
3154
- title = content.split("\n")[0]
3212
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
3213
+ title = content.split("\n")[0]
3214
+
3215
+ end
3216
+
3217
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
3218
+
3219
+ content = "#{title}\n" + content
3155
3220
  end
3156
3221
 
3157
3222
  if @data['포스트설정']['중앙정렬'].checked?
@@ -4490,21 +4555,29 @@ class Wordpress
4490
4555
  top 5
4491
4556
  left 0
4492
4557
  on_toggled{
4493
- if @data['포스트설정']['제목을랜덤'].checked? == true
4494
- if @data['포스트설정']['제목내용설정'].checked?
4495
- @data['포스트설정']['제목내용설정'].checked = false
4496
- end
4558
+ if @data['포스트설정']['제목을랜덤'].checked?
4559
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4560
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4497
4561
  end
4498
4562
  }
4499
4563
  }
4500
- @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4564
+ @data['포스트설정']['내용첫줄제목에입력'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4501
4565
  top 6
4502
4566
  left 0
4503
4567
  on_toggled{
4504
- if @data['포스트설정']['제목내용설정'].checked? == true
4505
- if @data['포스트설정']['제목을랜덤'].checked?
4506
- @data['포스트설정']['제목을랜덤'].checked = false
4507
- end
4568
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
4569
+ @data['포스트설정']['제목을랜덤'].checked = false
4570
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4571
+ end
4572
+ }
4573
+ }
4574
+ @data['포스트설정']['제목을내용첫줄입력'] = checkbox('제목을 내용 첫 줄에 넣기'){
4575
+ top 6
4576
+ left 1
4577
+ on_toggled{
4578
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
4579
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4580
+ @data['포스트설정']['제목을랜덤'].checked = false
4508
4581
  end
4509
4582
  }
4510
4583
  }
@@ -4784,22 +4857,66 @@ class Wordpress
4784
4857
  left 1
4785
4858
  text 'ex) OO시 OO구 OO동 270-68'
4786
4859
  }
4787
- @data['포스트설정']['인용구변경'] = checkbox('내용 특정단어를 인용구로 적용'){
4860
+ @data['포스트설정']['인용구변경'] = checkbox('특정단어를 인용구로 적용'){
4788
4861
  top 11
4789
4862
  left 0
4863
+ on_toggled {
4864
+ if @data['포스트설정']['인용구변경'].checked?
4865
+ @data['포스트설정']['인용구제목사용'].enabled = true # '내용투명' 활성화
4866
+ @data['포스트설정']['인용구문구설정'].enabled = true # '내용투명' 활성화
4867
+ else
4868
+ @data['포스트설정']['인용구변경'].checked = false # 체크 해제
4869
+ @data['포스트설정']['인용구제목사용'].enabled = false # 비활성화
4870
+ @data['포스트설정']['인용구문구설정'].enabled = false # 비활성화
4871
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4872
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4873
+ end
4874
+ }
4790
4875
  }
4791
4876
  @data['포스트설정']['인용구변경단어'] = entry{
4792
4877
  top 11
4793
4878
  left 1
4794
4879
  text '특정단어'
4795
4880
  }
4796
- label('ㄴ인용구 사용시 들어갈 문구'){
4881
+ @data['포스트설정']['인용구제목사용'] = checkbox('인용구를 제목으로 삽입 설정'){
4797
4882
  top 12
4798
4883
  left 0
4884
+ enabled false # 기본적으로 비활성화
4885
+ on_toggled {
4886
+ if @data['포스트설정']['인용구제목사용'].checked?
4887
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4888
+ @data['포스트설정']['인용구문구설정'].enabled = false
4889
+ else
4890
+ @data['포스트설정']['인용구문구설정'].enabled = true
4891
+ end
4892
+ }
4893
+
4894
+ }
4895
+ #label('ㄴ인용구 사용시 들어갈 문구'){
4896
+ @data['포스트설정']['인용구문구설정'] = checkbox('인용구에 들어갈 문구 설정'){
4897
+ top 13
4898
+ left 0
4899
+ enabled false # 기본적으로 비활성화
4900
+
4901
+ on_toggled {
4902
+ if @data['포스트설정']['인용구문구설정'].checked?
4903
+ @data['포스트설정']['인용구제목사용'].checked = false
4904
+ @data['포스트설정']['인용구제목사용'].enabled = false
4905
+ @data['포스트설정']['인용구순서'].enabled = true # '내용투명' 활성화
4906
+ @data['포스트설정']['인용구랜덤'].enabled = true # '내용투명' 활성화
4907
+ else
4908
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4909
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4910
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4911
+ @data['포스트설정']['인용구제목사용'].enabled = true
4912
+ end
4913
+ }
4914
+
4799
4915
  }
4800
4916
  button('설정 파일 불러오기'){
4801
- top 12
4917
+ top 13
4802
4918
  left 1
4919
+
4803
4920
  on_clicked{
4804
4921
  file = open_file
4805
4922
  if file != nil
@@ -4807,6 +4924,27 @@ class Wordpress
4807
4924
  @data['포스트설정']['인용구'] = file_data.split(',')
4808
4925
  end
4809
4926
  }
4927
+ }
4928
+ @data['포스트설정']['인용구순서'] = checkbox('인용구 순서 사용'){
4929
+ top 14
4930
+ left 0
4931
+ enabled false # 기본적으로 비활성화
4932
+ on_toggled {
4933
+ if @data['포스트설정']['인용구순서'].checked?
4934
+ @data['포스트설정']['인용구랜덤'].checked = false
4935
+ end
4936
+ }
4937
+
4938
+ }
4939
+ @data['포스트설정']['인용구랜덤'] = checkbox('인용구 랜덤 사용'){
4940
+ top 14
4941
+ left 1
4942
+ enabled false # 기본적으로 비활성화
4943
+ on_toggled {
4944
+ if @data['포스트설정']['인용구랜덤'].checked?
4945
+ @data['포스트설정']['인용구순서'].checked = false
4946
+ end
4947
+ }
4810
4948
  }
4811
4949
  }
4812
4950
  }
@@ -5333,7 +5471,7 @@ class Wordpress
5333
5471
  @data['포스트설정']['복사,저장 허용'].checked = true
5334
5472
  @data['포스트설정']['자동출처 사용'].checked = false
5335
5473
  @data['포스트설정']['CCL사용'].checked = false
5336
-
5474
+ @data['포스트설정']['인용구랜덤'].checked = true
5337
5475
 
5338
5476
  }.show
5339
5477
  end
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.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