cafe_basics 0.0.19 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cafe_basics.rb +134 -158
- 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: f4a90bc3be99e284827c28dd01d082dc0fe1091b917ab400b9ee12e5a846ba7c
|
4
|
+
data.tar.gz: '0609c3a6d915732add3b5bbec14086ad333f5af2f70be90edeb487681156a828'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22027d2758f2ddd332d60b1bc26e89e2636e83079ddc96386a71a894159cd6f00abf227d414984d6a7660a6f80ef17b1b44bf08f6461e597a4fce5076db34b6d
|
7
|
+
data.tar.gz: 442449406bfbaf0a4174511523745445d2a12e7bb88db7f42b659726cc317815a3182add9b205ca09ea655cb6e539438a6f4a650646a4de3b61dc3406bd46038
|
data/lib/cafe_basics.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,95 +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}})
|
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
|
217
221
|
end
|
218
222
|
def chrome_start(proxy, user_id)
|
219
223
|
naver_cookie_dir = "C:/naver_cookie"
|
220
224
|
FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
|
221
|
-
|
222
|
-
chromedriver_path = './chromedriver.exe'
|
223
|
-
|
224
|
-
# 웹드라이버 자동 업데이트 시도
|
225
|
-
begin
|
226
|
-
# webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
|
227
|
-
Webdrivers::Chromedriver.update # 자동 업데이트 시도
|
228
|
-
rescue => e
|
229
|
-
puts "webdrivers에서 chromedriver 다운로드 실패: #{e.message}"
|
230
|
-
puts "자동으로 chromedriver.exe 사용합니다."
|
231
|
-
puts "만일 프로그램 폴더안에 chromedriver.exe 버전이 맞지 않거나 없는 경우 인터넷창이 깜빡하고 닫히거나 열리지 않는경우에만 아래 안내를 따라주세요."
|
232
|
-
puts "https://storage.googleapis.com/chrome-for-testing-public/사용자크롬버전/win32/chromedriver-win32.zip 링크를 복사 후 복사 된 링크 중(사용자크롬버전) 부분을 크롬 사용자의 버전(예:131.0.6778.264)으로 수정 후 주소입력 부분에 넣어 엔터 후 다운로드 하고 압축을 풀고 chromedriver.exe 파일만 프로그램 폴더안에 넣어주세요."
|
233
|
-
puts "인터넷 창이 열리고 작업을 한다면 위 항목은 패스해주세요."
|
234
|
-
# 예외가 발생하면 수동 경로 사용
|
235
|
-
Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
|
236
|
-
end
|
237
|
-
|
238
225
|
if proxy == ''
|
239
|
-
begin
|
240
|
-
# webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
|
241
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
242
|
-
options.page_load_strategy = :normal
|
243
|
-
options.timeouts = { page_load: 20_000 }
|
244
|
-
options.page_load_strategy = 'none'
|
245
|
-
options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
options.add_argument('--remote-debugging-port=9222')
|
250
|
-
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
251
|
-
|
252
|
-
# :capabilities에 options를 배열로 전달
|
253
|
-
capabilities = [options]
|
254
|
-
|
255
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
256
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
257
|
-
rescue
|
258
|
-
# 예외 발생 시 다른 방법으로 셀레니움 실행
|
259
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
260
|
-
end
|
261
|
-
else
|
262
|
-
begin
|
263
|
-
# Proxy를 사용하는 경우
|
264
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
265
|
-
options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
|
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
|
-
|
271
|
-
options.add_argument('--remote-debugging-port=9222')
|
272
|
-
options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
|
273
|
-
|
274
|
-
# :capabilities에 options를 배열로 전달
|
275
|
-
capabilities = [options]
|
276
|
-
|
277
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
278
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
279
|
-
rescue => e
|
280
|
-
puts 'proxy error...'
|
281
226
|
begin
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
capabilities = [options]
|
293
|
-
|
294
|
-
@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)
|
295
237
|
rescue
|
296
|
-
|
297
|
-
|
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
|
298
277
|
end
|
299
|
-
end
|
300
278
|
end
|
301
|
-
|
279
|
+
end
|
302
280
|
|
303
281
|
|
304
282
|
|
@@ -320,7 +298,7 @@ class Naver
|
|
320
298
|
end
|
321
299
|
|
322
300
|
# 새로운 스레드 생성 및 실행
|
323
|
-
Thread.new { chrome_setup(user_id) }
|
301
|
+
Thread.new { chrome_setup(user_id, proxy) }
|
324
302
|
sleep(3)
|
325
303
|
|
326
304
|
|
@@ -1368,94 +1346,106 @@ class Naver
|
|
1368
1346
|
# puts '카테고리 error'
|
1369
1347
|
# puts e33
|
1370
1348
|
# end
|
1371
|
-
sleep(
|
1349
|
+
sleep(2)
|
1372
1350
|
tags2 = option['tag'].to_s
|
1373
1351
|
tag_mm2 = Array.new
|
1374
1352
|
tags2.split(',').each do |tag_value|
|
1375
1353
|
tag_mm2 << ''+tag_value
|
1376
1354
|
end
|
1377
|
-
@driver.find_element(:xpath, '//*[@
|
1355
|
+
@driver.find_element(:xpath, '//*[@placeholder="태그를 입력해주세요 (최대 10개)"]').send_keys(tag_mm2.join("\n")+"\n")
|
1378
1356
|
|
1379
1357
|
sleep(1)
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1358
|
+
|
1359
|
+
if option['전체공개'] == 'true'
|
1360
|
+
puts '전체공개'
|
1361
|
+
begin
|
1362
|
+
@driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
|
1363
|
+
sleep(2)
|
1364
|
+
@driver.find_element(:xpath, '//*[@for="all"]').click
|
1365
|
+
rescue
|
1366
|
+
end
|
1367
|
+
sleep(1)
|
1368
|
+
end
|
1369
|
+
|
1370
|
+
if option['멤버공개'] == 'true'
|
1371
|
+
puts '멤버공개'
|
1372
|
+
begin
|
1373
|
+
@driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
|
1374
|
+
sleep(2)
|
1375
|
+
@driver.find_element(:xpath, '//*[@for="member"]').click
|
1376
|
+
rescue
|
1377
|
+
end
|
1378
|
+
sleep(1)
|
1379
|
+
end
|
1380
|
+
|
1390
1381
|
if option['댓글허용'] == 'true'
|
1391
1382
|
puts '댓글허용'
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1383
|
+
begin
|
1384
|
+
@driver.find_element(:xpath, '//*[@for="coment"]').click
|
1385
|
+
rescue
|
1386
|
+
end
|
1387
|
+
sleep(1)
|
1397
1388
|
end
|
1398
|
-
end
|
1399
1389
|
|
1400
|
-
|
1390
|
+
|
1401
1391
|
if option['블로그,카페 공유허용'] == 'true'
|
1402
1392
|
puts '블로그,카페 공유허용'
|
1403
1393
|
begin
|
1404
|
-
@driver.find_element(:xpath, '
|
1405
|
-
|
1406
|
-
|
1394
|
+
@driver.find_element(:xpath, '//*[@for="blog_sharing"]').click
|
1395
|
+
rescue
|
1396
|
+
end
|
1397
|
+
sleep(1)
|
1407
1398
|
end
|
1408
|
-
end
|
1409
1399
|
|
1410
1400
|
|
1411
|
-
|
1401
|
+
|
1412
1402
|
if option['외부공유허용'] == 'true'
|
1413
1403
|
puts '외부공유허용'
|
1414
1404
|
begin
|
1415
|
-
@driver.find_element(:xpath, '
|
1416
|
-
|
1417
|
-
|
1405
|
+
@driver.find_element(:xpath, '//*[@for="external_sharing"]').click
|
1406
|
+
rescue
|
1407
|
+
end
|
1408
|
+
sleep(1)
|
1418
1409
|
end
|
1419
|
-
end
|
1420
1410
|
|
1421
|
-
|
1411
|
+
|
1422
1412
|
|
1423
1413
|
if option['복사,저장 허용'] == 'true'
|
1424
1414
|
puts '복사,저장 허용'
|
1425
1415
|
begin
|
1426
|
-
@driver.find_element(:xpath, '
|
1427
|
-
|
1428
|
-
|
1416
|
+
@driver.find_element(:xpath, '//*[@for="copy"]').click
|
1417
|
+
rescue
|
1418
|
+
end
|
1419
|
+
sleep(1)
|
1429
1420
|
end
|
1430
|
-
end
|
1431
1421
|
|
1432
|
-
|
1422
|
+
|
1433
1423
|
if option['자동출처 사용'] == 'true'
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
end
|
1424
|
+
puts '자동출처 사용'
|
1425
|
+
begin
|
1426
|
+
@driver.find_element(:xpath, '//*[@for="automatic_source"]').click
|
1427
|
+
rescue
|
1428
|
+
end
|
1429
|
+
sleep(1)
|
1430
|
+
end
|
1441
1431
|
|
1442
|
-
|
1432
|
+
|
1443
1433
|
|
1444
1434
|
if option['CCL 사용'] == 'true'
|
1445
1435
|
puts 'CCL 사용'
|
1446
1436
|
begin
|
1447
|
-
@driver.find_element(:xpath, '
|
1448
|
-
|
1449
|
-
|
1437
|
+
@driver.find_element(:xpath, '//*[@for="ccl"]').click
|
1438
|
+
rescue
|
1439
|
+
end
|
1440
|
+
sleep(1)
|
1450
1441
|
end
|
1451
|
-
|
1452
|
-
sleep(1)
|
1442
|
+
|
1453
1443
|
# puts data['documentModel'] = data['documentModel'].to_json
|
1454
1444
|
|
1455
1445
|
sleep(dd_time.to_i)
|
1456
|
-
@driver.find_element(:xpath, '
|
1446
|
+
@driver.find_element(:xpath, '//*[@class="BaseButton BaseButton--skinGreen size_default"]').click
|
1457
1447
|
|
1458
|
-
sleep(
|
1448
|
+
sleep(7)
|
1459
1449
|
|
1460
1450
|
|
1461
1451
|
begin
|
@@ -1601,18 +1591,10 @@ class Wordpress
|
|
1601
1591
|
|
1602
1592
|
def get_naver_text(q)
|
1603
1593
|
begin
|
1604
|
-
|
1605
|
-
|
1606
|
-
capabilities = [options]
|
1607
|
-
|
1608
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1609
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1594
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1595
|
+
@driver = Selenium::WebDriver.for :chrome
|
1610
1596
|
rescue
|
1611
|
-
|
1612
|
-
capabilities = [options]
|
1613
|
-
|
1614
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1615
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1597
|
+
@driver = Selenium::WebDriver.for :chrome
|
1616
1598
|
end
|
1617
1599
|
@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')
|
1618
1600
|
noko = Nokogiri::HTML(@driver.page_source)
|
@@ -1642,18 +1624,10 @@ class Wordpress
|
|
1642
1624
|
|
1643
1625
|
def get_naver_text2(keyword)
|
1644
1626
|
begin
|
1645
|
-
|
1646
|
-
|
1647
|
-
capabilities = [options]
|
1648
|
-
|
1649
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1650
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1627
|
+
Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
|
1628
|
+
@driver = Selenium::WebDriver.for :chrome
|
1651
1629
|
rescue
|
1652
|
-
|
1653
|
-
capabilities = [options]
|
1654
|
-
|
1655
|
-
# Selenium WebDriver에서 options를 capabilities로 전달
|
1656
|
-
@driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
|
1630
|
+
@driver = Selenium::WebDriver.for :chrome
|
1657
1631
|
end
|
1658
1632
|
@driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
|
1659
1633
|
for n3 in 1..10
|
@@ -2101,7 +2075,7 @@ class Wordpress
|
|
2101
2075
|
@data['table'] << []
|
2102
2076
|
@data['table'].pop
|
2103
2077
|
#포스팅 get 데이터 가저오기#############################
|
2104
|
-
proxy = table[
|
2078
|
+
proxy = table[6].to_s
|
2105
2079
|
user_id = table[1].to_s
|
2106
2080
|
user_pw = table[2].to_s
|
2107
2081
|
naver = Naver.new
|
@@ -2844,13 +2818,15 @@ class Wordpress
|
|
2844
2818
|
|
2845
2819
|
|
2846
2820
|
if @data['포스트설정']['전체공개'].checked?
|
2847
|
-
option['
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2821
|
+
option['전체공개'] = 'true'
|
2822
|
+
else
|
2823
|
+
option['전체공개'] = 'false'
|
2824
|
+
end
|
2825
|
+
|
2826
|
+
if @data['포스트설정']['멤버공개'].checked?
|
2827
|
+
option['멤버공개'] = 'true'
|
2852
2828
|
else
|
2853
|
-
option['
|
2829
|
+
option['멤버공개'] = 'false'
|
2854
2830
|
end
|
2855
2831
|
|
2856
2832
|
if @data['포스트설정']['댓글허용'].checked?
|
@@ -4795,7 +4771,7 @@ class Wordpress
|
|
4795
4771
|
end
|
4796
4772
|
}
|
4797
4773
|
}
|
4798
|
-
@data['포스트설정']['멤버공개'] = checkbox('
|
4774
|
+
@data['포스트설정']['멤버공개'] = checkbox('멤버공개'){
|
4799
4775
|
top 10
|
4800
4776
|
left 1
|
4801
4777
|
on_toggled{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics
|
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
|