nblog_duo 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_duo.rb +119 -54
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1816747db89eebe1f8a7ba6e28bb72da736851301ee04d5492b072f77cd7dce
4
- data.tar.gz: a11b3c5879a9e551ae9db56c6dc65f68aac187f532976660c2ee5dab194e7c24
3
+ metadata.gz: 17f42ee4f623c4e35e948d3a44d8cf0a30450570b343a1f52005d9db7c0bc283
4
+ data.tar.gz: b4062f17e17f363792599221e9f580165c9bb880932963f890a2135cba088443
5
5
  SHA512:
6
- metadata.gz: 696eb31afeebb10e6376019a742fc1aba53b3deeec862c4b2a1b1c40ca4fd98c518e9c112881547607b0fbd5e11721e9f93064ef0e63616fde266cb6afdf4d6a
7
- data.tar.gz: 7676387c5a84e5b1d5f0a3df48a37f126cb8db5c3cd67ccd09560a6c797531c57b8a53eee8c4e5327ac9be3134bcb9cf706c20dd4173ae9460400a337f61fe2c
6
+ metadata.gz: dcc25f1d736ad277732d3f7fa6671f629d3bcfb09c895517b31499ca145f55c6315822d61e5a66a6ec1bc3109b58c9ce93984281b2df9fb5a4c3f1ccc31f648c
7
+ data.tar.gz: 6085efc480923a1e9c45ea4e8111c03cbe5358c20fd9d9b35a53d6c6c7545bd2926ca24b35e2f4f39565a6a51604aeb2b1c38e3a0075b0107913844d2fce51e2
data/lib/nblog_duo.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,88 @@ 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
266
299
 
267
300
 
268
301
 
@@ -1686,10 +1719,18 @@ class Wordpress
1686
1719
 
1687
1720
  def get_naver_text(q)
1688
1721
  begin
1689
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1690
- @driver = Selenium::WebDriver.for :chrome
1722
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1723
+ options = Selenium::WebDriver::Chrome::Options.new
1724
+ capabilities = [options]
1725
+
1726
+ # Selenium WebDriver에서 options를 capabilities로 전달
1727
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1691
1728
  rescue
1692
- @driver = Selenium::WebDriver.for :chrome
1729
+ # :capabilities에 options를 배열로 전달
1730
+ capabilities = [options]
1731
+
1732
+ # Selenium WebDriver에서 options를 capabilities로 전달
1733
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1693
1734
  end
1694
1735
  @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')
1695
1736
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1719,10 +1760,18 @@ class Wordpress
1719
1760
 
1720
1761
  def get_naver_text2(keyword)
1721
1762
  begin
1722
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1723
- @driver = Selenium::WebDriver.for :chrome
1763
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1764
+ options = Selenium::WebDriver::Chrome::Options.new
1765
+ capabilities = [options]
1766
+
1767
+ # Selenium WebDriver에서 options를 capabilities로 전달
1768
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1724
1769
  rescue
1725
- @driver = Selenium::WebDriver.for :chrome
1770
+ # :capabilities에 options를 배열로 전달
1771
+ capabilities = [options]
1772
+
1773
+ # Selenium WebDriver에서 options를 capabilities로 전달
1774
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1726
1775
  end
1727
1776
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1728
1777
  for n3 in 1..10
@@ -1764,10 +1813,26 @@ class Wordpress
1764
1813
  @user_id = user_id
1765
1814
  @user_pw = user_pw
1766
1815
  begin
1767
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1768
- @driver = Selenium::WebDriver.for :chrome
1816
+ #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1817
+ options = Selenium::WebDriver::Chrome::Options.new
1818
+ options.page_load_strategy = :normal
1819
+ options.timeouts = {page_load: 20_000}
1820
+ options.page_load_strategy = 'none'
1821
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
1822
+
1823
+ options.add_argument('--remote-debugging-port=9222')
1824
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
1825
+ # :capabilities에 options를 배열로 전달
1826
+ capabilities = [options]
1827
+
1828
+ # Selenium WebDriver에서 options를 capabilities로 전달
1829
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1769
1830
  rescue
1770
- @driver = Selenium::WebDriver.for :chrome
1831
+ # :capabilities에 options를 배열로 전달
1832
+ capabilities = [options]
1833
+
1834
+ # Selenium WebDriver에서 options를 capabilities로 전달
1835
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1771
1836
  end
1772
1837
  end
1773
1838
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_duo
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: mymin26@naver.com