cafe_basics_duo 0.0.17 → 0.0.20

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/cafe_basics_duo.rb +80 -102
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfbbaf6428eee25f772417269a4ff86459b359615720f14fab0c8ee81727f429
4
- data.tar.gz: 41b716dd89954bd2ea744eee3cd8a2d517e57677d30bac6640c64503c0f233a6
3
+ metadata.gz: '09c6ba48d9cdd6060be74a6f8c4a3035a327e71fa613fa0baf9ed2fefb415652'
4
+ data.tar.gz: c8331a5baa52b241de005422ee14e2783f6d625942a5e8ad624f2a9b1b8133b0
5
5
  SHA512:
6
- metadata.gz: ffb1afd6aeebc9d04d68d75658a5db2e048ffc566876d4aea1fc46c21b49d5aecf62eb2478ce01fbb9a2a5a8c305fec0301a8d344015e83c1b57e6a53505d5c0
7
- data.tar.gz: fa069d428ff13e87192f83f535cb072909012892f00dbc2f56cd7c4397d782f400d219041d9c833e93389a113c7d29bfce288261df35deaca27f0473b7c8b20c
6
+ metadata.gz: 1a09ec016dd0ca898c4538b532e78349d3708930f86849a35373f3e53bec40dc5dd9257e06fd6b762f143f6d6aa84cfe029df30585e03ae6e08fd3f5e9a4ffb9
7
+ data.tar.gz: 4c0d1e18e6e71d0a8ab1cfab5ff51d4b329a1fb6865abca6aeec9bb675098e436c323aa01a5727e78fc66330813434aa3942b3b9a38d72a8a10c3fbc0b64e93b
@@ -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'
@@ -219,71 +219,61 @@ class Naver
219
219
  def chrome_start(proxy, user_id)
220
220
  naver_cookie_dir = "C:/naver_cookie"
221
221
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
222
-
223
222
  if proxy == ''
224
- begin
225
- # webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
226
- options = Selenium::WebDriver::Chrome::Options.new
227
- options.page_load_strategy = :normal
228
- options.timeouts = { page_load: 20_000 }
229
- options.page_load_strategy = 'none'
230
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
231
-
232
-
233
-
234
- options.add_argument('--remote-debugging-port=9222')
235
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
236
-
237
- # :capabilities에 options를 배열로 전달
238
- capabilities = [options]
239
-
240
- # Selenium WebDriver에서 options를 capabilities로 전달
241
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
242
- rescue
243
- # 예외 발생 시 다른 방법으로 셀레니움 실행
244
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
245
- end
246
- else
247
- begin
248
- # Proxy를 사용하는 경우
249
- options = Selenium::WebDriver::Chrome::Options.new
250
- options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
251
- options.page_load_strategy = :normal
252
- options.timeouts = { page_load: 20_000 }
253
- options.page_load_strategy = 'none'
254
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
255
-
256
- options.add_argument('--remote-debugging-port=9222')
257
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
258
-
259
- # :capabilities에 options를 배열로 전달
260
- capabilities = [options]
261
-
262
- # Selenium WebDriver에서 options를 capabilities로 전달
263
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
264
- rescue => e
265
- puts 'proxy error...'
266
223
  begin
267
- # Proxy가 실패할 경우 예외 처리
268
- options = Selenium::WebDriver::Chrome::Options.new
269
- options.page_load_strategy = :normal
270
- options.timeouts = { page_load: 20_000 }
271
- options.page_load_strategy = 'none'
272
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
273
- options.add_argument('--remote-debugging-port=9222')
274
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
275
-
276
- # :capabilities options를 배열로 전달
277
- capabilities = [options]
278
-
279
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
224
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
225
+ options = Selenium::WebDriver::Chrome::Options.new
226
+ options.page_load_strategy = :normal
227
+ options.timeouts = {page_load: 20_000}
228
+ options.page_load_strategy = 'none'
229
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
230
+ options.add_argument('--disable-gpu')
231
+ options.add_argument('--remote-debugging-port=9222')
232
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
233
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
280
234
  rescue
281
- # 예외 발생 다른 방법으로 셀레니움 실행
282
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
235
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
236
+ end
237
+ else
238
+ begin
239
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
240
+ options = Selenium::WebDriver::Chrome::Options.new
241
+ # profile = Selenium::WebDriver::Chrome::Profile.new
242
+ # profile['network.proxy.type'] = 1
243
+ # profile['network.proxy.http'] = proxy.split(':')[0]
244
+ # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
245
+ # options = Selenium::WebDriver::Chrome::Options.new
246
+ # options.profile = profile
247
+ options = Selenium::WebDriver::Chrome::Options.new
248
+ options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
249
+ options.page_load_strategy = :normal
250
+ options.timeouts = {page_load: 20_000}
251
+ options.page_load_strategy = 'none'
252
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
253
+ options.add_argument('--disable-gpu')
254
+ options.add_argument('--remote-debugging-port=9222')
255
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
256
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
257
+ rescue => e
258
+ puts e
259
+ puts 'proxy error...'
260
+ begin
261
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
262
+ options = Selenium::WebDriver::Chrome::Options.new
263
+ options.page_load_strategy = :normal
264
+ options.timeouts = {page_load: 20_000}
265
+ options.page_load_strategy = 'none'
266
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
267
+ options.add_argument('--disable-gpu')
268
+ options.add_argument('--remote-debugging-port=9222')
269
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
270
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
271
+ rescue
272
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
273
+ end
283
274
  end
