cafe_buy 0.0.33 → 0.0.36
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/cafe_buy.rb +106 -44
- 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: 9a2b86e82d287673f6aeb5c149ae38ef7601a9bc7332a5c4e94a4430bb8b2b5e
|
4
|
+
data.tar.gz: fd2fd84e201f97bc3af3253d37aa0cdd50217db4656a0b1090eaa5d78f055337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e4f2a16a2fc2790b10ce4c28ec83a7656ec1441c22a830a29533b18001074d082cbb2440d886dc777ba28fe4a06e9d1d490e2171e46e4f5d26d6b763b1f8300
|
7
|
+
data.tar.gz: ba36cfc6801e4c1d6f28f896f9f3df56a1068ed1197c458ea22c0476e295043a98255576b5ef7203bea26486f0b3a88c6f5ad50adacd7fa374849c47e5323a67
|
data/lib/cafe_buy.rb
CHANGED
@@ -226,6 +226,8 @@ class Naver
|
|
226
226
|
begin
|
227
227
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
228
228
|
options = Selenium::WebDriver::Chrome::Options.new
|
229
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
230
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
229
231
|
options.page_load_strategy = :normal
|
230
232
|
options.timeouts = {page_load: 20_000}
|
231
233
|
options.page_load_strategy = 'none'
|
@@ -241,13 +243,8 @@ class Naver
|
|
241
243
|
begin
|
242
244
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
243
245
|
options = Selenium::WebDriver::Chrome::Options.new
|
244
|
-
#
|
245
|
-
|
246
|
-
# profile['network.proxy.http'] = proxy.split(':')[0]
|
247
|
-
# profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
|
248
|
-
# options = Selenium::WebDriver::Chrome::Options.new
|
249
|
-
# options.profile = profile
|
250
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
246
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
247
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
251
248
|
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
252
249
|
options.page_load_strategy = :normal
|
253
250
|
options.timeouts = {page_load: 20_000}
|
@@ -263,6 +260,8 @@ class Naver
|
|
263
260
|
begin
|
264
261
|
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
265
262
|
options = Selenium::WebDriver::Chrome::Options.new
|
263
|
+
options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
|
264
|
+
options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
|
266
265
|
options.page_load_strategy = :normal
|
267
266
|
options.timeouts = {page_load: 20_000}
|
268
267
|
options.page_load_strategy = 'none'
|
@@ -310,39 +309,57 @@ class Naver
|
|
310
309
|
sleep(1)
|
311
310
|
|
312
311
|
begin
|
313
|
-
wait = Selenium::WebDriver::Wait.new(:timeout =>
|
312
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
313
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
314
|
+
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
315
|
+
sleep(1.5)
|
316
|
+
check_cookie_login = 1
|
317
|
+
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
318
|
+
sleep(2.5)
|
319
|
+
rescue
|
320
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
314
321
|
#요소가 나타날 때까지 3초 동안 기다립니다.
|
315
322
|
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
|
316
323
|
sleep(1.5)
|
317
324
|
@driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
|
318
325
|
check_cookie_login = 0
|
319
326
|
sleep(1)
|
320
|
-
rescue
|
321
|
-
check_cookie_login = 1
|
322
|
-
puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
|
323
|
-
sleep(2.5)
|
324
327
|
end
|
325
328
|
|
326
329
|
if check_cookie_login == 0
|
327
330
|
puts'[Step.02] 계정 세션이 없거나 기간 만료로 인해 로그인 시도.......'.yellow
|
328
331
|
# @driver.find_element(:xpath, '//*[@id="right-content-area"]/div[1]/div[1]/div/a').click
|
329
332
|
sleep(3)
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
333
|
+
begin
|
334
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 7)
|
335
|
+
#요소가 나타날 때까지 3초 동안 기다립니다.
|
336
|
+
wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
|
337
|
+
sleep(1.5)
|
338
|
+
@driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
|
339
|
+
sleep(1.5)
|
340
|
+
@driver.find_element(:xpath, '//*[@id="id"]').click
|
341
|
+
Clipboard.copy(user_id)
|
342
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
343
|
+
sleep(1.5)
|
344
|
+
@driver.find_element(:xpath, '//*[@id="pw"]').click
|
345
|
+
Clipboard.copy(user_pw)
|
346
|
+
@driver.action.key_down(:control).send_keys('v').key_up(:control).perform
|
347
|
+
sleep(1.5)
|
348
|
+
@driver.find_element(:xpath, '//*[@id="log.login"]').click
|
349
|
+
sleep(2.5)
|
350
|
+
rescue => e
|
351
|
+
puts '-[√] 로딩 지연 접속 실패.......'.red
|
352
|
+
@driver.window_handles.each do |handle|
|
353
|
+
@driver.switch_to.window(handle)
|
354
|
+
begin
|
355
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
356
|
+
@driver.close
|
357
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
358
|
+
puts "Failed to close tab: #{e.message}"
|
359
|
+
end
|
360
|
+
end
|
361
|
+
return 0
|
362
|
+
end
|
346
363
|
|
347
364
|
else
|
348
365
|
# @driver.switch_to.default_content
|
@@ -354,11 +371,18 @@ class Naver
|
|
354
371
|
wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
|
355
372
|
|
356
373
|
rescue => e
|
357
|
-
puts '-[√] 로그인
|
358
|
-
|
359
|
-
|
374
|
+
puts '-[√] 로그인 실패.......'.red
|
375
|
+
@driver.window_handles.each do |handle|
|
376
|
+
@driver.switch_to.window(handle)
|
377
|
+
begin
|
378
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
379
|
+
@driver.close
|
380
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
381
|
+
puts "Failed to close tab: #{e.message}"
|
382
|
+
end
|
383
|
+
end
|
360
384
|
return 0
|
361
|
-
end
|
385
|
+
end
|
362
386
|
end
|
363
387
|
|
364
388
|
def create_id
|
@@ -977,10 +1001,27 @@ end
|
|
977
1001
|
|
978
1002
|
|
979
1003
|
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
1004
|
+
|
1005
|
+
begin
|
1006
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
1007
|
+
#요소가 나타날 때까지 60초 동안 기다립니다.
|
1008
|
+
wait.until { @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[1]/div[2]/div/textarea') }
|
1009
|
+
sleep(1)
|
1010
|
+
@driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[1]/div[1]/div[2]/div/textarea').send_keys(title)
|
1011
|
+
sleep(1)
|
1012
|
+
rescue => e
|
1013
|
+
puts '-[√] 제목 입력 필드 로딩 지연 접속 실패.......'.red
|
1014
|
+
@driver.window_handles.each do |handle|
|
1015
|
+
@driver.switch_to.window(handle)
|
1016
|
+
begin
|
1017
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1018
|
+
@driver.close
|
1019
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1020
|
+
puts "Failed to close tab: #{e.message}"
|
1021
|
+
end
|
1022
|
+
end
|
1023
|
+
return 0
|
1024
|
+
end
|
984
1025
|
|
985
1026
|
|
986
1027
|
|
@@ -988,14 +1029,27 @@ end
|
|
988
1029
|
sleep(1)
|
989
1030
|
@driver.action.send_keys(:page_down).perform
|
990
1031
|
sleep(2)
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
1032
|
+
|
995
1033
|
sleep(2)
|
996
|
-
|
997
|
-
|
998
|
-
|
1034
|
+
begin
|
1035
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
1036
|
+
#요소가 나타날 때까지 60초 동안 기다립니다.
|
1037
|
+
wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-bold"]/button[@data-type="toggle" and @data-name="bold"]') }
|
1038
|
+
@driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
|
1039
|
+
@driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[5]/button').click()
|
1040
|
+
rescue => e
|
1041
|
+
puts '-[√] 글 입력 필드 로딩 지연 접속 실패.......'.red
|
1042
|
+
@driver.window_handles.each do |handle|
|
1043
|
+
@driver.switch_to.window(handle)
|
1044
|
+
begin
|
1045
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1046
|
+
@driver.close
|
1047
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1048
|
+
puts "Failed to close tab: #{e.message}"
|
1049
|
+
end
|
1050
|
+
end
|
1051
|
+
return 0
|
1052
|
+
end
|
999
1053
|
sleep(2)
|
1000
1054
|
@driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
|
1001
1055
|
sleep(1)
|
@@ -1907,7 +1961,15 @@ end
|
|
1907
1961
|
|
1908
1962
|
|
1909
1963
|
begin
|
1910
|
-
@driver.
|
1964
|
+
@driver.window_handles.each do |handle|
|
1965
|
+
@driver.switch_to.window(handle)
|
1966
|
+
begin
|
1967
|
+
# 로딩 중이거나, 페이지가 완전히 로딩되지 않더라도 탭을 닫기
|
1968
|
+
@driver.close
|
1969
|
+
rescue Selenium::WebDriver::Error::WebDriverError => e
|
1970
|
+
puts "Failed to close tab: #{e.message}"
|
1971
|
+
end
|
1972
|
+
end
|
1911
1973
|
rescue
|
1912
1974
|
|
1913
1975
|
end
|