nblog_duo 0.0.39 → 0.0.51

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 +77 -128
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17f42ee4f623c4e35e948d3a44d8cf0a30450570b343a1f52005d9db7c0bc283
4
- data.tar.gz: b4062f17e17f363792599221e9f580165c9bb880932963f890a2135cba088443
3
+ metadata.gz: df7330c7c5e6074749a42ee6e4afc6fb0f07e36214a56bff8baa4f6141cf6e8c
4
+ data.tar.gz: dce315107d0d30802e157960cb26c93a0d89b5c765febcc2083acd1104d579d3
5
5
  SHA512:
6
- metadata.gz: dcc25f1d736ad277732d3f7fa6671f629d3bcfb09c895517b31499ca145f55c6315822d61e5a66a6ec1bc3109b58c9ce93984281b2df9fb5a4c3f1ccc31f648c
7
- data.tar.gz: 6085efc480923a1e9c45ea4e8111c03cbe5358c20fd9d9b35a53d6c6c7545bd2926ca24b35e2f4f39565a6a51604aeb2b1c38e3a0075b0107913844d2fce51e2
6
+ metadata.gz: 9306802a0d0cf35c4cc2f22f95362b29b443f8add62dbb30dae08091f9607f7e9c5e1eaeb984695c10b99eac056eb1b2943abe1c90a563826a8abc7315b47bb9
7
+ data.tar.gz: 6d0a34873d722d42f66ece97ba1bc0ca9f308e2f3741f32ec9ef888fbe834632dd778648e60a371dd91c331aedea322ad87bf7c6ad708c9694152e88ffaf4e9b
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,88 +214,61 @@ 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
-
234
217
  if proxy == ''
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
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...'
277
218
  begin
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)
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('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
225
+ options.add_argument('--disable-gpu')
226
+ options.add_argument('--remote-debugging-port=9222')
227
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
228
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
292
229
  rescue
293
- # 예외 발생 다른 방법으로 셀레니움 실행
294
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
230
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
231
+ end
232
+ else
233
+ begin
234
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
235
+ options = Selenium::WebDriver::Chrome::Options.new
236
+ # profile = Selenium::WebDriver::Chrome::Profile.new
237
+ # profile['network.proxy.type'] = 1
238
+ # profile['network.proxy.http'] = proxy.split(':')[0]
239
+ # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
240
+ # options = Selenium::WebDriver::Chrome::Options.new
241
+ # options.profile = profile
242
+ options = Selenium::WebDriver::Chrome::Options.new
243
+ options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
244
+ options.page_load_strategy = :normal
245
+ options.timeouts = {page_load: 20_000}
246
+ options.page_load_strategy = 'none'
247
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
248
+ options.add_argument('--disable-gpu')
249
+ options.add_argument('--remote-debugging-port=9222')
250
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
251
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
252
+ rescue => e
253
+ puts e
254
+ puts 'proxy error...'
255
+ begin
256
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
257
+ options = Selenium::WebDriver::Chrome::Options.new
258
+ options.page_load_strategy = :normal
259
+ options.timeouts = {page_load: 20_000}
260
+ options.page_load_strategy = 'none'
261
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
262
+ options.add_argument('--disable-gpu')
263
+ options.add_argument('--remote-debugging-port=9222')
264
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
265
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
266
+ rescue
267
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
268
+ end
295
269
  end
296
- end
297
270
  end
298
- end
271
+ end
299
272
 
300
273
 
301
274
 
@@ -1460,63 +1433,71 @@ class Naver
1460
1433
  puts '카테고리 error'
1461
1434
  puts e33
1462
1435
  end
1463
- sleep(2)
1436
+ sleep(1)
1464
1437
  tags2 = option['tag'].to_s
1465
1438
  tag_mm2 = Array.new
1466
1439
  tags2.split(',').each do |tag_value|
1467
1440
  tag_mm2 << ''+tag_value
1468
1441
  end
1469
1442
  @driver.find_element(:xpath, '//*[@id="tag-input"]').send_keys(tag_mm2.join("\n")+"\n")
1470
- sleep(2)
1443
+ sleep(1)
1471
1444
  # data['populationParams'] = '{"configuration":{"openType":'+option['공개']+',"commentYn":'+option['댓글허용']+',"searchYn":'+option['검색허용']+',"sympathyYn":'+option['공감허용']+',"scrapType":'+option['블로그공유']+',"outSideAllowYn":'+option['외부공유허용']+',"twitterPostingYn":false,"facebookPostingYn":false,"cclYn":false},"populationMeta":{"categoryId":'+category_value+',"logNo":null,"directorySeq":0,"directoryDetail":null,"mrBlogTalkCode":null,"postWriteTimeType":"now","tags":"'+tags2+'","moviePanelParticipation":false,"greenReviewBannerYn":false,"continueSaved":false,"noticePostYn":false,"autoByCategoryYn":false,"postLocationSupportYn":false,"postLocationJson":null,"prePostDate":null,"thisDayPostInfo":null,"scrapYn":false,"autoSaveNo":'+(Time.now.to_f.round(3)*1000).to_i.to_s+'},"editorSource":"AbZmtbYiAmhrzPJyhPXNWg=="}'
1472
1445
  if option['공개'] == '2'
1473
1446
  @driver.find_element(:xpath ,'//*[@for="open_public"]').click #공개버튼
1447
+ sleep(1)
1474
1448
  elsif option['공개'] == '3'
1475
1449
  @driver.find_element(:xpath, '//*[@for="open_both_neighbor"]').click #서이웃 공개
1450
+ sleep(1)
1476
1451
  elsif option['공개'] == '0'
1477
1452
  @driver.find_element(:xpath, '//*[@for="open_private"]').click #비공개
1453
+ sleep(1)
1478
1454
  else
1479
1455
  @driver.find_element(:xpath, '//*[@for="open_neighbor"]').click #이웃공개
1456
+ sleep(1)
1480
1457
  end
1481
1458
 
1482
- sleep(1)
1459
+
1483
1460
  if option['댓글허용'] == 'true'
1484
1461
 
1485
1462
  else
1486
1463
  @driver.find_element(:xpath, '//*[@for="publish-option-comment"]').click
1464
+ sleep(1)
1487
1465
  end
1488
- sleep(1)
1466
+
1489
1467
 
1490
1468
  if option['검색허용'] == 'true'
1491
1469
 
1492
1470
  else
1493
1471
  @driver.find_element(:xpath, '//*[@for="publish-option-search"]').click
1472
+ sleep(1)
1494
1473
  end
1495
- sleep(1)
1474
+
1496
1475
 
1497
1476
  if option['공감허용'] == 'true'
1498
1477
 
1499
1478
  else
1500
1479
  @driver.find_element(:xpath, '//*[@for="publish-option-sympathy"]').click
1480
+ sleep(1)
1501
1481
  end
1502
- sleep(1)
1482
+
1503
1483
 
1504
1484
  if option['블로그공유'] == '2'
1505
1485
 
1506
1486
  else
1507
1487
  @driver.find_element(:xpath, '//*[@for="publish-option-scrap"]').click
1488
+ sleep(1)
1508
1489
  end
1509
- sleep(1)
1490
+
1510
1491
 
1511
1492
  if option['외부공유허용'] == 'true'
1512
1493
  @driver.find_element(:xpath, '//*[@for="publish-option-outside"]').click
1494
+ sleep(1)
1513
1495
  else
1514
1496
 
1515
1497
  end
1516
- sleep(1)
1498
+
1517
1499
  # puts data['documentModel'] = data['documentModel'].to_json
1518
1500
 
1519
-
1520
1501
  if option['발행'] == '2' #저장
1521
1502
  sleep(dd_time.to_i)
1522
1503
  @driver.find_element(:xpath, '//*[@class="save_btn__bzc5B"]').click
@@ -1719,18 +1700,10 @@ class Wordpress
1719
1700
 
1720
1701
  def get_naver_text(q)
1721
1702
  begin
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)
1703
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1704
+ @driver = Selenium::WebDriver.for :chrome
1728
1705
  rescue
