cafe_basics 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_basics.rb +205 -80
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 732d293fbe298007d812850531f11f00bddc27a7d2cf2a8de0849b05f65c68a3
4
- data.tar.gz: c56120bd679c4d871aaf7811be998b56a6beac4fe76b84491e57c90bf275820c
3
+ metadata.gz: 67b94c083f63b91262a70afdb3c0456e140622b7f213e03705578daae7570a43
4
+ data.tar.gz: 69acbee14d09707ba0d6cc90e7961eeb1d49899f4e859f8627094230d3db0863
5
5
  SHA512:
6
- metadata.gz: 51bef7a3ca54f39edf24c88fb93e5704a208a017eee91ed053bbbf9ee5d1cb8673e168176e119b48ccf079374c02003bdb5a549905a686c24eb755001d5d0ad4
7
- data.tar.gz: b4b7575195c449eccbecd6627317c58460603388f92ca9499924588b0a02c98ad8d02d416a1988bd902c99ca23c3903d391ace148d3a848cd0ce09a4c66cd9dc
6
+ metadata.gz: 9185b4be4fee55e74debf3f8965568426fce81369a6f83a3ef8dbdd122db30f09609330ace33e0c43fd06628f15973aeb21c20fd83da5b3ef5544d0776f69820
7
+ data.tar.gz: fed8af8069291dac956e10ce4257ff44b5c646babade15e397e7983fd370bc5b2f494b33cbec151d0ab1cba3f833c99ad49a9099be32224830af780cccd69a72
data/lib/cafe_basics.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
 
@@ -1568,10 +1584,18 @@ class Wordpress
1568
1584
 
1569
1585
  def get_naver_text(q)
1570
1586
  begin
1571
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1572
- @driver = Selenium::WebDriver.for :chrome
1587
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1588
+ options = Selenium::WebDriver::Chrome::Options.new
1589
+ capabilities = [options]
1590
+
1591
+ # Selenium WebDriver에서 options를 capabilities로 전달
1592
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1573
1593
  rescue
1574
- @driver = Selenium::WebDriver.for :chrome
1594
+ # :capabilities에 options를 배열로 전달
1595
+ capabilities = [options]
1596
+
1597
+ # Selenium WebDriver에서 options를 capabilities로 전달
1598
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1575
1599
  end
1576
1600
  @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')
1577
1601
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1601,10 +1625,18 @@ class Wordpress
1601
1625
 
1602
1626
  def get_naver_text2(keyword)
1603
1627
  begin
1604
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1605
- @driver = Selenium::WebDriver.for :chrome
1628
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1629
+ options = Selenium::WebDriver::Chrome::Options.new
1630
+ capabilities = [options]
1631
+
1632
+ # Selenium WebDriver에서 options를 capabilities로 전달
1633
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1606
1634
  rescue
1607
- @driver = Selenium::WebDriver.for :chrome
1635
+ # :capabilities에 options를 배열로 전달
1636
+ capabilities = [options]
1637
+
1638
+ # Selenium WebDriver에서 options를 capabilities로 전달
1639
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1608
1640
  end
1609
1641
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1610
1642
  for n3 in 1..10
@@ -1641,19 +1673,6 @@ class Wordpress
1641
1673
 
1642
1674
 
1643
1675
 
1644
- def chrome_start(url, user_id, user_pw)
1645
- @url = url
1646
- @user_id = user_id
1647
- @user_pw = user_pw
1648
- begin
1649
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1650
- @driver = Selenium::WebDriver.for :chrome
1651
- rescue
1652
- @driver = Selenium::WebDriver.for :chrome
1653
- end
1654
- end
1655
-
1656
-
1657
1676
 
1658
1677
  #def chrome_start(url, user_id, user_pw)
1659
1678
  # @url = url
@@ -2690,10 +2709,36 @@ class Wordpress
2690
2709
  end
2691
2710
 
2692
2711
  if @data['포스트설정']['인용구변경'].checked?
