njongto_duo 0.0.2 → 0.0.5
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/njongto_duo.rb +154 -94
- 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: e36ac7cb8b231587d6f08860160d96daad4ac030abd00d53c71b829739ccd9ef
|
4
|
+
data.tar.gz: 80cf12a63b6a9a97fd1da5d3fa3fbcf2bd99b655d72ae225e2b1330a88414160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f65169db094bcb97abed2cdc7763e8b075801742108a15712e9346fd4043391a632dd2c1e664c3f99c071e11546b05ebe0f54f98b60c2d4a615e33c50176f41
|
7
|
+
data.tar.gz: eb038c527282224625b22a98a11fdf8b8ee3b46d3405c6039a965dfefff121d681f8849c7f1758e8a0348865393d7a0c92e90c786dec47a3dc66464de21b1f4d
|
data/lib/njongto_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'
|
@@ -19,98 +19,122 @@ require 'auto_click'
|
|
19
19
|
require 'rainbow/refinement'
|
20
20
|
include AutoClickMethods
|
21
21
|
using Rainbow
|
22
|
-
|
22
|
+
include Glimmer
|
23
23
|
|
24
24
|
class Naver
|
25
25
|
def initialize
|
26
26
|
@seed = 1
|
27
|
-
@cookie = ''
|
28
27
|
end
|
28
|
+
def chrome_setup(user_id)
|
29
|
+
naver_cookie_dir = "C:/naver_cookie"
|
30
|
+
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
31
|
+
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
|
29
32
|
|
30
|
-
|
33
|
+
end
|
34
|
+
def chrome_start(proxy, user_id)
|
35
|
+
naver_cookie_dir = "C:/naver_cookie"
|
36
|
+
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
37
|
+
|
31
38
|
if proxy == ''
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
begin
|
40
|
+
# webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
|
41
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
42
|
+
options.page_load_strategy = :normal
|
43
|
+
options.timeouts = { page_load: 20_000 }
|
44
|
+
options.page_load_strategy = 'none'
|
45
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
options.add_argument('--remote-debugging-port=9222')
|
50
|
+
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
51
|
+
|
52
|
+
# :capabilities에 options를 배열로 전달
|
53
|
+
capabilities = [options]
|
54
|
+
|
55
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
56
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
57
|
+
rescue
|
58
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
59
|
+
capabilities = [options]
|
60
|
+
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
61
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
62
|
+
end
|
42
63
|
else
|
64
|
+
begin
|
65
|
+
# Proxy를 사용하는 경우
|
66
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
67
|
+
options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
|
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
|
+
|
73
|
+
options.add_argument('--remote-debugging-port=9222')
|
74
|
+
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
75
|
+
|
76
|
+
# :capabilities에 options를 배열로 전달
|
77
|
+
capabilities = [options]
|
78
|
+
|
79
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
80
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
81
|
+
rescue => e
|
82
|
+
puts 'proxy error...'
|
43
83
|
begin
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
63
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
64
|
-
options.page_load_strategy = :normal
|
65
|
-
options.timeouts = {page_load: 20_000}
|
66
|
-
options.page_load_strategy = 'none'
|
67
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
68
|
-
rescue
|
69
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
70
|
-
end
|
84
|
+
# Proxy가 실패할 경우 예외 처리
|
85
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
86
|
+
options.page_load_strategy = :normal
|
87
|
+
options.timeouts = { page_load: 20_000 }
|
88
|
+
options.page_load_strategy = 'none'
|
89
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
90
|
+
options.add_argument('--remote-debugging-port=9222')
|
91
|
+
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
92
|
+
|
93
|
+
# :capabilities에 options를 배열로 전달
|
94
|
+
capabilities = [options]
|
95
|
+
|
96
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
97
|
+
rescue
|
98
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
99
|
+
capabilities = [options]
|
100
|
+
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
101
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
71
102
|
end
|
103
|
+
end
|
72
104
|
end
|
73
|
-
|
105
|
+
end
|
74
106
|
|
75
107
|
|
76
108
|
|
77
109
|
def login(user_id, user_pw, proxy)
|
78
110
|
@user_id = user_id
|
79
111
|
@user_id11 = user_id
|
80
|
-
|
112
|
+
current_dir = File.dirname(__FILE__)
|
113
|
+
naver_cookie_dir = "C:/naver_cookie"
|
114
|
+
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
unless File.exist?("C:/naver_cookie/" + user_id)
|
119
|
+
driverfile_src = File.join(current_dir, 'driverfile')
|
120
|
+
if Dir.exist?(driverfile_src)
|
121
|
+
FileUtils.cp_r(driverfile_src, "C:/naver_cookie/" + user_id)
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# 새로운 스레드 생성 및 실행
|
127
|
+
Thread.new { chrome_setup(user_id) }
|
128
|
+
sleep(3)
|
129
|
+
|
130
|
+
|
131
|
+
chrome_start(proxy, user_id)
|
81
132
|
@driver.get('https://www.naver.com')
|
82
133
|
puts'[Step.01] 계정 로그인 및 세션 확인.......'.yellow
|
83
|
-
sleep(1)
|
84
|
-
user_cookie_file = Array.new
|
85
|
-
begin
|
86
|
-
Dir.entries('./cookie').each do |i|
|
87
|
-
if i == '.' or i == '..'
|
88
134
|
|
89
|
-
else
|
90
|
-
user_cookie_file << i
|
91
|
-
end
|
92
|
-
end
|
93
|
-
rescue
|
94
|
-
|
95
|
-
end
|
96
|
-
sleep(1)
|
97
|
-
@cookie4 = Hash.new
|
98
|
-
if user_cookie_file.include?(user_id+'.txt')
|
99
|
-
f = File.open('./cookie/'+user_id+'.txt', 'r')
|
100
|
-
@cookie4 = JSON.parse(f.read())
|
101
|
-
f.close
|
102
|
-
end
|
103
|
-
|
104
|
-
begin
|
105
|
-
@cookie4.each do |i|
|
106
|
-
p i
|
107
|
-
@driver.manage.add_cookie(name: i['name'], value: i['value'], same_site: i['same_site'], domain: i['domain'], path: i['path'])
|
108
|
-
end
|
109
|
-
rescue
|
110
135
|
|
111
|
-
end
|
112
136
|
sleep(1)
|
113
|
-
|
137
|
+
|
114
138
|
begin
|
115
139
|
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
116
140
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
@@ -133,7 +157,7 @@ class Naver
|
|
133
157
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
134
158
|
wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
|
135
159
|
sleep(1.5)
|
136
|
-
@driver.find_element(:xpath, '//*[@
|
160
|
+
@driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
|
137
161
|
sleep(1.5)
|
138
162
|
@driver.find_element(:xpath, '//*[@id="id"]').click
|
139
163
|
Clipboard.copy(user_id)
|
@@ -145,20 +169,21 @@ class Naver
|
|
145
169
|
sleep(1.5)
|
146
170
|
@driver.find_element(:xpath, '//*[@id="log.login"]').click
|
147
171
|
sleep(2.5)
|
172
|
+
|
148
173
|
else
|
149
174
|
# @driver.switch_to.default_content
|
150
175
|
end
|
151
176
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
177
|
+
begin
|
178
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
179
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
180
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
181
|
+
|
182
|
+
rescue => e
|
183
|
+
puts '-[√] 로그인 실패!!.......'.red
|
184
|
+
puts e
|
185
|
+
@driver.close
|
186
|
+
return 0
|
162
187
|
end
|
163
188
|
end
|
164
189
|
|
@@ -190,10 +215,16 @@ class Naver
|
|
190
215
|
@driver.switch_to.default_content()
|
191
216
|
rescue
|
192
217
|
#종토리뷰
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
218
|
+
begin
|
219
|
+
@driver.find_element(:xpath, '//*[@placeholder="제목"]')
|
220
|
+
puts'[기능 발동!!] 오픈톡 유형 감지 확인.......'.green
|
221
|
+
puts'[Step.04] 제목 입력.......'.yellow
|
222
|
+
@driver.find_element(:xpath, '//*[@placeholder="제목"]').send_keys(title)
|
223
|
+
rescue
|
224
|
+
puts '[Error] 제목 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
|
225
|
+
@driver.close
|
226
|
+
return 0
|
227
|
+
end
|
197
228
|
end
|
198
229
|
|
199
230
|
#내용 입력
|
@@ -208,9 +239,15 @@ class Naver
|
|
208
239
|
@driver.switch_to.default_content()
|
209
240
|
rescue
|
210
241
|
#종토리뷰
|
242
|
+
begin
|
211
243
|
@driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]')
|
212
244
|
puts'[Step.05] 내용 입력.......'.yellow
|
213
245
|
@driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]').click
|
246
|
+
rescue
|
247
|
+
puts '[Error] 내용 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
|
248
|
+
@driver.close
|
249
|
+
return 0
|
250
|
+
end
|
214
251
|
end
|
215
252
|
|
216
253
|
puts content
|
@@ -276,11 +313,17 @@ class Naver
|
|
276
313
|
puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
|
277
314
|
rescue
|
278
315
|
#종토리뷰
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
316
|
+
begin
|
317
|
+
@driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]')
|
318
|
+
sleep(1)
|
319
|
+
puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
|
320
|
+
@driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]').click
|
321
|
+
puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
|
322
|
+
rescue
|
323
|
+
puts '[Error] 등록 버튼을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
|
324
|
+
@driver.close
|
325
|
+
return 0
|
326
|
+
end
|
284
327
|
end
|
285
328
|
sleep(5)
|
286
329
|
begin
|
@@ -397,10 +440,27 @@ class Wordpress
|
|
397
440
|
@user_id = user_id
|
398
441
|
@user_pw = user_pw
|
399
442
|
begin
|
400
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
401
|
-
|
443
|
+
#Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
444
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
445
|
+
options.page_load_strategy = :normal
|
446
|
+
options.timeouts = {page_load: 20_000}
|
447
|
+
options.page_load_strategy = 'none'
|
448
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
449
|
+
|
450
|
+
options.add_argument('--remote-debugging-port=9222')
|
451
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
452
|
+
# :capabilities에 options를 배열로 전달
|
453
|
+
capabilities = [options]
|
454
|
+
|
455
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
456
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
402
457
|
rescue
|
403
|
-
|
458
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
459
|
+
# :capabilities에 options를 배열로 전달
|
460
|
+
capabilities = [options]
|
461
|
+
|
462
|
+
# Selenium WebDriver에서 options를 capabilities로 전달
|
463
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
404
464
|
end
|
405
465
|
end
|
406
466
|
|
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.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|