cafe_basics_duo 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_basics_duo.rb +205 -67
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccaaca7ab7260950d6ee2d342ad539f95386196976ed6a6c3675562f094448d6
4
- data.tar.gz: d5427262d21ded00f1ae08f94842fb03725d10118a4dc60dc9babb35355ce89d
3
+ metadata.gz: 28fd31024601888e363f1c6938e732e38cce01bdd96c3869d671b5cb9c66130d
4
+ data.tar.gz: 12eb99cf1cc77524d28e78114f58a279511ad2b6376e7535e1100b55b6e8d4bf
5
5
  SHA512:
6
- metadata.gz: 48f9a541aa2232bf42ca2afa613751a29aa7928c8178f912b962bac9b31eebbe3d15ac05a9139aa2b145cd4387c8645f57e53e2e8b016f55cecbaaabdb2b5df1
7
- data.tar.gz: 2f0818b594ee2f2b09813d42953ad805b037657cc787c26578611ba823f026976b178cbf7fbdd8cf6aaae5111d878c31583e954afb9663629ae5312a08c613a7
6
+ metadata.gz: 91de47b13dd958d847c8acfa9b73f5698481780879fc6e720e2564712e6b21f3172ac97cd8a7108d4f62ea657ef47fe8ef320892dcb38918aa5e1647b208b752
7
+ data.tar.gz: 0b4e44c9c007e16d562de9877a067b47175dd3b6b6fb7c402821ca77886a0097060835f108dea9ea80a1c99d854e2e3df5751c5b308ca24e0eb4e3f9bddffce2
@@ -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
 
@@ -1637,10 +1653,18 @@ class Wordpress
1637
1653
 
1638
1654
  def get_naver_text(q)
1639
1655
  begin
1640
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1641
- @driver = Selenium::WebDriver.for :chrome
1656
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1657
+ options = Selenium::WebDriver::Chrome::Options.new
1658
+ capabilities = [options]
1659
+
1660
+ # Selenium WebDriver에서 options를 capabilities로 전달
1661
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1642
1662
  rescue
1643
- @driver = Selenium::WebDriver.for :chrome
1663
+ # :capabilities에 options를 배열로 전달
1664
+ capabilities = [options]
1665
+
1666
+ # Selenium WebDriver에서 options를 capabilities로 전달
1667
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1644
1668
  end
1645
1669
  @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')
1646
1670
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1670,10 +1694,18 @@ class Wordpress
1670
1694
 
1671
1695
  def get_naver_text2(keyword)
1672
1696
  begin
1673
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1674
- @driver = Selenium::WebDriver.for :chrome
1697
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1698
+ options = Selenium::WebDriver::Chrome::Options.new
1699
+ capabilities = [options]
1700
+
1701
+ # Selenium WebDriver에서 options를 capabilities로 전달
1702
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1675
1703
  rescue
1676
- @driver = Selenium::WebDriver.for :chrome
1704
+ # :capabilities에 options를 배열로 전달
1705
+ capabilities = [options]
1706
+
1707
+ # Selenium WebDriver에서 options를 capabilities로 전달
1708
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1677
1709
  end
1678
1710
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1679
1711
  for n3 in 1..10
@@ -2745,10 +2777,36 @@ class Wordpress
2745
2777
  end
2746
2778
 
2747
2779
  if @data['포스트설정']['인용구변경'].checked?
