njongto_duo 0.0.7 → 0.0.33

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/njongto_duo.rb +61 -104
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5107888009fcb1efc09e3f80f68a220d279480a1954c0364e1cbdafafa1df74a
4
- data.tar.gz: f21436b1023dca575fe531286ab961e21e98de9a12b4e3aa624e3aed3756250a
3
+ metadata.gz: d18f34993f0d40cd3be2e39a908b598a0b4c0978baeb7b35bc92a1a31ef30c35
4
+ data.tar.gz: d58266525dd42b5e208514bacb751b839f381dd69717903b36c93f0a70133306
5
5
  SHA512:
6
- metadata.gz: 69bdbce3ea16ace378c64ed0bb6519cebd5dab199a77afd709fc3fa5ecacbb98e6322eb3d0826aec54ac65014bc6d2ac4943e86fcde70afff9fef7327455fda6
7
- data.tar.gz: 45abe8e4ee089acd1c2f3af717380847caf3101d343b74aa3b928140558bdd9e0c3c4b712c4ec353b7283e3c6a705c6c17629366fd468110e569255d6ae7ca55
6
+ metadata.gz: 6a52e35928a41dd9b045c4e323b87e29b6ba9cf38c332e9b7056b6a5071bca1d1b55ea946585473c32cfd237f3451472532ce235a536c994ad335b8560c8dbf5
7
+ data.tar.gz: 81be25e56cdb46826f7e799fc2df968bf88b34cb1e70667456c6ca20e5e0c5c252c7c2e5213c392423c59d0763ab7e7d66f47224df606ee01bfc3668ac220f7c
data/lib/njongto_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'
@@ -21,104 +21,78 @@ include AutoClickMethods
21
21
  using Rainbow
22
22
  include Glimmer
23
23
 
24
+
24
25
  class Naver
25
26
  def initialize
26
27
  @seed = 1
27
28
  end
28
- def chrome_setup(user_id)
29
+ def chrome_setup(user_id, proxy)
29
30
  naver_cookie_dir = "C:/naver_cookie"
30
31
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
32
+ if proxy == ''
31
33
  system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
32
-
34
+ else
35
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" "https://naver.com/" --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s}})
36
+ end
33
37
  end
34
38
  def chrome_start(proxy, user_id)
35
39
  naver_cookie_dir = "C:/naver_cookie"
36
40
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
37
- # ChromeDriver 경로 수동 지정
38
- chromedriver_path = './chromedriver.exe'
39
-
40
- # 웹드라이버 자동 업데이트 시도
41
- begin
42
- # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
43
- Webdrivers::Chromedriver.update # 자동 업데이트 시도
44
- rescue => e
45
- puts "webdrivers에서 chromedriver 다운로드 실패: #{e.message}"
46
- puts "자동으로 chromedriver.exe 사용합니다."
47
- puts "만일 프로그램 폴더안에 chromedriver.exe 버전이 맞지 않거나 없는 경우 인터넷창이 깜빡하고 닫히거나 열리지 않는경우에만 아래 안내를 따라주세요."
48
- puts "https://storage.googleapis.com/chrome-for-testing-public/사용자크롬버전/win32/chromedriver-win32.zip 링크를 복사 후 복사 된 링크 중(사용자크롬버전) 부분을 크롬 사용자의 버전(예:131.0.6778.264)으로 수정 후 주소입력 부분에 넣어 엔터 후 다운로드 하고 압축을 풀고 chromedriver.exe 파일만 프로그램 폴더안에 넣어주세요."
49
- puts "인터넷 창이 열리고 작업을 한다면 위 항목은 패스해주세요."
50
- # 예외가 발생하면 수동 경로 사용
51
- Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
52
- end
53
-
54
41
  if proxy == ''
55
- begin
56
- # webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
57
- options = Selenium::WebDriver::Chrome::Options.new
58
- options.page_load_strategy = :normal
59
- options.timeouts = { page_load: 20_000 }
60
- options.page_load_strategy = 'none'
61
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
62
-
63
-
64
-
65
- options.add_argument('--remote-debugging-port=9222')
66
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
67
-
68
- # :capabilities에 options를 배열로 전달
69
- capabilities = [options]
70
-
71
- # Selenium WebDriver에서 options를 capabilities로 전달
72
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
73
- rescue
74
- options = Selenium::WebDriver::Chrome::Options.new
75
- capabilities = [options]
76
- # 예외 발생 시 다른 방법으로 셀레니움 실행
77
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
78
- end
79
- else
80
- begin
81
- # Proxy를 사용하는 경우
82
- options = Selenium::WebDriver::Chrome::Options.new
83
- options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
84
- options.page_load_strategy = :normal
85
- options.timeouts = { page_load: 20_000 }
86
- options.page_load_strategy = 'none'
87
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
88
-
89
- options.add_argument('--remote-debugging-port=9222')
90
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
91
-
92
- # :capabilities에 options를 배열로 전달
93
- capabilities = [options]
94
-
95
- # Selenium WebDriver에서 options를 capabilities로 전달
96
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
97
- rescue => e
98
- puts 'proxy error...'
99
42
  begin
