zon_board_crawling 0.0.2 → 0.0.5
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 +280 -95
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba23bc3403ca85b71b485f42e604d24ab92cd97e1ec22d7dd75ef5bbb3cec82
|
4
|
+
data.tar.gz: 55d759b47240621bd7758063449ac1298c5c2bfd4332a42494a8788ab74f2d26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38542d8cf8689aa476b94f3731a137a9e849dd08096169123baecdad1b8d0b6deed2218727365caae13fb2fabd89481515af97e1cfb8cb9eae887a37223fb526
|
7
|
+
data.tar.gz: b181019d256bf021c1c14956c24a9d675e84a3f54d32d2823f74bc43d7503a86d39bdce18f5a22891159591067b12254ecb6e5ee090fb81687a634d6b01443a0
|
data/lib/zon_board_crawling.rb
CHANGED
@@ -1,31 +1,21 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
3
|
require 'webdrivers'
|
4
|
-
require 'iconv'
|
5
|
-
require 'nokogiri'
|
6
|
-
require 'open-uri'
|
7
4
|
require 'http'
|
8
5
|
require 'json'
|
9
|
-
require 'down'
|
10
|
-
require 'rmagick'
|
11
|
-
require 'fileutils'
|
12
|
-
require 'rest-client'
|
13
6
|
require 'open3'
|
14
|
-
require '
|
15
|
-
require '
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'open-uri'
|
9
|
+
require 'fileutils'
|
16
10
|
require 'uri'
|
17
|
-
require 'cgi'
|
18
|
-
require 'digest'
|
19
|
-
require 'auto_click'
|
20
11
|
require 'rainbow/refinement'
|
21
12
|
require 'watir'
|
13
|
+
require 'clipboard'
|
22
14
|
require 'timeout'
|
23
|
-
|
15
|
+
require 'win32ole'
|
24
16
|
using Rainbow
|
25
17
|
|
26
18
|
|
27
|
-
|
28
|
-
|
29
19
|
class Naver
|
30
20
|
def initialize
|
31
21
|
|
@@ -230,16 +220,17 @@ class Naver
|
|
230
220
|
wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
|
231
221
|
sleep(1.5)
|
232
222
|
@driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
|
233
|
-
puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.
|
234
|
-
puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.
|
223
|
+
puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.red
|
224
|
+
puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.red
|
235
225
|
sleep(1.5)
|
236
|
-
|
237
|
-
|
238
|
-
|
226
|
+
shell = WIN32OLE.new('WScript.Shell')
|
227
|
+
shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
|
228
|
+
shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
|
239
229
|
sleep(1)
|
240
|
-
|
230
|
+
shell.SendKeys("{TAB}")
|
241
231
|
sleep(0.5)
|
242
|
-
|
232
|
+
shell.SendKeys("{ENTER}")
|
233
|
+
|
243
234
|
check_cookie_login = 0
|
244
235
|
sleep(1)
|
245
236
|
rescue
|
@@ -249,58 +240,66 @@ class Naver
|
|
249
240
|
end
|
250
241
|
|
251
242
|
if check_cookie_login == 0
|
252
|
-
|
243
|
+
|
253
244
|
begin
|
254
245
|
|
255
246
|
begin
|
256
|
-
#
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
rescue Selenium::WebDriver::Error::WebDriverError => e
|
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
|
272
261
|
end
|
273
|
-
else
|
274
262
|
end
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
if all_windows.size > 0
|
280
|
-
@driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
|
281
|
-
else
|
263
|
+
break if found
|
264
|
+
|
265
|
+
sleep(3)
|
266
|
+
waited += 1
|
282
267
|
end
|
283
268
|
|
284
|
-
|
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
|
285
291
|
|
286
292
|
rescue => e
|
293
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
294
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
287
295
|
@driver.quit if @driver
|
288
296
|
end
|
289
297
|
|
290
298
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
# 빈 탭에서 원하는 작업을 진행하거나, 옵션 페이지로 이동
|
295
|
-
@driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
|
296
|
-
sleep(1)
|
297
|
-
|
298
|
-
|
299
299
|
|
300
300
|
|
301
301
|
|
302
302
|
begin
|
303
|
-
puts '-[√] 캡챠 연결 설정 1차 시도.......'.green
|
304
303
|
# 요소 찾기 타임아웃을 10초로 설정
|
305
304
|
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
306
305
|
#요소가 나타날 때까지 60초 동안 기다립니다.
|
@@ -326,7 +325,6 @@ class Naver
|
|
326
325
|
end
|
327
326
|
end
|
328
327
|
rescue Selenium::WebDriver::Error::TimeoutError
|
329
|
-
puts "alert이 없으므로 버튼 클릭"
|
330
328
|
@driver.find_element(:xpath, '//*[@id="connect"]').click
|
331
329
|
begin
|
332
330
|
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
@@ -340,9 +338,9 @@ class Naver
|
|
340
338
|
false
|
341
339
|
end
|
342
340
|
end
|
343
|
-
puts "두 번째 alert 처리 완료"
|
344
341
|
rescue Selenium::WebDriver::Error::TimeoutError
|
345
|
-
puts "
|
342
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
343
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
346
344
|
system('taskkill /F /IM chrome.exe')
|
347
345
|
@driver.quit if @driver
|
348
346
|
end
|
@@ -351,11 +349,8 @@ class Naver
|
|
351
349
|
|
352
350
|
rescue
|
353
351
|
begin
|
354
|
-
puts '-[√] 캡챠 연결 설정 2차 시도.......'.green
|
355
352
|
sleep(1)
|
356
|
-
|
357
|
-
|
358
|
-
|
353
|
+
|
359
354
|
# 요소 찾기 타임아웃을 10초로 설정
|
360
355
|
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
361
356
|
#요소가 나타날 때까지 60초 동안 기다립니다.
|
@@ -365,10 +360,6 @@ class Naver
|
|
365
360
|
begin
|
366
361
|
@driver.find_element(:xpath, '//*[@name="apiKey"]').click
|
367
362
|
rescue
|
368
|
-
|
369
|
-
puts '-[√] 로딩 및 코드인식 실패등 기타 이유로 다음 게시판 작업으로 이동합니다.......'.red
|
370
|
-
puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
|
371
|
-
|
372
363
|
end
|
373
364
|
|
374
365
|
Clipboard.copy(captcha_key)
|
@@ -391,7 +382,7 @@ class Naver
|
|
391
382
|
end
|
392
383
|
end
|
393
384
|
rescue Selenium::WebDriver::Error::TimeoutError
|
394
|
-
|
385
|
+
|
395
386
|
@driver.find_element(:xpath, '//*[@class="default-btn"]').click
|
396
387
|
begin
|
397
388
|
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
@@ -405,9 +396,10 @@ class Naver
|
|
405
396
|
false
|
406
397
|
end
|
407
398
|
end
|
408
|
-
|
399
|
+
|
409
400
|
rescue Selenium::WebDriver::Error::TimeoutError
|
410
|
-
puts "
|
401
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
402
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
411
403
|
system('taskkill /F /IM chrome.exe')
|
412
404
|
@driver.quit if @driver
|
413
405
|
end
|
@@ -420,7 +412,8 @@ class Naver
|
|
420
412
|
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
421
413
|
@driver.close
|
422
414
|
rescue Selenium::WebDriver::Error::WebDriverError => e
|
423
|
-
|
415
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
416
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
424
417
|
end
|
425
418
|
end
|
426
419
|
return 0
|
@@ -429,15 +422,16 @@ class Naver
|
|
429
422
|
|
430
423
|
|
431
424
|
rescue => e
|
432
|
-
puts
|
433
|
-
puts
|
425
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
426
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
434
427
|
@driver.window_handles.each do |handle|
|
435
428
|
@driver.switch_to.window(handle)
|
436
429
|
begin
|
437
430
|
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
438
431
|
@driver.close
|
439
432
|
rescue Selenium::WebDriver::Error::WebDriverError => e
|
440
|
-
|
433
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
434
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
441
435
|
end
|
442
436
|
end
|
443
437
|
return 0
|
@@ -447,7 +441,8 @@ class Naver
|
|
447
441
|
end
|
448
442
|
|
449
443
|
rescue => e
|
450
|
-
puts
|
444
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
445
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
451
446
|
@driver.window_handles.each do |handle|
|
452
447
|
@driver.switch_to.window(handle)
|
453
448
|
begin
|
@@ -460,6 +455,86 @@ class Naver
|
|
460
455
|
@driver.quit
|
461
456
|
return 0
|
462
457
|
end
|
458
|
+
|
459
|
+
begin
|
460
|
+
@driver.get('https://chromewebstore.google.com/detail/%EC%9B%B9-%ED%94%84%EB%A1%9D%EC%8B%9C/lcbpobjekkgofogdbjjhgefgmmncfada')
|
461
|
+
sleep(1)
|
462
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 3)
|
463
|
+
wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
|
464
|
+
sleep(1.5)
|
465
|
+
@driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
|
466
|
+
sleep(1.5)
|
467
|
+
shell = WIN32OLE.new('WScript.Shell')
|
468
|
+
begin
|
469
|
+
# 첫 번째 창 이름 시도
|
470
|
+
shell.AppActivate("웹 프록시 - Chrome 웹 스토어")
|
471
|
+
shell.AppActivate("웹 프록시 - Chrome 웹 스토어")
|
472
|
+
rescue
|
473
|
+
# 첫 번째 창이 없으면 두 번째 창 이름으로 시도
|
474
|
+
shell.AppActivate("Web proxy")
|
475
|
+
shell.AppActivate("Web proxy")
|
476
|
+
end
|
477
|
+
sleep(1)
|
478
|
+
shell.SendKeys("{TAB}")
|
479
|
+
sleep(0.5)
|
480
|
+
# Enter 키 입력
|
481
|
+
shell.SendKeys("{ENTER}")
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
begin
|
488
|
+
target_url = 'https://extaddon.site/web-proxy/chrome/'
|
489
|
+
max_wait_time = 20
|
490
|
+
waited = 0
|
491
|
+
target_window = nil
|
492
|
+
|
493
|
+
# 최대 20초 대기
|
494
|
+
while waited < max_wait_time
|
495
|
+
all_windows = @driver.window_handles
|
496
|
+
all_windows.each do |window|
|
497
|
+
@driver.switch_to.window(window)
|
498
|
+
current_url = @driver.current_url
|
499
|
+
if current_url.include?(target_url)
|
500
|
+
target_window = window
|
501
|
+
break
|
502
|
+
end
|
503
|
+
end
|
504
|
+
break if target_window
|
505
|
+
|
506
|
+
sleep(3)
|
507
|
+
waited += 1
|
508
|
+
end
|
509
|
+
|
510
|
+
if target_window
|
511
|
+
@driver.switch_to.window(target_window)
|
512
|
+
sleep(2)
|
513
|
+
@driver.close
|
514
|
+
sleep(2)
|
515
|
+
else
|
516
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
517
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
518
|
+
end
|
519
|
+
|
520
|
+
# 닫은 후 남아있는 탭 중 첫 번째 탭으로 포커스 이동
|
521
|
+
remaining_windows = @driver.window_handles
|
522
|
+
@driver.switch_to.window(remaining_windows.first) if remaining_windows.any?
|
523
|
+
|
524
|
+
rescue => e
|
525
|
+
puts "초기 작업 브라우저가 완벽하게 세팅 되지 않았습니다.".red
|
526
|
+
puts "C드라이브에서 scraping_cookie 폴더 삭제 후 다시 시작해주세요.".red
|
527
|
+
@driver.quit if @driver
|
528
|
+
end
|
529
|
+
|
530
|
+
|
531
|
+
puts "[Step.03] 작업 브라우저가 완벽하게 세팅 되었습니다.".red
|
532
|
+
puts "[※Tip!!] 작업 브라우저 세팅은 매번 하지않고 초기에만 진행합니다.".red
|
533
|
+
|
534
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
535
|
+
puts "크롬 브라우저 종료: #{e.message}"
|
536
|
+
end
|
537
|
+
|
463
538
|
|
464
539
|
else
|
465
540
|
# @driver.switch_to.default_content
|
@@ -470,12 +545,18 @@ class Naver
|
|
470
545
|
|
471
546
|
|
472
547
|
@driver.get('https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko')
|
473
|
-
|
548
|
+
sleep(1)
|
474
549
|
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
|
475
550
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
476
551
|
wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
|
477
552
|
|
478
|
-
|
553
|
+
sleep(1)
|
554
|
+
shell = WIN32OLE.new('WScript.Shell')#크롬창에 타겟주고 확장프로그램 열기
|
555
|
+
shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
|
556
|
+
shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
|
557
|
+
sleep(1)
|
558
|
+
shell.SendKeys('^+7')# Ctrl + Shift + 7 단축키 입력 시뮬레이션
|
559
|
+
sleep(1)
|
479
560
|
|
480
561
|
rescue => e
|
481
562
|
puts '-[√] 연결 실패.......'.red
|
@@ -493,9 +574,10 @@ class Naver
|
|
493
574
|
end
|
494
575
|
end
|
495
576
|
|
577
|
+
|
496
578
|
|
497
579
|
sleep(1)
|
498
|
-
def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
580
|
+
def update(keyword_input, counter, option, captcha_key, sleep_delay, proxy_list)
|
499
581
|
puts 'start...'.yellow
|
500
582
|
@keyword_input = keyword_input
|
501
583
|
@counter = counter
|
@@ -600,7 +682,6 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
|
600
682
|
end
|
601
683
|
# 캡챠 발생시──────────────────────────────────────────────────────────────
|
602
684
|
|
603
|
-
|
604
685
|
# elements를 찾는 xpath 수정: href에 "/bbs/board.php?"가 포함된 링크만 추출
|
605
686
|
elements = @driver.find_elements(xpath: '//div[@class="MjjYud"]//a[contains(@href, "/bbs/board.php?")]')
|
606
687
|
sleep(1)
|
@@ -650,6 +731,28 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
|
650
731
|
puts "href를 찾을 수 없습니다: #{e.message}".red
|
651
732
|
end
|
652
733
|
end
|
734
|
+
|
735
|
+
|
736
|
+
if option['프록시'] == 'true'
|
737
|
+
|
738
|
+
shuffled_proxies = proxy_list.shuffle
|
739
|
+
proxy_ip = shuffled_proxies.first
|
740
|
+
puts "프록시 변경 IP: #{proxy_ip}".green
|
741
|
+
|
742
|
+
@driver.switch_to.window(@driver.window_handles[1])
|
743
|
+
@driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
|
744
|
+
sleep(1)
|
745
|
+
#Clipboard.copy(proxy_ip)
|
746
|
+
@driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
|
747
|
+
sleep(0.5)
|
748
|
+
@driver.action.key_down(:enter).key_up(:enter).perform #엔터
|
749
|
+
sleep(1)
|
750
|
+
@driver.switch_to.window(@driver.window_handles[0])
|
751
|
+
|
752
|
+
else
|
753
|
+
end
|
754
|
+
|
755
|
+
|
653
756
|
sleep(sleep_delay)
|
654
757
|
# 수집 목표 개수에 도달했으면 종료
|
655
758
|
break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
|
@@ -812,6 +915,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
|
812
915
|
puts "href를 찾을 수 없습니다: #{e.message}".red
|
813
916
|
end
|
814
917
|
end
|
918
|
+
|
919
|
+
if option['프록시'] == 'true'
|
920
|
+
|
921
|
+
shuffled_proxies = proxy_list.shuffle
|
922
|
+
proxy_ip = shuffled_proxies.first
|
923
|
+
puts "프록시 변경 IP: #{proxy_ip}".green
|
924
|
+
|
925
|
+
@driver.switch_to.window(@driver.window_handles[1])
|
926
|
+
@driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
|
927
|
+
sleep(1)
|
928
|
+
#Clipboard.copy(proxy_ip)
|
929
|
+
@driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
|
930
|
+
sleep(0.5)
|
931
|
+
@driver.action.key_down(:enter).key_up(:enter).perform #엔터
|
932
|
+
sleep(1)
|
933
|
+
@driver.switch_to.window(@driver.window_handles[0])
|
934
|
+
|
935
|
+
else
|
936
|
+
end
|
937
|
+
|
815
938
|
sleep(sleep_delay)
|
816
939
|
# 수집 목표 개수에 도달했으면 종료
|
817
940
|
break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
|
@@ -985,6 +1108,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
|
985
1108
|
puts "href를 찾을 수 없습니다: #{e.message}".red
|
986
1109
|
end
|
987
1110
|
end
|
1111
|
+
|
1112
|
+
if option['프록시'] == 'true'
|
1113
|
+
|
1114
|
+
shuffled_proxies = proxy_list.shuffle
|
1115
|
+
proxy_ip = shuffled_proxies.first
|
1116
|
+
puts "프록시 변경 IP: #{proxy_ip}".green
|
1117
|
+
|
1118
|
+
@driver.switch_to.window(@driver.window_handles[1])
|
1119
|
+
@driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
|
1120
|
+
sleep(1)
|
1121
|
+
#Clipboard.copy(proxy_ip)
|
1122
|
+
@driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
|
1123
|
+
sleep(0.5)
|
1124
|
+
@driver.action.key_down(:enter).key_up(:enter).perform #엔터
|
1125
|
+
sleep(1)
|
1126
|
+
@driver.switch_to.window(@driver.window_handles[0])
|
1127
|
+
|
1128
|
+
else
|
1129
|
+
end
|
1130
|
+
|
988
1131
|
sleep(sleep_delay)
|
989
1132
|
# 수집 목표 개수에 도달했으면 종료
|
990
1133
|
break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
|
@@ -1154,6 +1297,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
|
1154
1297
|
puts "href를 찾을 수 없습니다: #{e.message}".red
|
1155
1298
|
end
|
1156
1299
|
end
|
1300
|
+
|
1301
|
+
if option['프록시'] == 'true'
|
1302
|
+
|
1303
|
+
shuffled_proxies = proxy_list.shuffle
|
1304
|
+
proxy_ip = shuffled_proxies.first
|
1305
|
+
puts "프록시 변경 IP: #{proxy_ip}".green
|
1306
|
+
|
1307
|
+
@driver.switch_to.window(@driver.window_handles[1])
|
1308
|
+
@driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
|
1309
|
+
sleep(1)
|
1310
|
+
#Clipboard.copy(proxy_ip)
|
1311
|
+
@driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
|
1312
|
+
sleep(0.5)
|
1313
|
+
@driver.action.key_down(:enter).key_up(:enter).perform #엔터
|
1314
|
+
sleep(1)
|
1315
|
+
@driver.switch_to.window(@driver.window_handles[0])
|
1316
|
+
|
1317
|
+
else
|
1318
|
+
end
|
1319
|
+
|
1157
1320
|
sleep(sleep_delay)
|
1158
1321
|
# 수집 목표 개수에 도달했으면 종료
|
1159
1322
|
break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
|
@@ -1317,6 +1480,26 @@ def update(keyword_input, counter, option, captcha_key, sleep_delay)
|
|
1317
1480
|
puts "href를 찾을 수 없습니다: #{e.message}".red
|
1318
1481
|
end
|
1319
1482
|
end
|
1483
|
+
|
1484
|
+
if option['프록시'] == 'true'
|
1485
|
+
|
1486
|
+
shuffled_proxies = proxy_list.shuffle
|
1487
|
+
proxy_ip = shuffled_proxies.first
|
1488
|
+
puts "프록시 변경 IP: #{proxy_ip}".green
|
1489
|
+
|
1490
|
+
@driver.switch_to.window(@driver.window_handles[1])
|
1491
|
+
@driver.find_element(:xpath, '//*[@id="ui_clear_default"]').click
|
1492
|
+
sleep(1)
|
1493
|
+
#Clipboard.copy(proxy_ip)
|
1494
|
+
@driver.find_element(:xpath, '//*[@id="ui_proxy_default"]').send_keys(proxy_ip)
|
1495
|
+
sleep(0.5)
|
1496
|
+
@driver.action.key_down(:enter).key_up(:enter).perform #엔터
|
1497
|
+
sleep(1)
|
1498
|
+
@driver.switch_to.window(@driver.window_handles[0])
|
1499
|
+
|
1500
|
+
else
|
1501
|
+
end
|
1502
|
+
|
1320
1503
|
sleep(sleep_delay)
|
1321
1504
|
# 수집 목표 개수에 도달했으면 종료
|
1322
1505
|
break if collected_count >= @counter # 수집 목표 개수에 도달했으면 종료
|
@@ -2983,17 +3166,27 @@ class Wordpress
|
|
2983
3166
|
option['중복금지'] = 'false'
|
2984
3167
|
end
|
2985
3168
|
|
2986
|
-
@data['table'][index][-1] =
|
3169
|
+
@data['table'][index][-1] = 65
|
3170
|
+
@data['table'] << []
|
3171
|
+
@data['table'].pop
|
3172
|
+
|
3173
|
+
|
3174
|
+
if @data['포스트설정']['프록시'].checked?
|
3175
|
+
option['프록시'] = 'true'
|
3176
|
+
proxy_list = @data['포스트설정']['프록시리스트']
|
3177
|
+
|
3178
|
+
else
|
3179
|
+
option['프록시'] = 'false'
|
3180
|
+
end
|
3181
|
+
|
3182
|
+
@data['table'][index][-1] = 65
|
2987
3183
|
@data['table'] << []
|
2988
3184
|
@data['table'].pop
|
2989
3185
|
|
2990
|
-
# 옵션 출력 확인
|
2991
|
-
#p option
|
2992
|
-
|
2993
3186
|
|
2994
3187
|
|
2995
3188
|
#puts 'start...'
|
2996
|
-
naver.update(keyword_input, counter, option, captcha_key, sleep_delay)
|
3189
|
+
naver.update(keyword_input, counter, option, captcha_key, sleep_delay, proxy_list)
|
2997
3190
|
|
2998
3191
|
@data['table'][index][3] = @data['table'][index][3].to_i + 1
|
2999
3192
|
@data['table'][index][-1] = 100
|
@@ -3098,8 +3291,8 @@ class Wordpress
|
|
3098
3291
|
end
|
3099
3292
|
|
3100
3293
|
if i.class == Array
|
3101
|
-
i[
|
3102
|
-
i[5] = i[5].to_i
|
3294
|
+
i[1] = i[1].to_i
|
3295
|
+
#i[5] = i[5].to_i
|
3103
3296
|
@data[key] << i
|
3104
3297
|
@data[key] << i
|
3105
3298
|
@data[key].pop
|
@@ -3143,14 +3336,6 @@ class Wordpress
|
|
3143
3336
|
@data['table'].pop
|
3144
3337
|
end
|
3145
3338
|
|
3146
|
-
while true
|
3147
|
-
if @data['키워드설정']['키워드'].length == 0
|
3148
|
-
break
|
3149
|
-
end
|
3150
|
-
|
3151
|
-
@data['키워드설정']['키워드'].pop
|
3152
|
-
end
|
3153
|
-
|
3154
3339
|
|
3155
3340
|
|
3156
3341
|
|