cafe_buy 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_buy.rb +114 -68
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c43ab658ab2d2cfea1366d5c3d72e457c912eeda1e856677a07d7adec5d16c96
4
- data.tar.gz: a9ad0d2eea72432769c0f269ce16b1000a320d3cc12018878de7bc811c758e03
3
+ metadata.gz: cdb19c47bbf824faecc33e177f95ef30d216b4a0f8fda9e70bf498554f3e8edf
4
+ data.tar.gz: '0830f6204c8e7ff3d3e473606b40cdbc37ae88e9b31ce6aa8c9836f8943f7f4c'
5
5
  SHA512:
6
- metadata.gz: 8d9c84b42813ca91cbc46a1dfe18d11ae16e2fe231d9d2993bae18e551ca6ccee7d3c86f0eb53b18f72b4b8ee9e08957b36a94260a50da9a4f1fc38859dd44f3
7
- data.tar.gz: 69eab08b7240efa21d3988a3069700253641f4b723820da0c424500158ed5010d367b44142b27a83217388e1f8b20e2bf97d12100f77c5ee72b63a8b4b41b037
6
+ metadata.gz: '092a11aa09a0e85cbf0ca60ab7fc1238db674a12c2f76eb92d84e197328787fa4487bcf401648c8303a91f982c04547e7e2317e14bcba59bd3ccbdde2d3c6376'
7
+ data.tar.gz: 544e6edcad5d4e52f005def24b66b12e472675d4f009871f1a4aa16505edeb910e6c4fdd4cb10ec28829afa00d04e6dfe96eb1beedb40c155e22f8949c8f0acf
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
 
@@ -1057,21 +1073,23 @@ end
1057
1073
 
1058
1074
 
1059
1075
 
1060
- begin
1061
- @driver.action.key_down(:up).key_up(:up).perform
1062
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1063
- #요소가 나타날 때까지 60초 동안 기다립니다.
1064
- wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
1065
- sleep(1)
1066
- @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
1067
- sleep(1)
1068
- @driver.action.send_keys(title).perform
1069
- sleep(1)
1070
- @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1071
- sleep(1)
1072
- rescue
1073
- @driver.action.key_down(:down).key_up(:down).perform
1074
- end
1076
+ if option['사진타이틀'] == 'true'
1077
+ begin
1078
+ @driver.action.key_down(:up).key_up(:up).perform
1079
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1080
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1081
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
1082
+ sleep(1)
1083
+ @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
1084
+ sleep(1)
1085
+ @driver.action.send_keys(title).perform
1086
+ sleep(1)
1087
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1088
+ sleep(1)
1089
+ rescue
1090
+ @driver.action.key_down(:down).key_up(:down).perform
1091
+ end
1092
+ end
1075
1093
 
1076
1094
 
1077
1095
  if i2.to_s.split('href="')[1] != nil
@@ -1882,10 +1900,18 @@ class Wordpress
1882
1900
 
1883
1901
  def get_naver_text(q)
1884
1902
  begin
1885
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1886
- @driver = Selenium::WebDriver.for :chrome
1903
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1904
+ options = Selenium::WebDriver::Chrome::Options.new
1905
+ capabilities = [options]
1906
+
1907
+ # Selenium WebDriver에서 options를 capabilities로 전달
1908
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1887
1909
  rescue
1888
- @driver = Selenium::WebDriver.for :chrome
1910
+ # :capabilities에 options를 배열로 전달
1911
+ capabilities = [options]
1912
+
1913
+ # Selenium WebDriver에서 options를 capabilities로 전달
1914
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1889
1915
  end
1890
1916
  @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
1917
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1915,10 +1941,18 @@ class Wordpress
1915
1941
 
1916
1942
  def get_naver_text2(keyword)
1917
1943
  begin
1918
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1919
- @driver = Selenium::WebDriver.for :chrome
1944
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1945
+ options = Selenium::WebDriver::Chrome::Options.new
1946
+ capabilities = [options]
1947
+
1948
+ # Selenium WebDriver에서 options를 capabilities로 전달
1949
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1920
1950
  rescue
1921
- @driver = Selenium::WebDriver.for :chrome
1951
+ # :capabilities에 options를 배열로 전달
1952
+ capabilities = [options]
1953
+
1954
+ # Selenium WebDriver에서 options를 capabilities로 전달
1955
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1922
1956
  end
1923
1957
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1924
1958
  for n3 in 1..10
@@ -1956,6 +1990,7 @@ class Wordpress
1956
1990
 
1957
1991
 
1958
1992
 
1993
+
1959
1994
  #def chrome_start(url, user_id, user_pw)
1960
1995
  # @url = url
1961
1996
  # @user_id = user_id
@@ -3175,6 +3210,12 @@ class Wordpress
3175
3210
  option['CCL사용'] = 'false'
3176
3211
  end
3177
3212
 
3213
+ if @data['포스트설정']['사진타이틀'].checked?
3214
+ option['사진타이틀'] = 'true'
3215
+ else
3216
+ option['사진타이틀'] = 'false'
3217
+ end
3218
+
3178
3219
 
3179
3220
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3180
3221
  title = content.split("\n")[0]
@@ -4700,13 +4741,18 @@ class Wordpress
4700
4741
  text 'URL'
4701
4742
  }
4702
4743
 
4703
- @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4744
+ @data['포스트설정']['사진타이틀'] = checkbox('사진 등록시 사진 하단에 제목 넣기'){
4704
4745
  top 15+ aa1
4705
4746
  left 0
4706
4747
  }
4748
+
4749
+ @data['포스트설정']['ChatGPT사용'] = checkbox('Chat GPT 사용하기'){
4750
+ top 16+ aa1
4751
+ left 0
4752
+ }
4707
4753
 
4708
4754
  @data['포스트설정']['api_key'] = entry(){
4709
- top 15+ aa1
4755
+ top 16+ aa1
4710
4756
  left 1
4711
4757
  text 'api key 입력 필수!!'
4712
4758
  }
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.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