nblog_zon 0.0.36 → 0.0.39

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/nblog_zon.rb +120 -54
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6546b50d3644389bd74854531fdbba7e5f12f9c1c1aeca3eb5ecb832fd926c45
4
- data.tar.gz: 0737ec97d0352bbb09905b323455445cedfcc99639d9648186233a1646095547
3
+ metadata.gz: 8ab911e4f459ffa2c826c80a3352a4323f02564758de4bac5aa1f8910938ddf0
4
+ data.tar.gz: 32933e515ae9ce444e824a30dbe11459e1d05aeee16b80a70dbb79813a1dcd7a
5
5
  SHA512:
6
- metadata.gz: 6184b4281cbc7cac4d4378f5cc76060dc8770a731239365c90bf71cc86334a214e7870e8266216792c7c757fd2d7f4adb9bc34a5f5c0efe457d5b8b9b646169c
7
- data.tar.gz: 310ab0ce7916891c23169c55a7ab32bfa7089c26e0dc5434a94333b6a23f26851d7a74541914a814352a47d123948aa2f3e76c9a9e1467a114074144fafc441f
6
+ metadata.gz: '068e79acff717dedeecf847dc1e629c0f2a4dc92f27c160b2815bc17b6024e2fa9f0ad6fd2229347c17169c9c54f2215fb5d7f28a3b11a0c7bb5edfa0822be83'
7
+ data.tar.gz: c89a2fa936113c3b2dc9c2106143d23c02ff9825d8c62451ccbf32102edba1c28c1a173622e12bdb92e414e4b2bc1b14e08e645a55aca40704e5318d729aef78
data/lib/nblog_zon.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'
@@ -214,55 +214,89 @@ class Naver
214
214
  def chrome_start(proxy, user_id)
215
215
  naver_cookie_dir = "C:/naver_cookie"
216
216
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
217
+
218
+ chromedriver_path = './chromedriver.exe'
219
+
220
+ # 웹드라이버 자동 업데이트 시도
221
+ begin
222
+ # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
223
+ Webdrivers::Chromedriver.update # 자동 업데이트 시도
224
+ rescue => e
225
+ puts "webdrivers에서 chromedriver 다운로드 실패: #{e.message}"
226
+ puts "자동으로 chromedriver.exe 사용합니다."
227
+ puts "만일 프로그램 폴더안에 chromedriver.exe 버전이 맞지 않거나 없는 경우 인터넷창이 깜빡하고 닫히거나 열리지 않는경우에만 아래 안내를 따라주세요."
228
+ puts "https://storage.googleapis.com/chrome-for-testing-public/사용자크롬버전/win32/chromedriver-win32.zip 링크를 복사 후 복사 된 링크 중(사용자크롬버전) 부분을 크롬 사용자의 버전(예:131.0.6778.264)으로 수정 후 주소입력 부분에 넣어 엔터 후 다운로드 하고 압축을 풀고 chromedriver.exe 파일만 프로그램 폴더안에 넣어주세요."
229
+ puts "인터넷 창이 열리고 작업을 한다면 위 항목은 패스해주세요."
230
+ # 예외가 발생하면 수동 경로 사용
231
+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
232
+ end
233
+
217
234
  if proxy == ''
218
- begin
219
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
220
- options = Selenium::WebDriver::Chrome::Options.new
221
- options.page_load_strategy = :normal
222
- options.timeouts = {page_load: 20_000}
223
- options.page_load_strategy = 'none'
224
- options.add_argument('--remote-debugging-port=9222')
225
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
226
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
227
- rescue
228
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
229
- end
235
+ begin
236
+ # webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
237
+ options = Selenium::WebDriver::Chrome::Options.new
238
+ options.page_load_strategy = :normal
239
+ options.timeouts = { page_load: 20_000 }
240
+ options.page_load_strategy = 'none'
241
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
242
+ options.add_argument('--disable-gpu')
243
+
244
+
245
+ options.add_argument('--remote-debugging-port=9222')
246
+ options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
247
+
248
+ # :capabilities에 options를 배열로 전달
249
+ capabilities = [options]
250
+
251
+ # Selenium WebDriver에서 options를 capabilities로 전달
252
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
253
+ rescue
254
+ # 예외 발생 시 다른 방법으로 셀레니움 실행
255
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
256
+ end
230
257
  else
258
+ begin
259
+ # Proxy를 사용하는 경우
260
+ options = Selenium::WebDriver::Chrome::Options.new
261
+ options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
262
+ options.page_load_strategy = :normal
263
+ options.timeouts = { page_load: 20_000 }
264
+ options.page_load_strategy = 'none'
265
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
266
+ options.add_argument('--disable-gpu')
267
+ options.add_argument('--remote-debugging-port=9222')
268
+ options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
269
+
270
+ # :capabilities에 options를 배열로 전달
271
+ capabilities = [options]
272
+
273
+ # Selenium WebDriver에서 options를 capabilities로 전달
274
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
275
+ rescue => e
276
+ puts 'proxy error...'
231
277
  begin