2748
- @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2749
- content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+@data['포스트설정']['인용구'].sample+'</inyonggoo>'+"")
2780
+ if @data['포스트설정']['인용구문구설정'].checked?
2781
+ # 인용구순서 사용
2782
+ if @data['포스트설정']['인용구순서'].checked?
2783
+ quote_index = 0
2784
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2785
+ content = content.gsub(i.force_encoding('utf-8')) {
2786
+ quote = "<inyonggoo src=''>" + @data['포스트설정']['인용구'][quote_index] + "</inyonggoo>"
2787
+ quote_index = (quote_index + 1) % @data['포스트설정']['인용구'].length
2788
+ quote
2789
+ }
2790
+ end
2791
+ elsif @data['포스트설정']['인용구랜덤'].checked?
2792
+ # 인용구랜덤 사용 시
2793
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2794
+ # 랜덤으로 인용구를 선택하여 각 단어마다 다른 인용구가 적용되도록 함
2795
+ content = content.gsub(i.force_encoding('utf-8')) {
2796
+ # 랜덤으로 인용구를 선택
2797
+ chosen_quote = @data['포스트설정']['인용구'].sample
2798
+ "<inyonggoo src=''>" + chosen_quote + "</inyonggoo>"
2799
+ }
2800
+ end
2801
+ end
2802
+ elsif @data['포스트설정']['인용구제목사용'].checked?
2803
+ # 제목으로 적용할 경우, 특정 단어가 포함된 위치에 제목 스타일을 적용
2804
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2805
+ # i는 '특정단어'입니다. 이 단어가 content에 여러 번 있을 수 있습니다.
2806
+ content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+title+'</inyonggoo>'+"")
2750
2807
  end
2751
2808
  end
2809
+ end
2752
2810
 
2753
2811
  @data['table'][index][-1] = 80
2754
2812
  @data['table'] << []
@@ -2883,8 +2941,14 @@ class Wordpress
2883
2941
  end
2884
2942
 
2885
2943
 
2886
- if @data['포스트설정']['제목내용설정'].checked?
2887
- title = content.split("\n")[0]
2944
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
2945
+ title = content.split("\n")[0]
2946
+
2947
+ end
2948
+
2949
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
2950
+
2951
+ content = "#{title}\n" + content
2888
2952
  end
2889
2953
 
2890
2954
  if @data['포스트설정']['중앙정렬'].checked?
@@ -4229,21 +4293,29 @@ class Wordpress
4229
4293
  top 5
4230
4294
  left 0
4231
4295
  on_toggled{
4232
- if @data['포스트설정']['제목을랜덤'].checked? == true
4233
- if @data['포스트설정']['제목내용설정'].checked?
4234
- @data['포스트설정']['제목내용설정'].checked = false
4235
- end
4296
+ if @data['포스트설정']['제목을랜덤'].checked?
4297
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4298
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4236
4299
  end
4237
4300
  }
4238
4301
  }
4239
- @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4302
+ @data['포스트설정']['내용첫줄제목에입력'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4240
4303
  top 6
4241
4304
  left 0
4242
4305
  on_toggled{
4243
- if @data['포스트설정']['제목내용설정'].checked? == true
4244
- if @data['포스트설정']['제목을랜덤'].checked?
4245
- @data['포스트설정']['제목을랜덤'].checked = false
4246
- end
4306
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
4307
+ @data['포스트설정']['제목을랜덤'].checked = false
4308
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4309
+ end
4310
+ }
4311
+ }
4312
+ @data['포스트설정']['제목을내용첫줄입력'] = checkbox('제목을 내용 첫 줄에 넣기'){
4313
+ top 6
4314
+ left 1
4315
+ on_toggled{
4316
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
4317
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4318
+ @data['포스트설정']['제목을랜덤'].checked = false
4247
4319
  end
4248
4320
  }
4249
4321
  }
@@ -4525,22 +4597,66 @@ class Wordpress
4525
4597
  left 1
4526
4598
  text 'ex) OO시 OO구 OO동 270-68'
4527
4599
  }
