nblog_duo 0.0.36 → 0.0.37
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_duo.rb +102 -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: 4539d9eef87fcc3e0e69b5c7d27e98fb4415232a0c2bcaa728cc4917781afe09
|
4
|
+
data.tar.gz: b58cc6a540103146d02dbb9e092b67610ad66a82e2ce0a5a8f19584832566a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15027ea61c7590166c54192b0e44a3ec6aaef802a84f62f9a460bb12cc2db97156cbbb8c5f1fb812e363756f48580caaaa25fa6b55110557fe7d958b5ad59cb7
|
7
|
+
data.tar.gz: 4e393089fa678b682f9c03788fad37356c5bbaf2654c9cb3d5fe2a758ba10c8af715cff3e1aea82c12f864698ff3637111d8a118a5ba4a2042030704dd9e7cc8
|
data/lib/nblog_duo.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,71 @@ 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
|
+
|
217
218
|
if proxy == ''
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
219
|
+
begin
|
220
|
+
# webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
|
221
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
222
|
+
options.page_load_strategy = :normal
|
223
|
+
options.timeouts = { page_load: 20_000 }
|
224
|
+
options.page_load_strategy = 'none'
|
225
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
options.add_argument('--remote-debugging-port=9222')
|
230
|
+
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
231
|
+
|
232
|
+
# :capabilities에 options를 배열로 전달
|
233
|
+
capabilities = [options]
|
234
|
+
|
235
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
236
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
237
|
+
rescue
|
238
|
+
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
239
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
240
|
+
end
|
230
241
|
else
|
242
|
+
begin
|
243
|
+
# Proxy를 사용하는 경우
|
244
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
245
|
+
options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
|
246
|
+
options.page_load_strategy = :normal
|
247
|
+
options.timeouts = { page_load: 20_000 }
|
248
|
+
options.page_load_strategy = 'none'
|
249
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
250
|
+
|
251
|
+
options.add_argument('--remote-debugging-port=9222')
|
252
|
+
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
253
|
+
|
254
|
+
# :capabilities에 options를 배열로 전달
|
255
|
+
capabilities = [options]
|
256
|
+
|
257
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
258
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
259
|
+
rescue => e
|
260
|
+
puts 'proxy error...'
|
231
261
|
begin
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
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
|
262
|
+
# Proxy가 실패할 경우 예외 처리
|
263
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
264
|
+
options.page_load_strategy = :normal
|
265
|
+
options.timeouts = { page_load: 20_000 }
|
266
|
+
options.page_load_strategy = 'none'
|
267
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
268
|
+
options.add_argument('--remote-debugging-port=9222')
|
269
|
+
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
270
|
+
|
271
|
+
# :capabilities에 options를 배열로 전달
|
272
|
+
capabilities = [options]
|
273
|
+
|
274
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
275
|
+
rescue
|
276
|
+
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
277
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
263
278
|
end
|
279
|
+
end
|
264
280
|
end
|
265
|
-
|
281
|
+
end
|
266
282
|
|
267
283
|
|
268
284
|
|
@@ -1686,10 +1702,18 @@ class Wordpress
|
|
1686
1702
|
|
1687
1703
|
def get_naver_text(q)
|
1688
1704
|
begin
|
1689
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1690
|
-
|
1705
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1706
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
1707
|
+
capabilities = [options]
|
1708
|
+
|
1709
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1710
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1691
1711
|
rescue
|
1692
|
-
|
1712
|
+
# :capabilities에 options를 배열로 전달
|
1713
|
+
capabilities = [options]
|
1714
|
+
|
1715
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1716
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1693
1717
|
end
|
1694
1718
|
@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
1719
|
noko = Nokogiri::HTML(@driver.page_source)
|
@@ -1719,10 +1743,18 @@ class Wordpress
|
|
1719
1743
|
|
1720
1744
|
def get_naver_text2(keyword)
|
1721
1745
|
begin
|
1722
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1723
|
-
|
1746
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1747
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
1748
|
+
capabilities = [options]
|
1749
|
+
|
1750
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1751
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1724
1752
|
rescue
|
1725
|
-
|
1753
|
+
# :capabilities에 options를 배열로 전달
|
1754
|
+
capabilities = [options]
|
1755
|
+
|
1756
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1757
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1726
1758
|
end
|
1727
1759
|
@driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
|
1728
1760
|
for n3 in 1..10
|
@@ -1764,10 +1796,26 @@ class Wordpress
|
|
1764
1796
|
@user_id = user_id
|
1765
1797
|
@user_pw = user_pw
|
1766
1798
|
begin
|
1767
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1768
|
-
|
1799
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1800
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
1801
|
+
options.page_load_strategy = :normal
|
1802
|
+
options.timeouts = {page_load: 20_000}
|
1803
|
+
options.page_load_strategy = 'none'
|
1804
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
1805
|
+
|
1806
|
+
options.add_argument('--remote-debugging-port=9222')
|
1807
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
1808
|
+
# :capabilities에 options를 배열로 전달
|
1809
|
+
capabilities = [options]
|
1810
|
+
|
1811
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1812
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1769
1813
|
rescue
|
1770
|
-
|
1814
|
+
# :capabilities에 options를 배열로 전달
|
1815
|
+
capabilities = [options]
|
1816
|
+
|
1817
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1818
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1771
1819
|
end
|
1772
1820
|
end
|
1773
1821
|
|
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.
|
4
|
+
version: 0.0.37
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|