232
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
233
- options = Selenium::WebDriver::Chrome::Options.new
234
- # profile = Selenium::WebDriver::Chrome::Profile.new
235
- # profile['network.proxy.type'] = 1
236
- # profile['network.proxy.http'] = proxy.split(':')[0]
237
- # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
238
- # options = Selenium::WebDriver::Chrome::Options.new
239
- # options.profile = profile
240
- options = Selenium::WebDriver::Chrome::Options.new
241
- options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
242
- options.page_load_strategy = :normal
243
- options.timeouts = {page_load: 20_000}
244
- options.page_load_strategy = 'none'
245
- options.add_argument('--remote-debugging-port=9222')
246
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
247
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
248
- rescue => e
249
- puts e
250
- puts 'proxy error...'
251
- begin
252
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
253
- options = Selenium::WebDriver::Chrome::Options.new
254
- options.page_load_strategy = :normal
255
- options.timeouts = {page_load: 20_000}
256
- options.page_load_strategy = 'none'
257
- options.add_argument('--remote-debugging-port=9222')
258
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
259
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
260
- rescue
261
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
262
- end
278
+ # Proxy가 실패할 경우 예외 처리
279
+ options = Selenium::WebDriver::Chrome::Options.new
280
+ options.page_load_strategy = :normal
281
+ options.timeouts = { page_load: 20_000 }
282
+ options.page_load_strategy = 'none'
283
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
284
+ options.add_argument('--disable-gpu')
285
+ options.add_argument('--remote-debugging-port=9222')
286
+ options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
287
+
288
+ # :capabilities에 options 배열로 전달
289
+ capabilities = [options]
290
+
291
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
292
+ rescue
293
+ # 예외 발생 다른 방법으로 셀레니움 실행
294
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
263
295
  end
296
+ end
264
297
  end
265
- end
298
+ end
299
+
266
300
 
267
301
 
268
302
 
@@ -1617,10 +1651,18 @@ class Wordpress
1617
1651
 
1618
1652
  def get_naver_text(q)
1619
1653
  begin
1620
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1621
- @driver = Selenium::WebDriver.for :chrome
1654
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1655
+ options = Selenium::WebDriver::Chrome::Options.new
1656
+ capabilities = [options]
1657
+
1658
+ # Selenium WebDriver에서 options를 capabilities로 전달
1659
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1622
1660
  rescue
1623
- @driver = Selenium::WebDriver.for :chrome
1661
+ # :capabilities에 options를 배열로 전달
1662
+ capabilities = [options]
1663
+
1664
+ # Selenium WebDriver에서 options를 capabilities로 전달
1665
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1624
1666
  end
1625
1667
  @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')
1626
1668
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1650,10 +1692,18 @@ class Wordpress
1650
1692
 
1651
1693
  def get_naver_text2(keyword)
1652
1694
  begin
1653
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1654
- @driver = Selenium::WebDriver.for :chrome
1695
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1696
+ options = Selenium::WebDriver::Chrome::Options.new
1697
+ capabilities = [options]
1698
+
1699
+ # Selenium WebDriver에서 options를 capabilities로 전달
1700
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1655
1701
  rescue
1656
- @driver = Selenium::WebDriver.for :chrome
1702
+ # :capabilities에 options를 배열로 전달
1703
+ capabilities = [options]
1704
+
1705
+ # Selenium WebDriver에서 options를 capabilities로 전달
1706
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1657
1707
  end
1658
1708
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1659
1709
  for n3 in 1..10
@@ -1695,10 +1745,26 @@ class Wordpress
1695
1745
  @user_id = user_id
1696
1746
  @user_pw = user_pw
1697
1747
  begin
1698
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1699
- @driver = Selenium::WebDriver.for :chrome
1748
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1749
+ options = Selenium::WebDriver::Chrome::Options.new
1750
+ options.page_load_strategy = :normal
1751
+ options.timeouts = {page_load: 20_000}
1752
+ options.page_load_strategy = 'none'
1753
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
1754
+
1755
+ options.add_argument('--remote-debugging-port=9222')
1756
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
1757
+ # :capabilities에 options를 배열로 전달
1758
+ capabilities = [options]
1759
+
1760
+ # Selenium WebDriver에서 options를 capabilities로 전달
1761
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1700
1762
  rescue
1701
- @driver = Selenium::WebDriver.for :chrome
1763
+ # :capabilities에 options를 배열로 전달
1764
+ capabilities = [options]
1765
+
1766
+ # Selenium WebDriver에서 options를 capabilities로 전달
1767
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1702
1768
  end
1703
1769
  end
1704
1770
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.39
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: rnjstnswp123@naver.com