cafe_buy 0.0.19 → 0.0.27
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 +138 -162
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d648b0b0a044468c457cbca1c7b01d131f04530e799c9389b2f983409ac75d9
|
4
|
+
data.tar.gz: fc48d3775eddd64d5fef5d535883a7cdcc7e95c11151571ae964cfc5e092d583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5042467993ba9b1ef30e7edcd5c5643f1a17d2e6eddfd0fd17e348031b26174db816d02e21d63980c346b4d9c7602e2aad586bd5f7ac09dce37ce5a970fa990f
|
7
|
+
data.tar.gz: 5ef0b66989d52ed9e91ebe2043c26f2735dfab648f9cb8ac933dfc8a4a9db5e560b998b537f73b340546765e649de733c4e0f73ae3a7c85b3f6c3c5d0e7df6f0
|
data/lib/cafe_buy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
require 'selenium-webdriver'
|
3
|
-
require 'webdrivers'
|
3
|
+
# require 'webdrivers'
|
4
4
|
require 'iconv'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'http'
|
@@ -210,96 +210,73 @@ class Naver
|
|
210
210
|
def initialize
|
211
211
|
@seed = 1
|
212
212
|
end
|
213
|
-
def chrome_setup(user_id)
|
213
|
+
def chrome_setup(user_id, proxy)
|
214
214
|
naver_cookie_dir = "C:/naver_cookie"
|
215
215
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
216
|
+
if proxy == ''
|
216
217
|
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
|
217
|
-
|
218
|
+
else
|
219
|
+
system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" "https://naver.com/" --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s}})
|
220
|
+
end
|
218
221
|
end
|
219
222
|
def chrome_start(proxy, user_id)
|
220
223
|
naver_cookie_dir = "C:/naver_cookie"
|
221
224
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
222
|
-
|
223
|
-
chromedriver_path = './chromedriver.exe'
|
224
|
-
|
225
|
-
# 웹드라이버 자동 업데이트 시도
|
226
|
-
begin
|
227
|
-
# webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
|
228
|
-
Webdrivers::Chromedriver.update # 자동 업데이트 시도
|
229
|
-
rescue => e
|
230
|
-
puts "webdrivers에서 chromedriver 다운로드 실패: #{e.message}"
|
231
|
-
puts "자동으로 chromedriver.exe 사용합니다."
|
232
|
-
puts "만일 프로그램 폴더안에 chromedriver.exe 버전이 맞지 않거나 없는 경우 인터넷창이 깜빡하고 닫히거나 열리지 않는경우에만 아래 안내를 따라주세요."
|
233
|
-
puts "https://storage.googleapis.com/chrome-for-testing-public/사용자크롬버전/win32/chromedriver-win32.zip 링크를 복사 후 복사 된 링크 중(사용자크롬버전) 부분을 크롬 사용자의 버전(예:131.0.6778.264)으로 수정 후 주소입력 부분에 넣어 엔터 후 다운로드 하고 압축을 풀고 chromedriver.exe 파일만 프로그램 폴더안에 넣어주세요."
|
234
|
-
puts "인터넷 창이 열리고 작업을 한다면 위 항목은 패스해주세요."
|
235
|
-
# 예외가 발생하면 수동 경로 사용
|
236
|
-
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
237
|
-
end
|
238
|
-
|
239
225
|
if proxy == ''
|
240
|
-
begin
|
241
|
-
# webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
|
242
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
243
|
-
options.page_load_strategy = :normal
|
244
|
-
options.timeouts = { page_load: 20_000 }
|
245
|
-
options.page_load_strategy = 'none'
|
246
|
-
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
options.add_argument('--remote-debugging-port=9222')
|
251
|
-
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
252
|
-
|
253
|
-
# :capabilities에 options를 배열로 전달
|
254
|
-
capabilities = [options]
|
255
|
-
|
256
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
257
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
258
|
-
rescue
|
259
|
-
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
260
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
261
|
-
end
|
262
|
-
else
|
263
|
-
begin
|
264
|
-
# Proxy를 사용하는 경우
|
265
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
266
|
-
options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
|
267
|
-
options.page_load_strategy = :normal
|
268
|
-
options.timeouts = { page_load: 20_000 }
|
269
|
-
options.page_load_strategy = 'none'
|
270
|
-
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
271
|
-
|
272
|
-
options.add_argument('--remote-debugging-port=9222')
|
273
|
-
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
274
|
-
|
275
|
-
# :capabilities에 options를 배열로 전달
|
276
|
-
capabilities = [options]
|
277
|
-
|
278
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
279
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
280
|
-
rescue => e
|
281
|
-
puts 'proxy error...'
|
282
226
|
begin
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
capabilities = [options]
|
294
|
-
|
295
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
227
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
228
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
229
|
+
options.page_load_strategy = :normal
|
230
|
+
options.timeouts = {page_load: 20_000}
|
231
|
+
options.page_load_strategy = 'none'
|
232
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
233
|
+
options.add_argument('--disable-gpu')
|
234
|
+
options.add_argument('--remote-debugging-port=9222')
|
235
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
236
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
296
237
|
rescue
|
297
|
-
|
298
|
-
|
238
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
239
|
+
end
|
240
|
+
else
|
241
|
+
begin
|
242
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
243
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
244
|
+
# profile = Selenium::WebDriver::Chrome::Profile.new
|
245
|
+
# profile['network.proxy.type'] = 1
|
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
|
251
|
+
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
252
|
+
options.page_load_strategy = :normal
|
253
|
+
options.timeouts = {page_load: 20_000}
|
254
|
+
options.page_load_strategy = 'none'
|
255
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
256
|
+
options.add_argument('--disable-gpu')
|
257
|
+
options.add_argument('--remote-debugging-port=9222')
|
258
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
259
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
260
|
+
rescue => e
|
261
|
+
puts e
|
262
|
+
puts 'proxy error...'
|
263
|
+
begin
|
264
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
265
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
266
|
+
options.page_load_strategy = :normal
|
267
|
+
options.timeouts = {page_load: 20_000}
|
268
|
+
options.page_load_strategy = 'none'
|
269
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
270
|
+
options.add_argument('--disable-gpu')
|
271
|
+
options.add_argument('--remote-debugging-port=9222')
|
272
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
273
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
274
|
+
rescue
|
275
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
276
|
+
end
|
299
277
|
end
|
300
|
-
end
|
301
278
|
end
|
302
|
-
|
279
|
+
end
|
303
280
|
|
304
281
|
|
305
282
|
|
@@ -321,7 +298,7 @@ class Naver
|
|
321
298
|
end
|
322
299
|
|
323
300
|
# 새로운 스레드 생성 및 실행
|
324
|
-
Thread.new { chrome_setup(user_id) }
|
301
|
+
Thread.new { chrome_setup(user_id, proxy) }
|
325
302
|
sleep(3)
|
326
303
|
|
327
304
|
|
@@ -1590,11 +1567,11 @@ end
|
|
1590
1567
|
end
|
1591
1568
|
end
|
1592
1569
|
end
|
1593
|
-
sleep(
|
1570
|
+
sleep(0.5)
|
1594
1571
|
@driver.action.key_down(:end).key_up(:end).perform
|
1595
|
-
sleep(
|
1572
|
+
sleep(0.5)
|
1596
1573
|
@driver.action.key_down(:enter).key_up(:enter).perform
|
1597
|
-
sleep(
|
1574
|
+
sleep(0.5)
|
1598
1575
|
# if check_image == 0
|
1599
1576
|
# if value_data['nodes'].length == 0
|
1600
1577
|
# value_data['nodes'][0] = {
|
@@ -1692,88 +1669,100 @@ end
|
|
1692
1669
|
tags2.split(',').each do |tag_value|
|
1693
1670
|
tag_mm2 << ''+tag_value
|
1694
1671
|
end
|
1695
|
-
@driver.find_element(:xpath, '//*[@
|
1672
|
+
@driver.find_element(:xpath, '//*[@placeholder="태그를 입력해주세요 (최대 10개)"]').send_keys(tag_mm2.join("\n")+"\n")
|
1696
1673
|
|
1697
1674
|
sleep(1)
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1675
|
+
|
1676
|
+
if option['전체공개'] == 'true'
|
1677
|
+
puts '전체공개'
|
1678
|
+
begin
|
1679
|
+
@driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
|
1680
|
+
sleep(2)
|
1681
|
+
@driver.find_element(:xpath, '//*[@for="all"]').click
|
1682
|
+
rescue
|
1683
|
+
end
|
1684
|
+
sleep(1)
|
1685
|
+
end
|
1686
|
+
|
1687
|
+
if option['멤버공개'] == 'true'
|
1688
|
+
puts '멤버공개'
|
1689
|
+
begin
|
1690
|
+
@driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
|
1691
|
+
sleep(2)
|
1692
|
+
@driver.find_element(:xpath, '//*[@for="member"]').click
|
1693
|
+
rescue
|
1694
|
+
end
|
1695
|
+
sleep(1)
|
1696
|
+
end
|
1697
|
+
|
1708
1698
|
if option['댓글허용'] == 'true'
|
1709
1699
|
puts '댓글허용'
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1700
|
+
begin
|
1701
|
+
@driver.find_element(:xpath, '//*[@for="coment"]').click
|
1702
|
+
rescue
|
1703
|
+
end
|
1704
|
+
sleep(1)
|
1715
1705
|
end
|
1716
|
-
end
|
1717
1706
|
|
1718
|
-
|
1707
|
+
|
1719
1708
|
if option['블로그,카페 공유허용'] == 'true'
|
1720
1709
|
puts '블로그,카페 공유허용'
|
1721
1710
|
begin
|
1722
|
-
@driver.find_element(:xpath, '
|
1723
|
-
|
1724
|
-
|
1711
|
+
@driver.find_element(:xpath, '//*[@for="blog_sharing"]').click
|
1712
|
+
rescue
|
1713
|
+
end
|
1714
|
+
sleep(1)
|
1725
1715
|
end
|
1726
|
-
end
|
1727
1716
|
|
1728
1717
|
|
1729
|
-
|
1718
|
+
|
1730
1719
|
if option['외부공유허용'] == 'true'
|
1731
1720
|
puts '외부공유허용'
|
1732
1721
|
begin
|
1733
|
-
@driver.find_element(:xpath, '
|
1734
|
-
|
1735
|
-
|
1722
|
+
@driver.find_element(:xpath, '//*[@for="external_sharing"]').click
|
1723
|
+
rescue
|
1724
|
+
end
|
1725
|
+
sleep(1)
|
1736
1726
|
end
|
1737
|
-
end
|
1738
1727
|
|
1739
|
-
|
1728
|
+
|
1740
1729
|
|
1741
1730
|
if option['복사,저장 허용'] == 'true'
|
1742
1731
|
puts '복사,저장 허용'
|
1743
1732
|
begin
|
1744
|
-
@driver.find_element(:xpath, '
|
1745
|
-
|
1746
|
-
|
1733
|
+
@driver.find_element(:xpath, '//*[@for="copy"]').click
|
1734
|
+
rescue
|
1735
|
+
end
|
1736
|
+
sleep(1)
|
1747
1737
|
end
|
1748
|
-
end
|
1749
1738
|
|
1750
|
-
|
1739
|
+
|
1751
1740
|
if option['자동출처 사용'] == 'true'
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
end
|
1741
|
+
puts '자동출처 사용'
|
1742
|
+
begin
|
1743
|
+
@driver.find_element(:xpath, '//*[@for="automatic_source"]').click
|
1744
|
+
rescue
|
1745
|
+
end
|
1746
|
+
sleep(1)
|
1747
|
+
end
|
1759
1748
|
|
1760
|
-
|
1749
|
+
|
1761
1750
|
|
1762
1751
|
if option['CCL 사용'] == 'true'
|
1763
1752
|
puts 'CCL 사용'
|
1764
1753
|
begin
|
1765
|
-
@driver.find_element(:xpath, '
|
1766
|
-
|
1767
|
-
|
1754
|
+
@driver.find_element(:xpath, '//*[@for="ccl"]').click
|
1755
|
+
rescue
|
1756
|
+
end
|
1757
|
+
sleep(1)
|
1768
1758
|
end
|
1769
|
-
|
1770
|
-
sleep(1)
|
1759
|
+
|
1771
1760
|
# puts data['documentModel'] = data['documentModel'].to_json
|
1772
|
-
|
1761
|
+
|
1773
1762
|
sleep(dd_time.to_i)
|
1774
|
-
@driver.find_element(:xpath, '
|
1763
|
+
@driver.find_element(:xpath, '//*[@class="BaseButton BaseButton--skinGreen size_default"]').click
|
1775
1764
|
|
1776
|
-
sleep(
|
1765
|
+
sleep(7)
|
1777
1766
|
|
1778
1767
|
|
1779
1768
|
begin
|
@@ -1916,18 +1905,10 @@ class Wordpress
|
|
1916
1905
|
|
1917
1906
|
def get_naver_text(q)
|
1918
1907
|
begin
|
1919
|
-
|
1920
|
-
|
1921
|
-
capabilities = [options]
|
1922
|
-
|
1923
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1924
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1908
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1909
|
+
@driver = Selenium::WebDriver.for :chrome
|
1925
1910
|
rescue
|
1926
|
-
|
1927
|
-
capabilities = [options]
|
1928
|
-
|
1929
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1930
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1911
|
+
@driver = Selenium::WebDriver.for :chrome
|
1931
1912
|
end
|
1932
1913
|
@driver.get('https://search.naver.com/search.naver?display=15&f=&filetype=0&page=3&query='+q.to_s+'&research_url=&sm=tab_pge&start=16&where=web')
|
1933
1914
|
noko = Nokogiri::HTML(@driver.page_source)
|
@@ -1957,18 +1938,10 @@ class Wordpress
|
|
1957
1938
|
|
1958
1939
|
def get_naver_text2(keyword)
|
1959
1940
|
begin
|
1960
|
-
|
1961
|
-
|
1962
|
-
capabilities = [options]
|
1963
|
-
|
1964
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1965
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1941
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1942
|
+
@driver = Selenium::WebDriver.for :chrome
|
1966
1943
|
rescue
|
1967
|
-
|
1968
|
-
capabilities = [options]
|
1969
|
-
|
1970
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1971
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1944
|
+
@driver = Selenium::WebDriver.for :chrome
|
1972
1945
|
end
|
1973
1946
|
@driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
|
1974
1947
|
for n3 in 1..10
|
@@ -2438,7 +2411,7 @@ class Wordpress
|
|
2438
2411
|
@data['table'] << []
|
2439
2412
|
@data['table'].pop
|
2440
2413
|
#포스팅 get 데이터 가저오기#############################
|
2441
|
-
proxy = table[
|
2414
|
+
proxy = table[6].to_s
|
2442
2415
|
user_id = table[1].to_s
|
2443
2416
|
user_pw = table[2].to_s
|
2444
2417
|
naver = Naver.new
|
@@ -3180,14 +3153,17 @@ class Wordpress
|
|
3180
3153
|
option['배달'] = [@data['포스트설정']['직거래'].checked?, @data['포스트설정']['택배 거래'].checked?, @data['포스트설정']['온라인전송'].checked?]
|
3181
3154
|
option['직 거래 카테고리'] = product_category1
|
3182
3155
|
option['결제'] = payment
|
3156
|
+
|
3183
3157
|
if @data['포스트설정']['전체공개'].checked?
|
3184
|
-
option['
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3158
|
+
option['전체공개'] = 'true'
|
3159
|
+
else
|
3160
|
+
option['전체공개'] = 'false'
|
3161
|
+
end
|
3162
|
+
|
3163
|
+
if @data['포스트설정']['멤버공개'].checked?
|
3164
|
+
option['멤버공개'] = 'true'
|
3189
3165
|
else
|
3190
|
-
option['
|
3166
|
+
option['멤버공개'] = 'false'
|
3191
3167
|
end
|
3192
3168
|
|
3193
3169
|
if @data['포스트설정']['댓글허용'].checked?
|
@@ -5130,7 +5106,7 @@ class Wordpress
|
|
5130
5106
|
end
|
5131
5107
|
}
|
5132
5108
|
}
|
5133
|
-
@data['포스트설정']['멤버공개'] = checkbox('
|
5109
|
+
@data['포스트설정']['멤버공개'] = checkbox('멤버공개'){
|
5134
5110
|
top 10
|
5135
5111
|
left 1
|
5136
5112
|
on_toggled{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_buy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|