1729
- # :capabilities에 options를 배열로 전달
1730
- capabilities = [options]
1731
-
1732
- # Selenium WebDriver에서 options를 capabilities로 전달
1733
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1706
+ @driver = Selenium::WebDriver.for :chrome
1734
1707
  end
1735
1708
  @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')
1736
1709
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1760,18 +1733,10 @@ class Wordpress
1760
1733
 
1761
1734
  def get_naver_text2(keyword)
1762
1735
  begin
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)
1736
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1737
+ @driver = Selenium::WebDriver.for :chrome
1769
1738
  rescue
1770
- # :capabilities에 options를 배열로 전달
1771
- capabilities = [options]
1772
-
1773
- # Selenium WebDriver에서 options를 capabilities로 전달
1774
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1739
+ @driver = Selenium::WebDriver.for :chrome
1775
1740
  end
1776
1741
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1777
1742
  for n3 in 1..10
@@ -1813,26 +1778,10 @@ class Wordpress
1813
1778
  @user_id = user_id
1814
1779
  @user_pw = user_pw
1815
1780
  begin
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)
1781
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1782
+ @driver = Selenium::WebDriver.for :chrome
1830
1783
  rescue
1831
- # :capabilities에 options를 배열로 전달
1832
- capabilities = [options]
1833
-
1834
- # Selenium WebDriver에서 options를 capabilities로 전달
1835
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1784
+ @driver = Selenium::WebDriver.for :chrome
1836
1785
  end
1837
1786
  end
1838
1787
 
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.39
4
+ version: 0.0.51
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-10 00:00:00.000000000 Z
11
+ date: 2025-01-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com