2693
- @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2694
- content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+@data['포스트설정']['인용구'].sample+'</inyonggoo>'+"")
2712
+ if @data['포스트설정']['인용구문구설정'].checked?
2713
+ # 인용구순서 사용
2714
+ if @data['포스트설정']['인용구순서'].checked?
2715
+ quote_index = 0
2716
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2717
+ content = content.gsub(i.force_encoding('utf-8')) {
2718
+ quote = "<inyonggoo src=''>" + @data['포스트설정']['인용구'][quote_index] + "</inyonggoo>"
2719
+ quote_index = (quote_index + 1) % @data['포스트설정']['인용구'].length
2720
+ quote
2721
+ }
2722
+ end
2723
+ elsif @data['포스트설정']['인용구랜덤'].checked?
2724
+ # 인용구랜덤 사용 시
2725
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2726
+ # 랜덤으로 인용구를 선택하여 각 단어마다 다른 인용구가 적용되도록 함
2727
+ content = content.gsub(i.force_encoding('utf-8')) {
2728
+ # 랜덤으로 인용구를 선택
2729
+ chosen_quote = @data['포스트설정']['인용구'].sample
2730
+ "<inyonggoo src=''>" + chosen_quote + "</inyonggoo>"
2731
+ }
2732
+ end
2733
+ end
2734
+ elsif @data['포스트설정']['인용구제목사용'].checked?
2735
+ # 제목으로 적용할 경우, 특정 단어가 포함된 위치에 제목 스타일을 적용
2736
+ @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2737
+ # i는 '특정단어'입니다. 이 단어가 content에 여러 번 있을 수 있습니다.
2738
+ content = content.split(i.force_encoding('utf-8')).join(""+'<inyonggoo src="">'+title+'</inyonggoo>'+"")
2695
2739
  end
2696
2740
  end
2741
+ end
2697
2742
 
2698
2743
  @data['table'][index][-1] = 80
2699
2744
  @data['table'] << []
@@ -2828,8 +2873,14 @@ class Wordpress
2828
2873
  end
2829
2874
 
2830
2875
 
2831
- if @data['포스트설정']['제목내용설정'].checked?
2832
- title = content.split("\n")[0]
2876
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
2877
+ title = content.split("\n")[0]
2878
+
2879
+ end
2880
+
2881
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
2882
+
2883
+ content = "#{title}\n" + content
2833
2884
  end
2834
2885
 
2835
2886
  if @data['포스트설정']['중앙정렬'].checked?
@@ -4168,21 +4219,29 @@ class Wordpress
4168
4219
  top 5
4169
4220
  left 0
4170
4221
  on_toggled{
4171
- if @data['포스트설정']['제목을랜덤'].checked? == true
4172
- if @data['포스트설정']['제목내용설정'].checked?
4173
- @data['포스트설정']['제목내용설정'].checked = false
4174
- end
4222
+ if @data['포스트설정']['제목을랜덤'].checked?
4223
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4224
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4175
4225
  end
4176
4226
  }
4177
4227
  }
4178
- @data['포스트설정']['제목내용설정'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4228
+ @data['포스트설정']['내용첫줄제목에입력'] = checkbox('내용의 첫 문장을 제목으로 설정'){
4179
4229
  top 6
4180
4230
  left 0
4181
4231
  on_toggled{
4182
- if @data['포스트설정']['제목내용설정'].checked? == true
4183
- if @data['포스트설정']['제목을랜덤'].checked?
4184
- @data['포스트설정']['제목을랜덤'].checked = false
4185
- end
4232
+ if @data['포스트설정']['내용첫줄제목에입력'].checked?
4233
+ @data['포스트설정']['제목을랜덤'].checked = false
4234
+ @data['포스트설정']['제목을내용첫줄입력'].checked = false
4235
+ end
4236
+ }
4237
+ }
4238
+ @data['포스트설정']['제목을내용첫줄입력'] = checkbox('제목을 내용 첫 줄에 넣기'){
4239
+ top 6
4240
+ left 1
4241
+ on_toggled{
4242
+ if @data['포스트설정']['제목을내용첫줄입력'].checked?
4243
+ @data['포스트설정']['내용첫줄제목에입력'].checked = false
4244
+ @data['포스트설정']['제목을랜덤'].checked = false
4186
4245
  end
4187
4246
  }
4188
4247
  }
@@ -4464,22 +4523,66 @@ class Wordpress
4464
4523
  left 1
4465
4524
  text 'ex) OO시 OO구 OO동 270-68'
4466
4525
  }
