zon_blog_cafe_comment 0.0.7 → 0.0.10

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_blog_cafe_comment.rb +57 -47
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cff901d96259d116a4334a7cd70a6f9f0f538c95e3e86f6ab66c3dc87366edf0
4
- data.tar.gz: d472a2b5d4711f21b2e56de48867f07401834f00b4e644fe1df15191243706d8
3
+ metadata.gz: 0a52491dc8580d04b09fb41456d16b97d99a40c58882698797f309fb292ffefd
4
+ data.tar.gz: f16feeaccc1bb5a14cd8b4fdae403e2afe1c2decae7be6438fcb1633b5d982ee
5
5
  SHA512:
6
- metadata.gz: 1d7c633265e447e30e13bc6a3775386b19ddb465c592644f073ffc82e03d1dba2550782a21dded00ef40c1652d36c321d8c404735416d985143643f2f3d5285b
7
- data.tar.gz: abf6b142ffcd4bae78c59a2a6bccfa51d58e1e2e44ef5ff5c3da6e3da08b7c98a5954cdb5cf13d8e3fdc6b55b526e875b65997c8dd824528c280880baf06e4a7
6
+ metadata.gz: 39bbbfaca062b11d9b99b9771a7fcae18b7ccbbdc9b7597955f6c5eb47501e591a0152b3a70e315cc957b3325bd70b4e9c5345f2d9d240f73e1d57991c28b36b
7
+ data.tar.gz: 2a4221f4fe6330e08982e2358738d48414e02a0445f2482760fdc2ee38adecdbe6f8a07467cce0acdbe7c68201b432f431736a9ece7b7b28ae0d1011d46cdc9a
@@ -50,9 +50,17 @@ class Naver
50
50
  options.add_argument('--disable-gpu')
51
51
  options.add_argument('--remote-debugging-port=9222')
52
52
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
53
- @driver = Selenium::WebDriver.for(:chrome, options: options)
54
- rescue
55
- @driver = Selenium::WebDriver.for(:chrome, options: options)
53
+ # 'capabilities'과 'options' 배열로 설정
54
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
55
+ capabilities["goog:chromeOptions"] = options.as_json
56
+
57
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
58
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
59
+
60
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
61
+
62
+ rescue => e
63
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
56
64
  end
57
65
  else
58
66
  begin
@@ -68,7 +76,14 @@ class Naver
68
76
  options.add_argument('--disable-gpu')
69
77
  options.add_argument('--remote-debugging-port=9222')
70
78
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
71
- @driver = Selenium::WebDriver.for(:chrome, options: options)
79
+ # 'capabilities'과 'options' 배열로 설정
80
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
81
+ capabilities["goog:chromeOptions"] = options.as_json
82
+
83
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
84
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
85
+
86
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
72
87
  rescue => e
73
88
  puts e
74
89
  puts 'proxy error...'
@@ -84,9 +99,16 @@ class Naver
84
99
  options.add_argument('--disable-gpu')
85
100
  options.add_argument('--remote-debugging-port=9222')
86
101
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
87
- @driver = Selenium::WebDriver.for(:chrome, options: options)
102
+ # 'capabilities'과 'options' 배열로 설정
103
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
104
+ capabilities["goog:chromeOptions"] = options.as_json
105
+
106
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
107
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
108
+
109
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
88
110
  rescue
89
- @driver = Selenium::WebDriver.for(:chrome, options: options)
111
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
90
112
  end
91
113
  end
92
114
  end
@@ -94,6 +116,7 @@ class Naver
94
116
 
95
117
 
96
118
 
119
+
97
120
  def login(user_id, user_pw, proxy)
98
121
  @user_id = user_id
99
122
  @user_id11 = user_id
@@ -1980,56 +2003,43 @@ end
1980
2003
 
1981
2004
  # ADB 서버 초기화
1982
2005
  puts 'adb kill-server'
1983
- Open3.capture3('adb kill-server')
1984
- sleep(2)
2006
+ Open3.capture3('./adb kill-server')
2007
+ sleep(3)
1985
2008
 
1986
2009
  # 다시 ADB 서버 실행
1987
2010
  puts 'adb start-server'
1988
- Open3.capture3('adb start-server')
1989
- sleep(2)
2011
+ Open3.capture3('./adb start-server')
2012
+ sleep(3)
1990
2013
 
1991
2014
  # 데이터를 끄고 켜기
1992
2015
  puts 'adb -s ' + device_id + ' shell svc data disable'
1993
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
1994
-
1995
- if status2.success?
1996
- sleep(3)
1997
- puts 'adb -s ' + device_id + ' shell svc data enable'
1998
- Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
1999
- sleep(3)
2000
- puts 'adb ok'
2001
- sleep(8)
2002
-
2003
- # IP 변경을 확인하는 람다 함수
2004
- robot_ip = lambda do
2005
- loop do # 무한 루프
2006
- begin
2007
- http = HTTP.get('https://www.findip.kr/')
2008
- noko = Nokogiri::HTML(http.to_s)
2009
- new_ip = noko.xpath('/html/body/header/h2').text.strip
2010
-
2011
- if new_ip != @my_ip
2012
- @my_ip = new_ip
2013
- puts "IP 변경됨: #{@my_ip}"
2014
- break # IP가 변경되었으면 루프 종료
2015
- else
2016
- puts 'IP가 변경되지 않음. 재시도...'
2017
- sleep(3) # 3초 후 재시도
2018
- end
2019
- rescue => e
2020
- puts "IP 확인 중 오류 발생: #{e.message}. 재시도 중..."
2021
- sleep(3) # 3초 후 재시도
2022
- end
2023
- end
2016
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2017
+ sleep(3)
2018
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2019
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2020
+ sleep(3)
2021
+ puts 'adb ok'
2022
+ sleep(8)
2023
+
2024
+ robot_ip = lambda do
2025
+ http = HTTP.get('https://www.findip.kr/')
2026
+ noko = Nokogiri::HTML(http.to_s)
2027
+ if noko.xpath('/html/body/header/h2').text != @my_ip
2028
+ @my_ip = noko.xpath('/html/body/header/h2').text
2029
+ puts "IP 변경됨[ #{@my_ip} ]"
2030
+ else
2031
+ puts @my_ip
2032
+ puts '제시도...'
2033
+ sleep(3)
2034
+ robot_ip[]
2024
2035
  end
2025
- robot_ip[] # 최초 호출
2026
- else
2027
- puts 'Failed to disable data. Error: ' + stderr2
2028
- end
2036
+ end
2037
+ robot_ip[]
2038
+
2029
2039
  else
2030
- puts 'adb error, unable to get devices. Error: ' + stderr
2040
+ puts 'adb error pass'
2031
2041
  end
2032
- end
2042
+ end
2033
2043
 
2034
2044
 
2035
2045
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zon_blog_cafe_comment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-07 00:00:00.000000000 Z
11
+ date: 2025-02-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com