zon_blog_cafe_comment 0.0.6 → 0.0.9

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 +78 -25
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33d180e7fb0938fc8f796f12056fa9bf771f1b3e02f97a38fff02b807575dfaf
4
- data.tar.gz: 5d5a6c6d0870e397f07ee09daf21fa4af49efc2d5b5ad1e369ebaf4a2dba639e
3
+ metadata.gz: 4f33959ddb91ccf09c51f288f02ad0b234041dbe3eeb58bab95f129aa3b6f6a0
4
+ data.tar.gz: d7ee2f004b397b54669076cf07bd0d6f34a5c123265714b490c799859f76e27c
5
5
  SHA512:
6
- metadata.gz: 355d3883aace0696a2305c250d161a0762d4e686b2fc0ecb6d53abfa32b072a5988b86cba34c0958c2dd0926b44faa09454ddd18dff483ba13b5b57cd6657868
7
- data.tar.gz: c69b704a41ff8359df80e509804a5bceb4da5fa42fe77561490bbcfc648a0bf4efc57d299ff0567996c96425be042f51e8cbcc4d7448be65ec4b6f8394b01c9e
6
+ metadata.gz: bd6dfd972a5fbbb08038f3262eac4d9f36db7277376ed54d54edcac764d73ceafabb5c5db7ae1735a556c811c57df89e0cc8517390b600c72d204efd1ed27a6c
7
+ data.tar.gz: 1d94751a7e0d84d01bcf2ccaf229017adeb76c21a022eaab2f538817f2dd3ecefd89c2bc995f56cbcc54ecc5eb5ec56e6fbb819c81e69895fb3306c56b8ead9d
@@ -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
@@ -1970,36 +1993,66 @@ end
1970
1993
  #if table[6].to_i #시작 부분 설정을 맞게해줘야 실행이 됨
1971
1994
 
1972
1995
  if @data['포스트설정']['테더링'].checked?
1973
- puts 'tedering ip change...'
1996
+ puts 'Tethering IP change...'
1997
+
1974
1998
  stdout, stderr, status = Open3.capture3('./adb devices')
1999
+
1975
2000
  if status.success?
1976
- device_id = stdout.split("\n")[1].split("\t")[0]
1977
- puts device_id
1978
- puts 'adb -s '+device_id+' shell svc data disable'
1979
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2001
+ device_id = stdout.split("\n")[1].split("\t")[0]
2002
+ puts device_id
2003
+
2004
+ # ADB 서버 초기화
2005
+ puts 'adb kill-server'
2006
+ Open3.capture3('adb kill-server')
2007
+ sleep(2)
2008
+
2009
+ # 다시 ADB 서버 실행
2010
+ puts 'adb start-server'
2011
+ Open3.capture3('adb start-server')
2012
+ sleep(2)
2013
+
2014
+ # 데이터를 끄고 켜기
2015
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2016
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2017
+
2018
+ if status2.success?
1980
2019
  sleep(3)
1981
- puts 'adb -s '+device_id+' shell svc data enable'
1982
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2020
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2021
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
1983
2022
  sleep(3)
1984
2023
  puts 'adb ok'
1985
2024
  sleep(8)
2025
+
2026
+ # IP 변경을 확인하는 람다 함수
1986
2027
  robot_ip = lambda do
1987
- http = HTTP.get('https://www.findip.kr/')
1988
- noko = Nokogiri::HTML(http.to_s)
1989
- if noko.xpath('/html/body/header/h2').text != @my_ip
1990
- @my_ip = noko.xpath('/html/body/header/h2').text
1991
- else
1992
- puts @my_ip
1993
- puts'[테더링] 연결 재시도.......'.red
1994
- sleep(3)
1995
- robot_ip[]
2028
+ loop do # 무한 루프
2029
+ begin
2030
+ http = HTTP.get('https://www.findip.kr/')
2031
+ noko = Nokogiri::HTML(http.to_s)
2032
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2033
+
2034
+ if new_ip != @my_ip
2035
+ @my_ip = new_ip
2036
+ puts "IP 변경됨: #{@my_ip}"
2037
+ break # IP가 변경되었으면 루프 종료
2038
+ else
2039
+ puts 'IP가 변경되지 않음. 재시도...'
2040
+ sleep(3) # 3초 후 재시도
2041
+ end
2042
+ rescue => e
2043
+ puts "IP 확인 중 오류 발생: #{e.message}. 재시도 중..."
2044
+ sleep(3) # 3초 후 재시도
1996
2045
  end
2046
+ end
1997
2047
  end
1998
- robot_ip[]
2048
+ robot_ip[] # 최초 호출
2049
+ else
2050
+ puts 'Failed to disable data. Error: ' + stderr2
2051
+ end
1999
2052
  else
2000
- puts 'adb error pass'.red
2053
+ puts 'adb error, unable to get devices. Error: ' + stderr
2001
2054
  end
2002
- end
2055
+ end
2003
2056
 
2004
2057
 
2005
2058
 
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.6
4
+ version: 0.0.9
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-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com