njongto_duo 0.0.1 → 0.0.3
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 +56 -49
- 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: 4cf36f0647a9f00f4a7b86a3d4a0c1892b32f0125ac1bb2236e1edad1ebd1d2e
|
4
|
+
data.tar.gz: 1862e048e5d52a06bd3d2d6ed915cc226c9249bb31b745d94e1e39cf62e652d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43cfc9f8e21432c43a774b29883eee89f3d2d1ae2e5ef69bcbc8e07f569153657749bfaad9ad8f2bb4b03ce097e9efbe82e38e8219674d00db48965879d08441
|
7
|
+
data.tar.gz: 2cc4c4a88b30ce30f220be3614a542bc9d8aaeb3990b4f0f0d0b5fedd063ea08809a844c7cbb88dd49ae8e3f0e8288135aa6e1545a52d056456ec80a17a076c9
|
data/lib/njongto_duo.rb
CHANGED
@@ -19,22 +19,30 @@ 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)
|
31
37
|
if proxy == ''
|
32
38
|
begin
|
33
39
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
34
40
|
options = Selenium::WebDriver::Chrome::Options.new
|
35
41
|
options.page_load_strategy = :normal
|
36
42
|
options.timeouts = {page_load: 20_000}
|
37
|
-
options.page_load_strategy = 'none'
|
43
|
+
options.page_load_strategy = 'none'
|
44
|
+
options.add_argument('--remote-debugging-port=9222')
|
45
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
38
46
|
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
39
47
|
rescue
|
40
48
|
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
@@ -53,7 +61,9 @@ class Naver
|
|
53
61
|
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
54
62
|
options.page_load_strategy = :normal
|
55
63
|
options.timeouts = {page_load: 20_000}
|
56
|
-
options.page_load_strategy = 'none'
|
64
|
+
options.page_load_strategy = 'none'
|
65
|
+
options.add_argument('--remote-debugging-port=9222')
|
66
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
57
67
|
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
58
68
|
rescue => e
|
59
69
|
puts e
|
@@ -63,7 +73,9 @@ class Naver
|
|
63
73
|
options = Selenium::WebDriver::Chrome::Options.new
|
64
74
|
options.page_load_strategy = :normal
|
65
75
|
options.timeouts = {page_load: 20_000}
|
66
|
-
options.page_load_strategy = 'none'
|
76
|
+
options.page_load_strategy = 'none'
|
77
|
+
options.add_argument('--remote-debugging-port=9222')
|
78
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
67
79
|
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
68
80
|
rescue
|
69
81
|
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
@@ -77,40 +89,32 @@ class Naver
|
|
77
89
|
def login(user_id, user_pw, proxy)
|
78
90
|
@user_id = user_id
|
79
91
|
@user_id11 = user_id
|
80
|
-
|
92
|
+
current_dir = File.dirname(__FILE__)
|
93
|
+
naver_cookie_dir = "C:/naver_cookie"
|
94
|
+
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
unless File.exist?("C:/naver_cookie/" + user_id)
|
99
|
+
driverfile_src = File.join(current_dir, 'driverfile')
|
100
|
+
if Dir.exist?(driverfile_src)
|
101
|
+
FileUtils.cp_r(driverfile_src, "C:/naver_cookie/" + user_id)
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# 새로운 스레드 생성 및 실행
|
107
|
+
Thread.new { chrome_setup(user_id) }
|
108
|
+
sleep(3)
|
109
|
+
|
110
|
+
|
111
|
+
chrome_start(proxy, user_id)
|
81
112
|
@driver.get('https://www.naver.com')
|
82
113
|
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
114
|
|
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
115
|
|
111
|
-
end
|
112
116
|
sleep(1)
|
113
|
-
|
117
|
+
|
114
118
|
begin
|
115
119
|
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
116
120
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
@@ -133,7 +137,7 @@ class Naver
|
|
133
137
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
134
138
|
wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
|
135
139
|
sleep(1.5)
|
136
|
-
@driver.find_element(:xpath, '//*[@
|
140
|
+
@driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
|
137
141
|
sleep(1.5)
|
138
142
|
@driver.find_element(:xpath, '//*[@id="id"]').click
|
139
143
|
Clipboard.copy(user_id)
|
@@ -145,20 +149,21 @@ class Naver
|
|
145
149
|
sleep(1.5)
|
146
150
|
@driver.find_element(:xpath, '//*[@id="log.login"]').click
|
147
151
|
sleep(2.5)
|
152
|
+
|
148
153
|
else
|
149
154
|
# @driver.switch_to.default_content
|
150
155
|
end
|
151
156
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
157
|
+
begin
|
158
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
159
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
160
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
161
|
+
|
162
|
+
rescue => e
|
163
|
+
puts '-[√] 로그인 실패!!.......'.red
|
164
|
+
puts e
|
165
|
+
@driver.close
|
166
|
+
return 0
|
162
167
|
end
|
163
168
|
end
|
164
169
|
|
@@ -182,7 +187,7 @@ class Naver
|
|
182
187
|
puts'[기능 발동!!] 종토방 또는 오픈톡 중 어떤 유형인지 감지 시작.......'.green
|
183
188
|
begin
|
184
189
|
#종토게시판
|
185
|
-
@driver.switch_to.frame(@driver.find_element(:xpath, '
|
190
|
+
@driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="글쓰기 영역"]')) #아이프레임
|
186
191
|
@driver.find_element(:xpath, '//*[@id="title"]')
|
187
192
|
puts'[기능 발동!!] 종토방 유형 감지 확인.......'.green
|
188
193
|
puts'[Step.04] 제목 입력.......'.yellow
|
@@ -201,7 +206,7 @@ class Naver
|
|
201
206
|
sleep(2)
|
202
207
|
begin
|
203
208
|
#종토게시판
|
204
|
-
@driver.switch_to.frame(@driver.find_element(:xpath, '
|
209
|
+
@driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="글쓰기 영역"]')) #아이프레임
|
205
210
|
@driver.find_element(:xpath, '//*[@id="body"]')
|
206
211
|
puts'[Step.05] 내용 입력.......'.yellow
|
207
212
|
@driver.find_element(:xpath, '//*[@id="body"]').click
|
@@ -266,7 +271,9 @@ class Naver
|
|
266
271
|
begin
|
267
272
|
#종토게시판
|
268
273
|
@driver.action.send_keys(:page_down).perform
|
269
|
-
@driver.switch_to.frame(@driver.find_element(:xpath, '
|
274
|
+
@driver.switch_to.frame(@driver.find_element(:xpath, '//*[@title="글쓰기 영역"]')) #아이프레임
|
275
|
+
sleep(1)
|
276
|
+
@driver.find_element(:xpath, '//*[@alt="완료"]')
|
270
277
|
sleep(1)
|
271
278
|
@driver.find_element(:xpath, '//*[@alt="완료"]').click
|
272
279
|
puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|