4528
- @data['포스트설정']['인용구변경'] = checkbox('내용 특정단어를 인용구로 적용'){
4600
+ @data['포스트설정']['인용구변경'] = checkbox('특정단어를 인용구로 적용'){
4529
4601
  top 11
4530
4602
  left 0
4603
+ on_toggled {
4604
+ if @data['포스트설정']['인용구변경'].checked?
4605
+ @data['포스트설정']['인용구제목사용'].enabled = true # '내용투명' 활성화
4606
+ @data['포스트설정']['인용구문구설정'].enabled = true # '내용투명' 활성화
4607
+ else
4608
+ @data['포스트설정']['인용구변경'].checked = false # 체크 해제
4609
+ @data['포스트설정']['인용구제목사용'].enabled = false # 비활성화
4610
+ @data['포스트설정']['인용구문구설정'].enabled = false # 비활성화
4611
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4612
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4613
+ end
4614
+ }
4531
4615
  }
4532
4616
  @data['포스트설정']['인용구변경단어'] = entry{
4533
4617
  top 11
4534
4618
  left 1
4535
4619
  text '특정단어'
4536
4620
  }
4537
- label('ㄴ인용구 사용시 들어갈 문구'){
4621
+ @data['포스트설정']['인용구제목사용'] = checkbox('인용구를 제목으로 삽입 설정'){
4538
4622
  top 12
4539
4623
  left 0
4624
+ enabled false # 기본적으로 비활성화
4625
+ on_toggled {
4626
+ if @data['포스트설정']['인용구제목사용'].checked?
4627
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4628
+ @data['포스트설정']['인용구문구설정'].enabled = false
4629
+ else
4630
+ @data['포스트설정']['인용구문구설정'].enabled = true
4631
+ end
4632
+ }
4633
+
4634
+ }
4635
+ #label('ㄴ인용구 사용시 들어갈 문구'){
4636
+ @data['포스트설정']['인용구문구설정'] = checkbox('인용구에 들어갈 문구 설정'){
4637
+ top 13
4638
+ left 0
4639
+ enabled false # 기본적으로 비활성화
4640
+
4641
+ on_toggled {
4642
+ if @data['포스트설정']['인용구문구설정'].checked?
4643
+ @data['포스트설정']['인용구제목사용'].checked = false
4644
+ @data['포스트설정']['인용구제목사용'].enabled = false
4645
+ @data['포스트설정']['인용구순서'].enabled = true # '내용투명' 활성화
4646
+ @data['포스트설정']['인용구랜덤'].enabled = true # '내용투명' 활성화
4647
+ else
4648
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4649
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4650
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4651
+ @data['포스트설정']['인용구제목사용'].enabled = true
4652
+ end
4653
+ }
4654
+
4540
4655
  }
4541
4656
  button('설정 파일 불러오기'){
4542
- top 12
4657
+ top 13
4543
4658
  left 1
4659
+
4544
4660
  on_clicked{
4545
4661
  file = open_file
4546
4662
  if file != nil
@@ -4548,6 +4664,27 @@ class Wordpress
4548
4664
  @data['포스트설정']['인용구'] = file_data.split(',')
4549
4665
  end
4550
4666
  }
4667
+ }
4668
+ @data['포스트설정']['인용구순서'] = checkbox('인용구 순서 사용'){
4669
+ top 14
4670
+ left 0
4671
+ enabled false # 기본적으로 비활성화
4672
+ on_toggled {
4673
+ if @data['포스트설정']['인용구순서'].checked?
4674
+ @data['포스트설정']['인용구랜덤'].checked = false
4675
+ end
4676
+ }
4677
+
4678
+ }
4679
+ @data['포스트설정']['인용구랜덤'] = checkbox('인용구 랜덤 사용'){
4680
+ top 14
4681
+ left 1
4682
+ enabled false # 기본적으로 비활성화
4683
+ on_toggled {
4684
+ if @data['포스트설정']['인용구랜덤'].checked?
4685
+ @data['포스트설정']['인용구순서'].checked = false
4686
+ end
4687
+ }
4551
4688
  }
4552
4689
  }
4553
4690
  }
@@ -4855,6 +4992,7 @@ class Wordpress
4855
4992
  @data['포스트설정']['복사,저장 허용'].checked = true
4856
4993
  @data['포스트설정']['자동출처 사용'].checked = false
4857
4994
  @data['포스트설정']['CCL사용'].checked = false
4995
+ @data['포스트설정']['인용구랜덤'].checked = true
4858
4996
  }.show
4859
4997
  end
4860
4998
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_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