cafe_basics 0.0.13 → 0.0.17

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.rb +113 -81
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7baec420eb1e6e2314695f6d00f1b4f8a17ecd15e91154308c9caa885a22410
4
- data.tar.gz: 05ecfa5bf82804f8ea6317726bc7f00f6a1f94e6fbe6bd06a0ea0180816c47d8
3
+ metadata.gz: da1c8c7a15888c18812deaa66dc7e24d50f129ddf4fb2d6acccf4f49762745f3
4
+ data.tar.gz: 2b2d5fe9ffc44a8155e3897c3a6ccf0da8ad62b99225ec2e60e939c46f178292
5
5
  SHA512:
6
- metadata.gz: 6b761dc8b152f0ecde740622b5ad623800533c1602775a7c2b0fc58d68bcefae3b105aec9be7a0becdf30f11fd7a3e05b3a48ec1dedbf3fd3e2c46fad465bd90
7
- data.tar.gz: 8b9d48995da87ba287354f4f68e3732bb7f8b3273905905a2a1b479ffda194c396591a086b76b4d859f9e663cabd5676c5e0ed4bc9430ab4405042465b310500
6
+ metadata.gz: 88b2d0a0dcc47cc556e1f4a3e4a87c5181b13bde29239648b02cf45c022cf4835f413f36613f6cc351513636b1a24c70af279ac56a06341df74d99941353b56a
7
+ data.tar.gz: 2f5ccecbc2ca0692eab295184cae46fa37c2a7eb229feb73eea80a5ed47d18f1af632e2f0367d097224100c0e18435e0b89daa5f346f5679f9309eab90bb1e8e
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
 
@@ -738,21 +754,23 @@ class Naver
738
754
 
739
755
 
740
756
 
741
- begin
742
- @driver.action.key_down(:up).key_up(:up).perform
743
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
744
- #요소가 나타날 때까지 60초 동안 기다립니다.
745
- wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
746
- sleep(1)
747
- @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
748
- sleep(1)
749
- @driver.action.send_keys(title).perform
750
- sleep(1)
751
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
752
- sleep(1)
753
- rescue
754
- @driver.action.key_down(:down).key_up(:down).perform
755
- end
757
+ if option['사진타이틀'] == 'true'
758
+ begin
759
+ @driver.action.key_down(:up).key_up(:up).perform
760
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
761
+ #요소가 나타날 때까지 60초 동안 기다립니다.
762
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
763
+ sleep(1)
764
+ @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
765
+ sleep(1)
766
+ @driver.action.send_keys(title).perform
767
+ sleep(1)
768
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
769
+ sleep(1)
770
+ rescue
771
+ @driver.action.key_down(:down).key_up(:down).perform
772
+ end
773
+ end
756
774
 
757
775
 
758
776
  if i2.to_s.split('href="')[1] != nil
@@ -1568,10 +1586,18 @@ class Wordpress
1568
1586
 
1569
1587
  def get_naver_text(q)
1570
1588
  begin
1571
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1572
- @driver = Selenium::WebDriver.for :chrome
1589
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1590
+ options = Selenium::WebDriver::Chrome::Options.new
1591
+ capabilities = [options]
1592
+
1593
+ # Selenium WebDriver에서 options를 capabilities로 전달
1594
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1573
1595
  rescue
1574
- @driver = Selenium::WebDriver.for :chrome
1596
+ # :capabilities에 options를 배열로 전달
1597
+ capabilities = [options]
1598
+
1599
+ # Selenium WebDriver에서 options를 capabilities로 전달
1600
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1575
1601
  end
1576
1602
  @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
1603
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1601,10 +1627,18 @@ class Wordpress
1601
1627
 
1602
1628
  def get_naver_text2(keyword)
1603
1629
  begin
1604
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1605
- @driver = Selenium::WebDriver.for :chrome
1630
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1631
+ options = Selenium::WebDriver::Chrome::Options.new
1632
+ capabilities = [options]
1633
+
1634
+ # Selenium WebDriver에서 options를 capabilities로 전달
1635
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1606
1636
  rescue
1607
- @driver = Selenium::WebDriver.for :chrome
1637
+ # :capabilities에 options를 배열로 전달
1638
+ capabilities = [options]
1639
+
1640
+ # Selenium WebDriver에서 options를 capabilities로 전달
1641
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1608
1642
  end
1609
1643
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1610
1644
  for n3 in 1..10
@@ -1641,19 +1675,6 @@ class Wordpress
1641
1675
 
1642
1676
 
1643
1677
 
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
1678
 
1658
1679
  #def chrome_start(url, user_id, user_pw)
1659
1680
  # @url = url
@@ -2853,6 +2874,12 @@ class Wordpress
2853
2874
  option['CCL사용'] = 'false'
2854
2875
  end
2855
2876
 
2877
+ if @data['포스트설정']['사진타이틀'].checked?
2878
+ option['사진타이틀'] = 'true'
2879
+ else
2880
+ option['사진타이틀'] = 'false'
2881
+ end
2882
+
2856
2883
 
2857
2884
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
2858
2885
  title = content.split("\n")[0]
@@ -4380,13 +4407,18 @@ class Wordpress
4380
4407
  text 'URL'
4381
4408
  }
4382
4409
 
4383
- @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4410
+ @data['포스트설정']['사진타이틀'] = checkbox('사진 등록시 사진 하단에 제목 넣기'){
4384
4411
  top 15+ aa1
4385
4412
  left 0
4386
4413
  }
4414
+
4415
+ @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4416
+ top 16+ aa1
4417
+ left 0
4418
+ }
4387
4419
 
4388
4420
  @data['포스트설정']['api_key'] = entry(){
4389
- top 15+ aa1
4421
+ top 16+ aa1
4390
4422
  left 1
4391
4423
  text 'api key 입력 필수!!'
4392
4424
  }
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.13
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-01-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com