duo_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/duo_board_crawling.rb +42 -80
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8c7f6c53d26ac76b19e5c649c45954005693cf279f53eeeeca6e1f2853998ce
4
- data.tar.gz: 3c84ecec1d5891172dc16420c6e42a62427e1a69be3ddd502e4df445209046cd
3
+ metadata.gz: 90ecd573fc0dfa3377c1f8a85bfa3cf5c8b7e42f40dde8241b9d2634518e835b
4
+ data.tar.gz: 5b5864cf71b97168371a2b058ab421ba35186b35c755cfd1526536652bb49c7a
5
5
  SHA512:
6
- metadata.gz: 1a95ef8b4180403df2667c9c00618175b2ab20ed6b8191c5ce94436e72b3e571b892448cb2199b1db5be3d7cf545a96745b47211e94f1211e679288944e79f58
7
- data.tar.gz: 7da6301c6b187cfcd668402bbf130328c8d369efef28df197b7139ce433decc3299b746495261cf1720fc5fbd30034794ccb6fed6feedad1c7c0631709756fe1
6
+ metadata.gz: '028fd94fd18141428af06b73b416507794e97f7c2808207d0ded86e42bcf0ca3394e1c522aca92159663428d15cb7d51cc6bc1662330c0bfb117758e3a556356'
7
+ data.tar.gz: 4887060d7b8325cae745b2809f97bb31dae142386471533b3600d98c827933a211025a8308980e8429fa83845e8315b6bcd99c3634c1b2763a5115a1dd16cb04
@@ -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'
@@ -16,30 +15,10 @@ require 'win32ole'
16
15
  using Rainbow
17
16
 
18
17
 
19
-
20
-
21
-
22
18
  class Naver
23
19
  def initialize
24
20
 
25
- begin
26
- # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
27
- puts "크롬을 최신 상태로 업데이트 해주세요"
28
- puts "크롬 최신 상태가 아닐경우 오류가 발생될수있습니다."
29
- # Webdrivers가 드라이버를 다운로드할 경로를 설정
30
- Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
31
- Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
32
- # 크롬드라이버 자동 업데이트 시도
33
- Webdrivers::Chromedriver.update
34
- puts "chromedriver 자동 다운로드 성공"
35
- rescue => e
36
- puts "chromedriver 자동 다운로드 실패: #{e.message}"
37
- puts "폴더내 크롬드라이버를 사용합니다."
38
- puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
39
- puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
40
- chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
41
- Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
42
- end
21
+
43
22
 
44
23
  end
45
24
 
@@ -62,6 +41,18 @@ class Naver
62
41
  FileUtils.mkdir_p(scraping_cookie_dir) unless File.exist?(scraping_cookie_dir)
63
42
  if proxy == ''
64
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
65
56
  options = Selenium::WebDriver::Chrome::Options.new
66
57
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
67
58
  #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -94,7 +85,18 @@ class Naver
94
85
  end
95
86
  else
96
87
  begin
97
- 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
98
100
  options = Selenium::WebDriver::Chrome::Options.new
99
101
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
100
102
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -123,7 +125,18 @@ class Naver
123
125
  puts e
124
126
  puts 'proxy error...'
125
127
  begin
126
- 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
127
140
  options = Selenium::WebDriver::Chrome::Options.new
128
141
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
129
142
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -246,63 +259,12 @@ class Naver
246
259
 
247
260
  begin
248
261
 
249
- begin
250
- # 최대 20초 동안 확장 프로그램 탭이 열릴 때까지 대기
251
- extension_url = 'chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html'
252
- max_wait_time = 20
253
- waited = 0
254
- found = false
255
-
256
- while waited < max_wait_time
257
- all_windows = @driver.window_handles
258
- all_windows.each do |window|
259
- @driver.switch_to.window(window)
260
- current_url = @driver.current_url
261
- if current_url.include?(extension_url)
262
- found = true
263
- break
264
- end
265
- end
266
- break if found
267
-
268
- sleep(3)
269
- waited += 1
270
- end
271
-
272
- if found
273
- # 확장 프로그램 탭을 제외한 나머지 탭 닫기
274
- all_windows = @driver.window_handles
275
- all_windows.each do |window|
276
- @driver.switch_to.window(window)
277
- current_url = @driver.current_url
278
- if !current_url.include?(extension_url)
279
- sleep(2)
280
- @driver.close
281
- sleep(2)
282
- end
283
- end
284
-
285
- # 확장 프로그램 탭으로 전환
286
- remaining_windows = @driver.window_handles
287
- if remaining_windows.size > 0
288
- @driver.switch_to.window(remaining_windows.first)
289
- end
290
- else
291
- puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
292
- puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
293
- end
294
-
295
- rescue => e
296
- puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
297
- puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
298
- @driver.quit if @driver
299
- end
300
-
301
-
302
-
303
-
262
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
263
+ sleep(5)
304
264
 
305
265
  begin
266
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
267
+ sleep(1)
306
268
  # 요소 찾기 타임아웃을 10초로 설정
307
269
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
308
270
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -352,8 +314,8 @@ class Naver
352
314
 
353
315
  rescue
354
316
  begin
317
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
355
318
  sleep(1)
356
-
357
319
  # 요소 찾기 타임아웃을 10초로 설정
358
320
  wait = Selenium::WebDriver::Wait.new(:timeout => 5)
359
321
  #요소가 나타날 때까지 60초 동안 기다립니다.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duo_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
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-11 00:00:00.000000000 Z
10
+ date: 2025-05-13 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com