zon_board_crawling 0.0.5 → 0.0.9
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/zon_board_crawling.rb +72 -81
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b247115b790f4ab4ff9a36026336d1b71fdf455f74d58562cdfc190b76d1a2e9
|
4
|
+
data.tar.gz: 1d1d14daa6d9d28e1b4e6975a670cb928b60e36aa93cab9ffa81e204d8048cc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edcc95a9f6a15e5bbb8b941ee13b3d9ddd2a62b8d350722e055566f828e3cdac8524f8f0235547fd09310123ab62c06854c9876059b492f4efd6b31a56b36fb8
|
7
|
+
data.tar.gz: b2b341db0e996539411bb654e20c846d57e7a065bb824d2e8b794796851026d912a51776bc80af4ec0eaeff4c932a2435dfd6fbddfb98386d86e40848042ac1c
|
data/lib/zon_board_crawling.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
|
-
require 'webdrivers'
|
4
3
|
require 'http'
|
5
4
|
require 'json'
|
6
5
|
require 'open3'
|
@@ -18,30 +17,39 @@ using Rainbow
|
|
18
17
|
|
19
18
|
class Naver
|
20
19
|
def initialize
|
20
|
+
kill_selenium_chrome #기존 창 모두 닫는 명령
|
21
|
+
sleep(1)
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
puts "
|
34
|
-
|
35
|
-
|
36
|
-
puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
|
37
|
-
chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
|
38
|
-
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
24
|
+
def kill_selenium_chrome #기존 창 모두 닫는 코드
|
25
|
+
wmi = WIN32OLE.connect("winmgmts://")
|
26
|
+
chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
|
27
|
+
|
28
|
+
chrome_procs.each do |proc|
|
29
|
+
cmd = proc.CommandLine
|
30
|
+
if cmd && cmd.include?("user-data-dir=C:/scraping_cookie")
|
31
|
+
puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
|
32
|
+
begin
|
33
|
+
proc.Terminate
|
34
|
+
rescue
|
35
|
+
#puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
|
36
|
+
end
|
37
|
+
end
|
39
38
|
end
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
# chromedriver도 같이 종료
|
41
|
+
chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
|
42
|
+
chromedrivers.each do |proc|
|
43
|
+
puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
|
44
|
+
begin
|
45
|
+
proc.Terminate
|
46
|
+
rescue
|
47
|
+
#puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
43
51
|
|
44
|
-
|
52
|
+
def chrome_setup(proxy, scraping_cookie_dir = "C:/scraping_cookie")
|
45
53
|
scraping_cookie_dir = "C:/scraping_cookie"
|
46
54
|
FileUtils.mkdir_p(scraping_cookie_dir) unless File.exist?(scraping_cookie_dir)
|
47
55
|
|
@@ -50,15 +58,27 @@ class Naver
|
|
50
58
|
else
|
51
59
|
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --remote-debugging-port=9222 --user-data-dir=C:/scraping_cookie --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko})
|
52
60
|
end
|
53
|
-
|
61
|
+
end
|
54
62
|
|
55
63
|
|
56
64
|
|
57
|
-
|
65
|
+
def chrome_start(proxy, scraping_cookie_dir = "C:/scraping_cookie")
|
58
66
|
scraping_cookie_dir = "C:/scraping_cookie"
|
59
67
|
FileUtils.mkdir_p(scraping_cookie_dir) unless File.exist?(scraping_cookie_dir)
|
60
68
|
if proxy == ''
|
61
69
|
begin
|
70
|
+
begin
|
71
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
72
|
+
rescue => e
|
73
|
+
puts "chromedriver 버전 불일치!!"
|
74
|
+
puts "아래 지침을 따라주세요."
|
75
|
+
puts "1.프로그램 종료!"
|
76
|
+
puts "2.크롬 업데이트!"
|
77
|
+
puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
|
78
|
+
puts "4.안내된 방식으로 크롬 드라이버 교체"
|
79
|
+
puts "5.재 시작"
|
80
|
+
exit 1
|
81
|
+
end
|
62
82
|
options = Selenium::WebDriver::Chrome::Options.new
|
63
83
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
64
84
|
#options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -91,7 +111,18 @@ class Naver
|
|
91
111
|
end
|
92
112
|
else
|
93
113
|
begin
|
94
|
-
|
114
|
+
begin
|
115
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
116
|
+
rescue => e
|
117
|
+
puts "chromedriver 버전 불일치!!"
|
118
|
+
puts "아래 지침을 따라주세요."
|
119
|
+
puts "1.프로그램 종료!"
|
120
|
+
puts "2.크롬 업데이트!"
|
121
|
+
puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
|
122
|
+
puts "4.안내된 방식으로 크롬 드라이버 교체"
|
123
|
+
puts "5.재 시작"
|
124
|
+
exit 1
|
125
|
+
end
|
95
126
|
options = Selenium::WebDriver::Chrome::Options.new
|
96
127
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
97
128
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -120,7 +151,18 @@ class Naver
|
|
120
151
|
puts e
|
121
152
|
puts 'proxy error...'
|
122
153
|
begin
|
123
|
-
|
154
|
+
begin
|
155
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
156
|
+
rescue => e
|
157
|
+
puts "chromedriver 버전 불일치!!"
|
158
|
+
puts "아래 지침을 따라주세요."
|
159
|
+
puts "1.프로그램 종료!"
|
160
|
+
puts "2.크롬 업데이트!"
|
161
|
+
puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
|
162
|
+
puts "4.안내된 방식으로 크롬 드라이버 교체"
|
163
|
+
puts "5.재 시작"
|
164
|
+
exit 1
|
165
|
+
end
|
124
166
|
options = Selenium::WebDriver::Chrome::Options.new
|
125
167
|
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
126
168
|
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
@@ -243,63 +285,12 @@ class Naver
|
|
243
285
|
|
244
286
|
begin
|
245
287
|
|
246
|
-
|
247
|
-
|
248
|
-
extension_url = 'chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html'
|
249
|
-
max_wait_time = 20
|
250
|
-
waited = 0
|
251
|
-
found = false
|
252
|
-
|
253
|
-
while waited < max_wait_time
|
254
|
-
all_windows = @driver.window_handles
|
255
|
-
all_windows.each do |window|
|
256
|
-
@driver.switch_to.window(window)
|
257
|
-
current_url = @driver.current_url
|
258
|
-
if current_url.include?(extension_url)
|
259
|
-
found = true
|
260
|
-
break
|
261
|
-
end
|
262
|
-
end
|
263
|
-
break if found
|
264
|
-
|
265
|
-
sleep(3)
|
266
|
-
waited += 1
|
267
|
-
end
|
268
|
-
|
269
|
-
if found
|
270
|
-
# 확장 프로그램 탭을 제외한 나머지 탭 닫기
|
271
|
-
all_windows = @driver.window_handles
|
272
|
-
all_windows.each do |window|
|
273
|
-
@driver.switch_to.window(window)
|
274
|
-
current_url = @driver.current_url
|
275
|
-
if !current_url.include?(extension_url)
|
276
|
-
sleep(2)
|
277
|
-
@driver.close
|
278
|
-
sleep(2)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
# 확장 프로그램 탭으로 전환
|
283
|
-
remaining_windows = @driver.window_handles
|
284
|
-
if remaining_windows.size > 0
|
285
|
-
@driver.switch_to.window(remaining_windows.first)
|
286
|
-
end
|
287
|
-
else
|
288
|
-
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
289
|
-
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
290
|
-
end
|
291
|
-
|
292
|
-
rescue => e
|
293
|
-
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
294
|
-
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
295
|
-
@driver.quit if @driver
|
296
|
-
end
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
288
|
+
@driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
|
289
|
+
sleep(5)
|
301
290
|
|
302
291
|
begin
|
292
|
+
@driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
|
293
|
+
sleep(1)
|
303
294
|
# 요소 찾기 타임아웃을 10초로 설정
|
304
295
|
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
305
296
|
#요소가 나타날 때까지 60초 동안 기다립니다.
|
@@ -349,8 +340,8 @@ class Naver
|
|
349
340
|
|
350
341
|
rescue
|
351
342
|
begin
|
343
|
+
@driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
|
352
344
|
sleep(1)
|
353
|
-
|
354
345
|
# 요소 찾기 타임아웃을 10초로 설정
|
355
346
|
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
356
347
|
#요소가 나타날 때까지 60초 동안 기다립니다.
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zon_board_crawling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-05-29 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: File to Clipboard gem
|
14
13
|
email: mymin26@naver.com
|
@@ -21,7 +20,6 @@ homepage: ''
|
|
21
20
|
licenses:
|
22
21
|
- zon
|
23
22
|
metadata: {}
|
24
|
-
post_install_message:
|
25
23
|
rdoc_options: []
|
26
24
|
require_paths:
|
27
25
|
- lib
|
@@ -36,8 +34,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
34
|
- !ruby/object:Gem::Version
|
37
35
|
version: '0'
|
38
36
|
requirements: []
|
39
|
-
rubygems_version: 3.
|
40
|
-
signing_key:
|
37
|
+
rubygems_version: 3.6.7
|
41
38
|
specification_version: 4
|
42
39
|
summary: file to clipboard
|
43
40
|
test_files: []
|