4467
- @data['포스트설정']['인용구변경'] = checkbox('내용 특정단어를 인용구로 적용'){
4526
+ @data['포스트설정']['인용구변경'] = checkbox('특정단어를 인용구로 적용'){
4468
4527
  top 11
4469
4528
  left 0
4529
+ on_toggled {
4530
+ if @data['포스트설정']['인용구변경'].checked?
4531
+ @data['포스트설정']['인용구제목사용'].enabled = true # '내용투명' 활성화
4532
+ @data['포스트설정']['인용구문구설정'].enabled = true # '내용투명' 활성화
4533
+ else
4534
+ @data['포스트설정']['인용구변경'].checked = false # 체크 해제
4535
+ @data['포스트설정']['인용구제목사용'].enabled = false # 비활성화
4536
+ @data['포스트설정']['인용구문구설정'].enabled = false # 비활성화
4537
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4538
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4539
+ end
4540
+ }
4470
4541
  }
4471
4542
  @data['포스트설정']['인용구변경단어'] = entry{
4472
4543
  top 11
4473
4544
  left 1
4474
4545
  text '특정단어'
4475
4546
  }
4476
- label('ㄴ인용구 사용시 들어갈 문구'){
4547
+ @data['포스트설정']['인용구제목사용'] = checkbox('인용구를 제목으로 삽입 설정'){
4477
4548
  top 12
4478
4549
  left 0
4550
+ enabled false # 기본적으로 비활성화
4551
+ on_toggled {
4552
+ if @data['포스트설정']['인용구제목사용'].checked?
4553
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4554
+ @data['포스트설정']['인용구문구설정'].enabled = false
4555
+ else
4556
+ @data['포스트설정']['인용구문구설정'].enabled = true
4557
+ end
4558
+ }
4559
+
4560
+ }
4561
+ #label('ㄴ인용구 사용시 들어갈 문구'){
4562
+ @data['포스트설정']['인용구문구설정'] = checkbox('인용구에 들어갈 문구 설정'){
4563
+ top 13
4564
+ left 0
4565
+ enabled false # 기본적으로 비활성화
4566
+
4567
+ on_toggled {
4568
+ if @data['포스트설정']['인용구문구설정'].checked?
4569
+ @data['포스트설정']['인용구제목사용'].checked = false
4570
+ @data['포스트설정']['인용구제목사용'].enabled = false
4571
+ @data['포스트설정']['인용구순서'].enabled = true # '내용투명' 활성화
4572
+ @data['포스트설정']['인용구랜덤'].enabled = true # '내용투명' 활성화
4573
+ else
4574
+ @data['포스트설정']['인용구문구설정'].checked = false # 체크 해제
4575
+ @data['포스트설정']['인용구순서'].enabled = false # 비활성화
4576
+ @data['포스트설정']['인용구랜덤'].enabled = false # 비활성화
4577
+ @data['포스트설정']['인용구제목사용'].enabled = true
4578
+ end
4579
+ }
4580
+
4479
4581
  }
4480
4582
  button('설정 파일 불러오기'){
4481
- top 12
4583
+ top 13
4482
4584
  left 1
4585
+
4483
4586
  on_clicked{
4484
4587
  file = open_file
4485
4588
  if file != nil
@@ -4487,6 +4590,27 @@ class Wordpress
4487
4590
  @data['포스트설정']['인용구'] = file_data.split(',')
4488
4591
  end
4489
4592
  }
4593
+ }
4594
+ @data['포스트설정']['인용구순서'] = checkbox('인용구 순서 사용'){
4595
+ top 14
4596
+ left 0
4597
+ enabled false # 기본적으로 비활성화
4598
+ on_toggled {
4599
+ if @data['포스트설정']['인용구순서'].checked?
4600
+ @data['포스트설정']['인용구랜덤'].checked = false
4601
+ end
4602
+ }
4603
+
4604
+ }
4605
+ @data['포스트설정']['인용구랜덤'] = checkbox('인용구 랜덤 사용'){
4606
+ top 14
4607
+ left 1
4608
+ enabled false # 기본적으로 비활성화
4609
+ on_toggled {
4610
+ if @data['포스트설정']['인용구랜덤'].checked?
4611
+ @data['포스트설정']['인용구순서'].checked = false
4612
+ end
4613
+ }
4490
4614
  }
4491
4615
  }
4492
4616
  }
@@ -4794,6 +4918,7 @@ class Wordpress
4794
4918
  @data['포스트설정']['복사,저장 허용'].checked = true
4795
4919
  @data['포스트설정']['자동출처 사용'].checked = false
4796
4920
  @data['포스트설정']['CCL사용'].checked = false
4921
+ @data['포스트설정']['인용구랜덤'].checked = true
4797
4922
  }.show
4798
4923
  end
4799
4924
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
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