cafe_buy 0.0.19 → 0.0.23

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 +131 -158
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efba79ba777e4f5f3c157c74d8de5ff7c1d169aceec7013b546d4e2f25024326
4
- data.tar.gz: b0fdab87c726df8d98e9b3da9206e212835f95dbf182c293ab634f5b8fc4a0cb
3
+ metadata.gz: 859484ea08e31a60b002a4af5cfd7dae3c580986991b8d7d666d5337bbb9af87
4
+ data.tar.gz: 1258dfaaba102713ec0e8223b81278def3334f68fb5c66dd430ab0f1750e3783
5
5
  SHA512:
6
- metadata.gz: 4dc9ffc70cf24c68309d4f8b39e9a72a49444fde0c2f7e75ae0f3e38e37334b768cf53ea8576b6ff21721fbacee503d0bda544c8a0fe53ed8b2661e0bac17418
7
- data.tar.gz: f408ed118dd32f058fa70964550ddc962783dba729a2314ad6aa37e4d1e59ee05c386783c41b830bd9a038396345bc990e90ac28871681586f9e986e36d9ca45
6
+ metadata.gz: ff6ad27a089ed44c68e2962aa7344b170624575e02df71d589be552f35b358752c511d3b72b8a843308164a22bc60438cb8e6ba25fdac6e17270ee2f89ac252c
7
+ data.tar.gz: 47357b7f5e1dbd4348110a64fdfedaa7cc8020836093a50dba9698d1dbc575f28a2e4864670df78850ef9d746c1c16d0d2460569c264b812022f10d829a914ca
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,87 +219,61 @@ 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
-
223
- chromedriver_path = './chromedriver.exe'
224
-
225
- # 웹드라이버 자동 업데이트 시도
226
- begin
227
- # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
228
- Webdrivers::Chromedriver.update # 자동 업데이트 시도
229
- rescue => e
230
- puts "webdrivers에서 chromedriver 다운로드 실패: #{e.message}"
231
- puts "자동으로 chromedriver.exe 사용합니다."
232
- puts "만일 프로그램 폴더안에 chromedriver.exe 버전이 맞지 않거나 없는 경우 인터넷창이 깜빡하고 닫히거나 열리지 않는경우에만 아래 안내를 따라주세요."
233
- puts "https://storage.googleapis.com/chrome-for-testing-public/사용자크롬버전/win32/chromedriver-win32.zip 링크를 복사 후 복사 된 링크 중(사용자크롬버전) 부분을 크롬 사용자의 버전(예:131.0.6778.264)으로 수정 후 주소입력 부분에 넣어 엔터 후 다운로드 하고 압축을 풀고 chromedriver.exe 파일만 프로그램 폴더안에 넣어주세요."
234
- puts "인터넷 창이 열리고 작업을 한다면 위 항목은 패스해주세요."
235
- # 예외가 발생하면 수동 경로 사용
236
- Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
237
- end
238
-
239
222
  if proxy == ''
240
- begin
241
- # webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
242
- options = Selenium::WebDriver::Chrome::Options.new
243
- options.page_load_strategy = :normal
244
- options.timeouts = { page_load: 20_000 }
245
- options.page_load_strategy = 'none'
246
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
247
-
248
-
249
-
250
- options.add_argument('--remote-debugging-port=9222')
251
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
252
-
253
- # :capabilities에 options를 배열로 전달
254
- capabilities = [options]
255
-
256
- # Selenium WebDriver에서 options를 capabilities로 전달
257
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
258
- rescue
259
- # 예외 발생 시 다른 방법으로 셀레니움 실행
260
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
261
- end
262
- else
263
- begin
264
- # Proxy를 사용하는 경우
265
- options = Selenium::WebDriver::Chrome::Options.new
266
- options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
267
- options.page_load_strategy = :normal
268
- options.timeouts = { page_load: 20_000 }
269
- options.page_load_strategy = 'none'
270
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
271
-
272
- options.add_argument('--remote-debugging-port=9222')
273
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
274
-
275
- # :capabilities에 options를 배열로 전달
276
- capabilities = [options]
277
-
278
- # Selenium WebDriver에서 options를 capabilities로 전달
279
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
280
- rescue => e
281
- puts 'proxy error...'
282
223
  begin
