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.
- checksums.yaml +4 -4
- data/lib/nblog_zon.rb +120 -54
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab911e4f459ffa2c826c80a3352a4323f02564758de4bac5aa1f8910938ddf0
|
4
|
+
data.tar.gz: 32933e515ae9ce444e824a30dbe11459e1d05aeee16b80a70dbb79813a1dcd7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
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
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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
|