zon_board_crawling 0.0.5 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zon_board_crawling.rb +42 -77
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ba23bc3403ca85b71b485f42e604d24ab92cd97e1ec22d7dd75ef5bbb3cec82
4
- data.tar.gz: 55d759b47240621bd7758063449ac1298c5c2bfd4332a42494a8788ab74f2d26
3
+ metadata.gz: bbf18fa7c9f7b8b4408d648db3e9103cdb22839f2ea5814d47c2b6c8ada05681
4
+ data.tar.gz: c9e1848c529544c07d6d94ebaea3251035157a3d2517d64f4ea67f3e5a58f575
5
5
  SHA512:
6
- metadata.gz: 38542d8cf8689aa476b94f3731a137a9e849dd08096169123baecdad1b8d0b6deed2218727365caae13fb2fabd89481515af97e1cfb8cb9eae887a37223fb526
7
- data.tar.gz: b181019d256bf021c1c14956c24a9d675e84a3f54d32d2823f74bc43d7503a86d39bdce18f5a22891159591067b12254ecb6e5ee090fb81687a634d6b01443a0
6
+ metadata.gz: a88bc6e5d4feef3f1a4c2ba4b0c9eac20ccb9893b54eccc1de16c2493168bcbaae57862201d6fc5a60238e07ddf35fc4da04a60e237cfb4f72c6b4af85bcb0a7
7
+ data.tar.gz: 70a82d505a6434ecc22099a722fd3ee0f8fdbcbb2125884b18362e9e8daa4121549b6b1e4f016ea44379ed55ef21f0a84d8a17757d7a5055dd47ee7abf5a7b4f
@@ -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'
@@ -19,24 +18,7 @@ using Rainbow
19
18
  class Naver
20
19
  def initialize
21
20
 
22
- begin
23
- # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
24
- puts "크롬을 최신 상태로 업데이트 해주세요"
25
- puts "크롬 최신 상태가 아닐경우 오류가 발생될수있습니다."
26
- # Webdrivers가 드라이버를 다운로드할 경로를 설정
27
- Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
28
- Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
29
- # 크롬드라이버 자동 업데이트 시도
30
- Webdrivers::Chromedriver.update
31
- puts "chromedriver 자동 다운로드 성공"
32
- rescue => e
33
- puts "chromedriver 자동 다운로드 실패: #{e.message}"
34
- puts "폴더내 크롬드라이버를 사용합니다."
35
- puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
36
- puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
37
- chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
38
- Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
39
- end
21
+
40
22
 
41
23
  end
42
24
 
@@ -59,6 +41,18 @@ class Naver
59
41
  FileUtils.mkdir_p(scraping_cookie_dir) unless File.exist?(scraping_cookie_dir)
60
42
  if proxy == ''
61
43
  begin
44
+ begin
45
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
46
+ rescue => e
47
+ puts "chromedriver 버전 불일치!!"
48
+ puts "아래 지침을 따라주세요."
49
+ puts "1.프로그램 종료!"
50
+ puts "2.크롬 업데이트!"
51
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
52
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
53
+ puts "5.재 시작"
54
+ exit 1
55
+ end
62
56
  options = Selenium::WebDriver::Chrome::Options.new
63
57
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
64
58
  #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -91,7 +85,18 @@ class Naver
91
85
  end
92
86
  else
93
87
  begin
94
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
88
+ begin
89
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
90
+ rescue => e
91
+ puts "chromedriver 버전 불일치!!"
92
+ puts "아래 지침을 따라주세요."
93
+ puts "1.프로그램 종료!"
94
+ puts "2.크롬 업데이트!"
95
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
96
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
97
+ puts "5.재 시작"
98
+ exit 1
99
+ end
95
100
  options = Selenium::WebDriver::Chrome::Options.new
96
101
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
97
102
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -120,7 +125,18 @@ class Naver
120
125
  puts e
121
126
  puts 'proxy error...'
122
127
  begin
123
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
128
+ begin
129
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
130
+ rescue => e
131
+ puts "chromedriver 버전 불일치!!"
132
+ puts "아래 지침을 따라주세요."
133
+ puts "1.프로그램 종료!"
134
+ puts "2.크롬 업데이트!"
135
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
136
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
137
+ puts "5.재 시작"
138
+ exit 1
139
+ end
124
140
  options = Selenium::WebDriver::Chrome::Options.new
125
141
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
126
142
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -243,63 +259,12 @@ class Naver
243
259
 
244
260
  begin
245
261
 
246
- begin
247
- # 최대 20초 동안 확장 프로그램 탭이 열릴 때까지 대기
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
-
262
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
263
+ sleep(5)
301
264
 
302
265
  begin
266
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
267
+ sleep(1)
303
268
  # 요소 찾기 타임아웃을 10초로 설정
304
269
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
305
270
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -349,8 +314,8 @@ class Naver
349
314
 
350
315
  rescue
351
316
  begin
317
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
352
318
  sleep(1)
353
-
354
319
  # 요소 찾기 타임아웃을 10초로 설정
355
320
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
356
321
  #요소가 나타날 때까지 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.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-10 00:00:00.000000000 Z
10
+ date: 2025-05-13 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.3.7
40
- signing_key:
37
+ rubygems_version: 3.6.7
41
38
  specification_version: 4
42
39
  summary: file to clipboard
43
40
  test_files: []