283
- # Proxy가 실패할 경우 예외 처리
284
- options = Selenium::WebDriver::Chrome::Options.new
285
- options.page_load_strategy = :normal
286
- options.timeouts = { page_load: 20_000 }
287
- options.page_load_strategy = 'none'
288
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
289
- options.add_argument('--remote-debugging-port=9222')
290
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
291
-
292
- # :capabilities options를 배열로 전달
293
- capabilities = [options]
294
-
295
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
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('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
230
+ options.add_argument('--disable-gpu')
231
+ options.add_argument('--remote-debugging-port=9222')
232
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
233
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
296
234
  rescue
297
- # 예외 발생 다른 방법으로 셀레니움 실행
298
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
235
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
236
+ end
237
+ else
238
+ begin
239
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
240
+ options = Selenium::WebDriver::Chrome::Options.new
241
+ # profile = Selenium::WebDriver::Chrome::Profile.new
242
+ # profile['network.proxy.type'] = 1
243
+ # profile['network.proxy.http'] = proxy.split(':')[0]
244
+ # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
245
+ # options = Selenium::WebDriver::Chrome::Options.new
246
+ # options.profile = profile
247
+ options = Selenium::WebDriver::Chrome::Options.new
248
+ options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
249
+ options.page_load_strategy = :normal
250
+ options.timeouts = {page_load: 20_000}
251
+ options.page_load_strategy = 'none'
252
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
253
+ options.add_argument('--disable-gpu')
254
+ options.add_argument('--remote-debugging-port=9222')
255
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
256
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
257
+ rescue => e
258
+ puts e
259
+ puts 'proxy error...'
260
+ begin
261
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
262
+ options = Selenium::WebDriver::Chrome::Options.new
263
+ options.page_load_strategy = :normal
264
+ options.timeouts = {page_load: 20_000}
265
+ options.page_load_strategy = 'none'
266
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
267
+ options.add_argument('--disable-gpu')
268
+ options.add_argument('--remote-debugging-port=9222')
269
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
270
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
271
+ rescue
272
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
273
+ end
299
274
  end
300
- end
301
275
  end
302
- end
276
+ end
303
277
 
304
278
 
305
279
 
@@ -1590,11 +1564,11 @@ end
1590
1564
  end
1591
1565
  end
1592
1566
  end
1593
- sleep(1)
1567
+ sleep(0.5)
1594
1568
  @driver.action.key_down(:end).key_up(:end).perform
1595
- sleep(1)
1569
+ sleep(0.5)
1596
1570
  @driver.action.key_down(:enter).key_up(:enter).perform
1597
- sleep(1)
1571
+ sleep(0.5)
1598
1572
  # if check_image == 0
1599
1573
  # if value_data['nodes'].length == 0
1600
1574
  # value_data['nodes'][0] = {
@@ -1692,88 +1666,100 @@ end
1692
1666
  tags2.split(',').each do |tag_value|
1693
1667
  tag_mm2 << ''+tag_value
1694
1668
  end
1695
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[4]/div/div/input').send_keys(tag_mm2.join("\n")+"\n")
1669
+ @driver.find_element(:xpath, '//*[@placeholder="태그를 입력해주세요 (최대 10개)"]').send_keys(tag_mm2.join("\n")+"\n")
1696
1670
 
1697
1671
  sleep(1)
1698
- # data['populationParams'] = '{"configuration":{"openType":'+option['공개']+',"commentYn":'+option['댓글허용']+',"searchYn":'+option['검색허용']+',"sympathyYn":'+option['공감허용']+',"scrapType":'+option['블로그공유']+',"outSideAllowYn":'+option['외부공유허용']+',"twitterPostingYn":false,"facebookPostingYn":false,"cclYn":false},"populationMeta":{"categoryId":'+category_value+',"logNo":null,"directorySeq":0,"directoryDetail":null,"mrBlogTalkCode":null,"postWriteTimeType":"now","tags":"'+tags2+'","moviePanelParticipation":false,"greenReviewBannerYn":false,"continueSaved":false,"noticePostYn":false,"autoByCategoryYn":false,"postLocationSupportYn":false,"postLocationJson":null,"prePostDate":null,"thisDayPostInfo":null,"scrapYn":false,"autoSaveNo":'+(Time.now.to_f.round(3)*1000).to_i.to_s+'},"editorSource":"AbZmtbYiAmhrzPJyhPXNWg=="}'
1699
- # if option['공개'] == '2'
1700
- # @driver.find_element(:xpath ,'//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[1]/span/label').click
1701
- # elsif option['공개'] == '3'
1702
- # @driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[3]/span/label').click
1703
- # elsif option['공개'] == '0'
1704
- # @driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[4]/span/label').click
1705
- # else
1706
- # @driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[2]/span/label').click
1707
- # end
1672
+
1673
+ if option['전체공개'] == 'true'
1674
+ puts '전체공개'
1675
+ begin
1676
+ @driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
1677
+ sleep(2)
1678
+ @driver.find_element(:xpath, '//*[@for="all"]').click
1679
+ rescue
1680
+ end
1681
+ sleep(1)
1682
+ end
1683
+
1684
+ if option['멤버공개'] == 'true'
1685
+ puts '멤버공개'
1686
+ begin
1687
+ @driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
1688
+ sleep(2)
1689
+ @driver.find_element(:xpath, '//*[@for="member"]').click
1690
+ rescue
1691
+ end
1692
+ sleep(1)
1693
+ end
1694
+
1708
1695
  if option['댓글허용'] == 'true'
1709
1696
  puts '댓글허용'
1710
- begin
1711
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[1]/div/label').click
1712
-
1713
- rescue
1714
-
1697
+ begin
1698
+ @driver.find_element(:xpath, '//*[@for="coment"]').click
1699
+ rescue
1700
+ end
1701
+ sleep(1)
1715
1702
  end
1716
- end
1717
1703
 
1718
- sleep(1)
1704
+
1719
1705
  if option['블로그,카페 공유허용'] == 'true'
1720
1706
  puts '블로그,카페 공유허용'
1721
1707
  begin
1722
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[2]/div[1]/label').click
1723
- rescue
1724
-
1708
+ @driver.find_element(:xpath, '//*[@for="blog_sharing"]').click
1709
+ rescue
1710
+ end
1711
+ sleep(1)
1725
1712
  end
1726
- end
1727
1713
 
1728
1714
 
1729
- sleep(1)
1715
+
1730
1716
  if option['외부공유허용'] == 'true'
1731
1717
  puts '외부공유허용'
1732
1718
  begin
1733
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[3]/div[1]/label').click
1734
- rescue
1735
-
1719
+ @driver.find_element(:xpath, '//*[@for="external_sharing"]').click
1720
+ rescue
1721
+ end
1722
+ sleep(1)
1736
1723
  end
1737
- end
1738
1724
 
1739
- sleep(1)
1725
+
1740
1726
 
1741
1727
  if option['복사,저장 허용'] == 'true'
1742
1728
  puts '복사,저장 허용'
1743
1729
  begin
1744
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[4]/div[1]/label').click
1745
- rescue
1746
-
1730
+ @driver.find_element(:xpath, '//*[@for="copy"]').click
1731
+ rescue
1732
+ end
1733
+ sleep(1)
1747
1734
  end
1748
- end
1749
1735
 
1750
- sleep(1)
1736
+
1751
1737
  if option['자동출처 사용'] == 'true'
1752
- puts '자동출처 사용'
1753
- begin
1754
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[5]/div[1]/label').click
1755
- rescue
1756
-
1757
- end
1758
- end
1738
+ puts '자동출처 사용'
1739
+ begin
1740
+ @driver.find_element(:xpath, '//*[@for="automatic_source"]').click
1741
+ rescue
1742
+ end
1743
+ sleep(1)
1744
+ end
1759
1745
 
1760
- sleep(1)
1746
+
1761
1747
 
1762
1748
  if option['CCL 사용'] == 'true'
1763
1749
  puts 'CCL 사용'
1764
1750
  begin
1765
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[6]/div[1]/label').click
1766
- rescue
1767
-
1751
+ @driver.find_element(:xpath, '//*[@for="ccl"]').click
1752
+ rescue
1753
+ end
1754
+ sleep(1)
1768
1755
  end
1769
- end
1770
- sleep(1)
1756
+
1771
1757
  # puts data['documentModel'] = data['documentModel'].to_json
1772
- sleep(2)
1758
+
1773
1759
  sleep(dd_time.to_i)
1774
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[1]/div/a').click
1760
+ @driver.find_element(:xpath, '//*[@class="BaseButton BaseButton--skinGreen size_default"]').click
1775
1761
 
1776
- sleep(10)
1762
+ sleep(7)
1777
1763
 
1778
1764
 
1779
1765
  begin
@@ -1916,18 +1902,10 @@ class Wordpress
1916
1902
 
1917
1903
  def get_naver_text(q)
1918
1904
  begin
1919
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1920
- options = Selenium::WebDriver::Chrome::Options.new
1921
- capabilities = [options]
1922
-
1923
- # Selenium WebDriver에서 options를 capabilities로 전달
1924
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1905
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1906
+ @driver = Selenium::WebDriver.for :chrome
1925
1907
  rescue
1926
- # :capabilities에 options를 배열로 전달
1927
- capabilities = [options]
1928
-
1929
- # Selenium WebDriver에서 options를 capabilities로 전달
1930
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1908
+ @driver = Selenium::WebDriver.for :chrome
1931
1909
  end
1932
1910
  @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')
1933
1911
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1957,18 +1935,10 @@ class Wordpress
1957
1935
 
1958
1936
  def get_naver_text2(keyword)
1959
1937
  begin
1960
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1961
- options = Selenium::WebDriver::Chrome::Options.new
1962
- capabilities = [options]
1963
-
1964
- # Selenium WebDriver에서 options를 capabilities로 전달
1965
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1938
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1939
+ @driver = Selenium::WebDriver.for :chrome
1966
1940
  rescue
1967
- # :capabilities에 options를 배열로 전달
1968
- capabilities = [options]
1969
-
1970
- # Selenium WebDriver에서 options를 capabilities로 전달
1971
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1941
+ @driver = Selenium::WebDriver.for :chrome
1972
1942
  end
1973
1943
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1974
1944
  for n3 in 1..10
@@ -3180,14 +3150,17 @@ class Wordpress
3180
3150
  option['배달'] = [@data['포스트설정']['직거래'].checked?, @data['포스트설정']['택배 거래'].checked?, @data['포스트설정']['온라인전송'].checked?]
3181
3151
  option['직 거래 카테고리'] = product_category1
3182
3152
  option['결제'] = payment
3153
+
3183
3154
  if @data['포스트설정']['전체공개'].checked?
3184
- option['공개'] = '2'
3185
- # elsif @data['포스트설정']['서로이웃공개'].checked?
3186
- # option['공개'] = '3'
3187
- # elsif @data['포스트설정']['비공개'].checked?
3188
- # option['공개'] = '0'
3155
+ option['전체공개'] = 'true'
3156
+ else
3157
+ option['전체공개'] = 'false'
3158
+ end
3159
+
3160
+ if @data['포스트설정']['멤버공개'].checked?
3161
+ option['멤버공개'] = 'true'
3189
3162
  else
3190
- option['공개'] = '1'
3163
+ option['멤버공개'] = 'false'
3191
3164
  end
3192
3165
 
3193
3166
  if @data['포스트설정']['댓글허용'].checked?
@@ -5130,7 +5103,7 @@ class Wordpress
5130
5103
  end
5131
5104
  }
5132
5105
  }
5133
- @data['포스트설정']['멤버공개'] = checkbox('맴버공개'){
5106
+ @data['포스트설정']['멤버공개'] = checkbox('멤버공개'){
5134
5107
  top 10
5135
5108
  left 1
5136
5109
  on_toggled{
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.19
4
+ version: 0.0.23
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-10 00:00:00.000000000 Z
11
+ date: 2025-01-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com