cafe_basics_duo 0.0.13 → 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 +83 -51
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30048e436ccbc3af7f1c22f80a58d861e8fff04c51abb887f89425b094f4fbf6
4
- data.tar.gz: 84aeca8b4ed9f84c383f5a3496fef5f6f9e410c9b11fe647e6c58c3db44bcd08
3
+ metadata.gz: 28fd31024601888e363f1c6938e732e38cce01bdd96c3869d671b5cb9c66130d
4
+ data.tar.gz: 12eb99cf1cc77524d28e78114f58a279511ad2b6376e7535e1100b55b6e8d4bf
5
5
  SHA512:
6
- metadata.gz: a78c47d98202e4373b76d6e1103546e7e43c6699104cd865c6c54a85a1c7a5cfdd3236f4100ca0a08c54c2e32c8e70116ae5001040d29bcb9a873bc8b9228824
7
- data.tar.gz: 10a3523ea308321867c7712537fe9eb05bc278952348d95c238957a0f56907e542ca07755deb23d3bf8a55cc5cc3219d8d0d0e4b2607dc652d9c20379af8c959
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
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.13
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: 2025-01-06 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