284
- end
285
275
  end
286
- end
276
+ end
287
277
 
288
278
 
289
279
 
@@ -1374,15 +1364,16 @@ class Naver
1374
1364
  # end
1375
1365
  if option['댓글허용'] == 'true'
1376
1366
  puts '댓글허용'
1367
+
1377
1368
  begin
1378
1369
  @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[1]/div/label').click
1379
-
1370
+ sleep(1)
1380
1371
  rescue
1381
1372
 
1382
1373
  end
1383
1374
  end
1384
1375
 
1385
- sleep(1)
1376
+
1386
1377
  if option['블로그,카페 공유허용'] == 'true'
1387
1378
  puts '블로그,카페 공유허용'
1388
1379
  begin
@@ -1393,54 +1384,57 @@ class Naver
1393
1384
  end
1394
1385
 
1395
1386
 
1396
- sleep(1)
1387
+
1397
1388
  if option['외부공유허용'] == 'true'
1398
1389
  puts '외부공유허용'
1399
1390
  begin
1400
1391
  @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[3]/div[1]/label').click
1392
+ sleep(1)
1401
1393
  rescue
1402
1394
 
1403
1395
  end
1404
1396
  end
1405
1397
 
1406
- sleep(1)
1398
+
1407
1399
 
1408
1400
  if option['복사,저장 허용'] == 'true'
1409
1401
  puts '복사,저장 허용'
1410
1402
  begin
1411
1403
  @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[4]/div[1]/label').click
1412
- rescue
1404
+ sleep(1)
1405
+ rescue
1413
1406
 
1407
+ end
1414
1408
  end
1415
- end
1416
1409
 
1417
- sleep(1)
1410
+
1418
1411
  if option['자동출처 사용'] == 'true'
1419
1412
  puts '자동출처 사용'
1420
- begin
1421
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[5]/div[1]/label').click
1422
- rescue
1413
+ begin
1414
+ @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[5]/div[1]/label').click
1415
+ sleep(1)
1416
+ rescue
1423
1417
 
1424
- end
1425
- end
1426
-
1427
- sleep(1)
1418
+ end
1419
+ end
1420
+
1428
1421
 
1429
1422
  if option['CCL 사용'] == 'true'
1430
1423
  puts 'CCL 사용'
1431
1424
  begin
1432
1425
  @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[6]/div[1]/label').click
1433
- rescue
1434
-
1426
+ sleep(1)
1427
+ rescue
1428
+
1429
+ end
1435
1430
  end
1436
- end
1437
- sleep(1)
1431
+
1438
1432
  # puts data['documentModel'] = data['documentModel'].to_json
1439
1433
 
1440
1434
  sleep(dd_time.to_i)
1441
1435
  @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[1]/div/a').click
1442
1436
 
1443
- sleep(10)
1437
+ sleep(7)
1444
1438
 
1445
1439
 
1446
1440
  begin
@@ -1655,18 +1649,10 @@ class Wordpress
1655
1649
 
1656
1650
  def get_naver_text(q)
1657
1651
  begin
1658
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1659
- options = Selenium::WebDriver::Chrome::Options.new
1660
- capabilities = [options]
1661
-
1662
- # Selenium WebDriver에서 options를 capabilities로 전달
1663
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1652
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1653
+ @driver = Selenium::WebDriver.for :chrome
1664
1654
  rescue
1665
- # :capabilities에 options를 배열로 전달
1666
- capabilities = [options]
1667
-
1668
- # Selenium WebDriver에서 options를 capabilities로 전달
1669
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1655
+ @driver = Selenium::WebDriver.for :chrome
1670
1656
  end
1671
1657
  @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')
1672
1658
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1696,18 +1682,10 @@ class Wordpress
1696
1682
 
1697
1683
  def get_naver_text2(keyword)
1698
1684
  begin
1699
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1700
- options = Selenium::WebDriver::Chrome::Options.new
1701
- capabilities = [options]
1702
-
1703
- # Selenium WebDriver에서 options를 capabilities로 전달
1704
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1685
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1686
+ @driver = Selenium::WebDriver.for :chrome
1705
1687
  rescue
1706
- # :capabilities에 options를 배열로 전달
1707
- capabilities = [options]
1708
-
1709
- # Selenium WebDriver에서 options를 capabilities로 전달
1710
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1688
+ @driver = Selenium::WebDriver.for :chrome
1711
1689
  end
1712
1690
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1713
1691
  for n3 in 1..10
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.20
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