nblog_zon 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_zon.rb +103 -54
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d90482a851c06f415f4fe8d880a577b4e35a0d1f239aefeb65514288dfebbb3
|
4
|
+
data.tar.gz: 9901fe01810997833caed83d318c5949e21a9b57a9a6d83f799b5406dd25d8c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 277e352a6eaf160f5386a9916342995efa2ddd6a005601439fb6537d17f197371a7adb08af621093b5fa5adfd6eae1105a22e9cd2bd867c7f138a5dc2c7b8263
|
7
|
+
data.tar.gz: 68c85f206fae56642d4f60b93a0c4ae31184bfdda167f8695a9572078ddd88458c103db13d19846d4366d233aa1c9eec8e50bb5cc4a64d175d16d5960495e2e8
|
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,72 @@ 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
|
282
|
+
|
266
283
|
|
267
284
|
|
268
285
|
|
@@ -1617,10 +1634,18 @@ class Wordpress
|
|
1617
1634
|
|
1618
1635
|
def get_naver_text(q)
|
1619
1636
|
begin
|
1620
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1621
|
-
|
1637
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1638
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
1639
|
+
capabilities = [options]
|
1640
|
+
|
1641
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1642
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1622
1643
|
rescue
|
1623
|
-
|
1644
|
+
# :capabilities에 options를 배열로 전달
|
1645
|
+
capabilities = [options]
|
1646
|
+
|
1647
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1648
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1624
1649
|
end
|
1625
1650
|
@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
1651
|
noko = Nokogiri::HTML(@driver.page_source)
|
@@ -1650,10 +1675,18 @@ class Wordpress
|
|
1650
1675
|
|
1651
1676
|
def get_naver_text2(keyword)
|
1652
1677
|
begin
|
1653
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1654
|
-
|
1678
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1679
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
1680
|
+
capabilities = [options]
|
1681
|
+
|
1682
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1683
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1655
1684
|
rescue
|
1656
|
-
|
1685
|
+
# :capabilities에 options를 배열로 전달
|
1686
|
+
capabilities = [options]
|
1687
|
+
|
1688
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1689
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1657
1690
|
end
|
1658
1691
|
@driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
|
1659
1692
|
for n3 in 1..10
|
@@ -1695,10 +1728,26 @@ class Wordpress
|
|
1695
1728
|
@user_id = user_id
|
1696
1729
|
@user_pw = user_pw
|
1697
1730
|
begin
|
1698
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1699
|
-
|
1731
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1732
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
1733
|
+
options.page_load_strategy = :normal
|
1734
|
+
options.timeouts = {page_load: 20_000}
|
1735
|
+
options.page_load_strategy = 'none'
|
1736
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
1737
|
+
|
1738
|
+
options.add_argument('--remote-debugging-port=9222')
|
1739
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
1740
|
+
# :capabilities에 options를 배열로 전달
|
1741
|
+
capabilities = [options]
|
1742
|
+
|
1743
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1744
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1700
1745
|
rescue
|
1701
|
-
|
1746
|
+
# :capabilities에 options를 배열로 전달
|
1747
|
+
capabilities = [options]
|
1748
|
+
|
1749
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
1750
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1702
1751
|
end
|
1703
1752
|
end
|
1704
1753
|
|