100
- # Proxy가 실패할 경우 예외 처리
101
- options = Selenium::WebDriver::Chrome::Options.new
102
- options.page_load_strategy = :normal
103
- options.timeouts = { page_load: 20_000 }
104
- options.page_load_strategy = 'none'
105
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
106
- options.add_argument('--remote-debugging-port=9222')
107
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
108
-
109
- # :capabilities options를 배열로 전달
110
- capabilities = [options]
111
-
112
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
43
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
44
+ options = Selenium::WebDriver::Chrome::Options.new
45
+ options.page_load_strategy = :normal
46
+ options.timeouts = {page_load: 20_000}
47
+ options.page_load_strategy = 'none'
48
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
49
+ options.add_argument('--disable-gpu')
50
+ options.add_argument('--remote-debugging-port=9222')
51
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
52
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
113
53
  rescue
114
- options = Selenium::WebDriver::Chrome::Options.new
115
- capabilities = [options]
116
- # 예외 발생 시 다른 방법으로 셀레니움 실행
117
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
54
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
55
+ end
56
+ else
57
+ begin
58
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
59
+ options = Selenium::WebDriver::Chrome::Options.new
60
+ # profile = Selenium::WebDriver::Chrome::Profile.new
61
+ # profile['network.proxy.type'] = 1
62
+ # profile['network.proxy.http'] = proxy.split(':')[0]
63
+ # profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
64
+ # options = Selenium::WebDriver::Chrome::Options.new
65
+ # options.profile = profile
66
+ options = Selenium::WebDriver::Chrome::Options.new
67
+ options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
68
+ options.page_load_strategy = :normal
69
+ options.timeouts = {page_load: 20_000}
70
+ options.page_load_strategy = 'none'
71
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
72
+ options.add_argument('--disable-gpu')
73
+ options.add_argument('--remote-debugging-port=9222')
74
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
75
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
76
+ rescue => e
77
+ puts e
78
+ puts 'proxy error...'
79
+ begin
80
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
81
+ options = Selenium::WebDriver::Chrome::Options.new
82
+ options.page_load_strategy = :normal
83
+ options.timeouts = {page_load: 20_000}
84
+ options.page_load_strategy = 'none'
85
+ options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
86
+ options.add_argument('--disable-gpu')
87
+ options.add_argument('--remote-debugging-port=9222')
88
+ options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
89
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
90
+ rescue
91
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
92
+ end
118
93
  end
119
- end
120
94
  end
121
- end
95
+ end
122
96
 
123
97
 
124
98
 
@@ -140,7 +114,7 @@ class Naver
140
114
  end
141
115
 
142
116
  # 새로운 스레드 생성 및 실행
143
- Thread.new { chrome_setup(user_id) }
117
+ Thread.new { chrome_setup(user_id, proxy) }
144
118
  sleep(3)
145
119
 
146
120
 
@@ -456,27 +430,10 @@ class Wordpress
456
430
  @user_id = user_id
457
431
  @user_pw = user_pw
458
432
  begin
459
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
460
- options = Selenium::WebDriver::Chrome::Options.new
461
- options.page_load_strategy = :normal
462
- options.timeouts = {page_load: 20_000}
463
- options.page_load_strategy = 'none'
464
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
465
-
466
- options.add_argument('--remote-debugging-port=9222')
467
- options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
468
- # :capabilities에 options를 배열로 전달
469
- capabilities = [options]
470
-
471
- # Selenium WebDriver에서 options를 capabilities로 전달
472
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
433
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
434
+ @driver = Selenium::WebDriver.for :chrome
473
435
  rescue
474
- options = Selenium::WebDriver::Chrome::Options.new
475
- # :capabilities에 options를 배열로 전달
476
- capabilities = [options]
477
-
478
- # Selenium WebDriver에서 options를 capabilities로 전달
479
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
436
+ @driver = Selenium::WebDriver.for :chrome
480
437
  end
481
438
  end
482
439
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njongto_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.33
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-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com