cafe_basics_duo 0.0.19 → 0.0.20
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_basics_duo.rb +80 -118
- 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: '09c6ba48d9cdd6060be74a6f8c4a3035a327e71fa613fa0baf9ed2fefb415652'
|
4
|
+
data.tar.gz: c8331a5baa52b241de005422ee14e2783f6d625942a5e8ad624f2a9b1b8133b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a09ec016dd0ca898c4538b532e78349d3708930f86849a35373f3e53bec40dc5dd9257e06fd6b762f143f6d6aa84cfe029df30585e03ae6e08fd3f5e9a4ffb9
|
7
|
+
data.tar.gz: 4c0d1e18e6e71d0a8ab1cfab5ff51d4b329a1fb6865abca6aeec9bb675098e436c323aa01a5727e78fc66330813434aa3942b3b9a38d72a8a10c3fbc0b64e93b
|
data/lib/cafe_basics_duo.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'
|
@@ -219,87 +219,61 @@ class Naver
|
|
219
219
|
def chrome_start(proxy, user_id)
|
220
220
|
naver_cookie_dir = "C:/naver_cookie"
|
221
221
|
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
222
|
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
223
|
begin
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
capabilities = [options]
|
294
|
-
|
295
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
224
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
225
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
226
|
+
options.page_load_strategy = :normal
|
227
|
+
options.timeouts = {page_load: 20_000}
|
228
|
+
options.page_load_strategy = 'none'
|
229
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
230
|
+
options.add_argument('--disable-gpu')
|
231
|
+
options.add_argument('--remote-debugging-port=9222')
|
232
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
233
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
296
234
|
rescue
|
297
|
-
|
298
|
-
|
235
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
236
|
+
end
|
237
|
+
else
|
238
|
+
begin
|
239
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
240
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
241
|
+
# profile = Selenium::WebDriver::Chrome::Profile.new
|
242
|
+
# profile['network.proxy.type'] = 1
|
243
|
+
# profile['network.proxy.http'] = proxy.split(':')[0]
|
244
|
+
# profile['network.proxy.http_port'] = proxy.split(':')[1].to_i
|
245
|
+
# options = Selenium::WebDriver::Chrome::Options.new
|
246
|
+
# options.profile = profile
|
247
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
248
|
+
options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
|
249
|
+
options.page_load_strategy = :normal
|
250
|
+
options.timeouts = {page_load: 20_000}
|
251
|
+
options.page_load_strategy = 'none'
|
252
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
253
|
+
options.add_argument('--disable-gpu')
|
254
|
+
options.add_argument('--remote-debugging-port=9222')
|
255
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
256
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
257
|
+
rescue => e
|
258
|
+
puts e
|
259
|
+
puts 'proxy error...'
|
260
|
+
begin
|
261
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
262
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
263
|
+
options.page_load_strategy = :normal
|
264
|
+
options.timeouts = {page_load: 20_000}
|
265
|
+
options.page_load_strategy = 'none'
|
266
|
+
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
267
|
+
options.add_argument('--disable-gpu')
|
268
|
+
options.add_argument('--remote-debugging-port=9222')
|
269
|
+
options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
|
270
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
271
|
+
rescue
|
272
|
+
@driver = Selenium::WebDriver.for(:chrome, capabilities: options)
|
273
|
+
end
|
299
274
|
end
|
300
|
-
end
|
301
275
|
end
|
302
|
-
|
276
|
+
end
|
303
277
|
|
304
278
|
|
305
279
|
|
@@ -1390,15 +1364,16 @@ class Naver
|
|
1390
1364
|
# end
|
1391
1365
|
if option['댓글허용'] == 'true'
|
1392
1366
|
puts '댓글허용'
|
1367
|
+
|
1393
1368
|
begin
|
1394
1369
|
@driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[1]/div/label').click
|
1395
|
-
|
1370
|
+
sleep(1)
|
1396
1371
|
rescue
|
1397
1372
|
|
1398
1373
|
end
|
1399
1374
|
end
|
1400
1375
|
|
1401
|
-
|
1376
|
+
|
1402
1377
|
if option['블로그,카페 공유허용'] == 'true'
|
1403
1378
|
puts '블로그,카페 공유허용'
|
1404
1379
|
begin
|
@@ -1409,54 +1384,57 @@ class Naver
|
|
1409
1384
|
end
|
1410
1385
|
|
1411
1386
|
|
1412
|
-
|
1387
|
+
|
1413
1388
|
if option['외부공유허용'] == 'true'
|
1414
1389
|
puts '외부공유허용'
|
1415
1390
|
begin
|
1416
1391
|
@driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[3]/div[1]/label').click
|
1392
|
+
sleep(1)
|
1417
1393
|
rescue
|
1418
1394
|
|
1419
1395
|
end
|
1420
1396
|
end
|
1421
1397
|
|
1422
|
-
|
1398
|
+
|
1423
1399
|
|
1424
1400
|
if option['복사,저장 허용'] == 'true'
|
1425
1401
|
puts '복사,저장 허용'
|
1426
1402
|
begin
|
1427
1403
|
@driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[4]/div[1]/label').click
|
1428
|
-
|
1404
|
+
sleep(1)
|
1405
|
+
rescue
|
1429
1406
|
|
1407
|
+
end
|
1430
1408
|
end
|
1431
|
-
end
|
1432
1409
|
|
1433
|
-
|
1410
|
+
|
1434
1411
|
if option['자동출처 사용'] == 'true'
|
1435
1412
|
puts '자동출처 사용'
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1413
|
+
begin
|
1414
|
+
@driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[5]/div[1]/label').click
|
1415
|
+
sleep(1)
|
1416
|
+
rescue
|
1439
1417
|
|
1440
|
-
|
1441
|
-
end
|
1442
|
-
|
1443
|
-
sleep(1)
|
1418
|
+
end
|
1419
|
+
end
|
1420
|
+
|
1444
1421
|
|
1445
1422
|
if option['CCL 사용'] == 'true'
|
1446
1423
|
puts 'CCL 사용'
|
1447
1424
|
begin
|
1448
1425
|
@driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[6]/div[1]/label').click
|
1449
|
-
|
1450
|
-
|
1426
|
+
sleep(1)
|
1427
|
+
rescue
|
1428
|
+
|
1429
|
+
end
|
1451
1430
|
end
|
1452
|
-
|
1453
|
-
sleep(1)
|
1431
|
+
|
1454
1432
|
# puts data['documentModel'] = data['documentModel'].to_json
|
1455
1433
|
|
1456
1434
|
sleep(dd_time.to_i)
|
1457
1435
|
@driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[1]/div/a').click
|
1458
1436
|
|
1459
|
-
sleep(
|
1437
|
+
sleep(7)
|
1460
1438
|
|
1461
1439
|
|
1462
1440
|
begin
|
@@ -1671,18 +1649,10 @@ class Wordpress
|
|
1671
1649
|
|
1672
1650
|
def get_naver_text(q)
|
1673
1651
|
begin
|
1674
|
-
|
1675
|
-
|
1676
|
-
capabilities = [options]
|
1677
|
-
|
1678
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1679
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1652
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1653
|
+
@driver = Selenium::WebDriver.for :chrome
|
1680
1654
|
rescue
|
1681
|
-
|
1682
|
-
capabilities = [options]
|
1683
|
-
|
1684
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1685
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1655
|
+
@driver = Selenium::WebDriver.for :chrome
|
1686
1656
|
end
|
1687
1657
|
@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')
|
1688
1658
|
noko = Nokogiri::HTML(@driver.page_source)
|
@@ -1712,18 +1682,10 @@ class Wordpress
|
|
1712
1682
|
|
1713
1683
|
def get_naver_text2(keyword)
|
1714
1684
|
begin
|
1715
|
-
|
1716
|
-
|
1717
|
-
capabilities = [options]
|
1718
|
-
|
1719
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1720
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1685
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1686
|
+
@driver = Selenium::WebDriver.for :chrome
|
1721
1687
|
rescue
|
1722
|
-
|
1723
|
-
capabilities = [options]
|
1724
|
-
|
1725
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1726
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1688
|
+
@driver = Selenium::WebDriver.for :chrome
|
1727
1689
|
end
|
1728
1690
|
@driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
|
1729
1691
|
for n3 in 1..10
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: File to Clipboard gem
|
14
14
|
email: mymin26@naver.com
|