njongto_duo 0.0.3 → 0.0.7
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 +128 -57
- 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: 5107888009fcb1efc09e3f80f68a220d279480a1954c0364e1cbdafafa1df74a
|
4
|
+
data.tar.gz: f21436b1023dca575fe531286ab961e21e98de9a12b4e3aa624e3aed3756250a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69bdbce3ea16ace378c64ed0bb6519cebd5dab199a77afd709fc3fa5ecacbb98e6322eb3d0826aec54ac65014bc6d2ac4943e86fcde70afff9fef7327455fda6
|
7
|
+
data.tar.gz: 45abe8e4ee089acd1c2f3af717380847caf3101d343b74aa3b928140558bdd9e0c3c4b712c4ec353b7283e3c6a705c6c17629366fd468110e569255d6ae7ca55
|
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'
|
@@ -34,55 +34,91 @@ class Naver
|
|
34
34
|
def chrome_start(proxy, user_id)
|
35
35
|
naver_cookie_dir = "C:/naver_cookie"
|
36
36
|
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
|
+
|
37
54
|
if proxy == ''
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
50
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...'
|
51
99
|
begin
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
puts 'proxy error...'
|
71
|
-
begin
|
72
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
73
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
74
|
-
options.page_load_strategy = :normal
|
75
|
-
options.timeouts = {page_load: 20_000}
|
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)
|
79
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
80
|
-
rescue
|
81
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
82
|
-
end
|
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)
|
113
|
+
rescue
|
114
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
115
|
+
capabilities = [options]
|
116
|
+
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
117
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
83
118
|
end
|
119
|
+
end
|
84
120
|
end
|
85
|
-
|
121
|
+
end
|
86
122
|
|
87
123
|
|
88
124
|
|
@@ -195,10 +231,16 @@ class Naver
|
|
195
231
|
@driver.switch_to.default_content()
|
196
232
|
rescue
|
197
233
|
#종토리뷰
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
234
|
+
begin
|
235
|
+
@driver.find_element(:xpath, '//*[@placeholder="제목"]')
|
236
|
+
puts'[기능 발동!!] 오픈톡 유형 감지 확인.......'.green
|
237
|
+
puts'[Step.04] 제목 입력.......'.yellow
|
238
|
+
@driver.find_element(:xpath, '//*[@placeholder="제목"]').send_keys(title)
|
239
|
+
rescue
|
240
|
+
puts '[Error] 제목 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
|
241
|
+
@driver.close
|
242
|
+
return 0
|
243
|
+
end
|
202
244
|
end
|
203
245
|
|
204
246
|
#내용 입력
|
@@ -213,9 +255,15 @@ class Naver
|
|
213
255
|
@driver.switch_to.default_content()
|
214
256
|
rescue
|
215
257
|
#종토리뷰
|
258
|
+
begin
|
216
259
|
@driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]')
|
217
260
|
puts'[Step.05] 내용 입력.......'.yellow
|
218
261
|
@driver.find_element(:xpath, '//*[@placeholder="내용을 입력해 주세요."]').click
|
262
|
+
rescue
|
263
|
+
puts '[Error] 내용 입력란을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
|
264
|
+
@driver.close
|
265
|
+
return 0
|
266
|
+
end
|
219
267
|
end
|
220
268
|
|
221
269
|
puts content
|
@@ -281,11 +329,17 @@ class Naver
|
|
281
329
|
puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
|
282
330
|
rescue
|
283
331
|
#종토리뷰
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
332
|
+
begin
|
333
|
+
@driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]')
|
334
|
+
sleep(1)
|
335
|
+
puts'[Step.06] 등록 버튼 클릭 (시도).......'.yellow
|
336
|
+
@driver.find_element(:xpath, '//*[@data-nclicks="nbw.ok"]').click
|
337
|
+
puts'[Step.07] 등록 버튼 클릭 (성공).......'.yellow
|
338
|
+
rescue
|
339
|
+
puts '[Error] 등록 버튼을 찾을 수 없습니다. 브라우저를 종료합니다.'.red
|
340
|
+
@driver.close
|
341
|
+
return 0
|
342
|
+
end
|
289
343
|
end
|
290
344
|
sleep(5)
|
291
345
|
begin
|
@@ -402,10 +456,27 @@ class Wordpress
|
|
402
456
|
@user_id = user_id
|
403
457
|
@user_pw = user_pw
|
404
458
|
begin
|
405
|
-
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
406
|
-
|
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)
|
407
473
|
rescue
|
408
|
-
|
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)
|
409
480
|
end
|
410
481
|
end
|
411
482
|
|
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.7
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|