cafe_basics 0.0.19 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_basics.rb +128 -155
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1046c0901fee040f217e0c09add41ef3e4b5ceeaa2bcecface8ba894d4895f8c
4
- data.tar.gz: 34459cc3069e69030ab88e60879f995eb4d2e9e47474fe54c3df98538a3dedf0
3
+ metadata.gz: 3e593ed945c3909a09a182a3d903931df52580bb2723461c0b84be8f5d6792b2
4
+ data.tar.gz: fed4cb7513275a585dab7eee53edc67dfd4395bcf1dc5a2c11b56b40dcad4c96
5
5
  SHA512:
6
- metadata.gz: 830f4be3e0be3352cea3fd94f83ae41c3bd440d0881a276da4b620483096cef4486d0ecd6362078c50626cc3e821a01f693f5c3424b666089eda3fbc8c1a7941
7
- data.tar.gz: cf62c9b12bb54c5808b3dc074a6a5c90cf2b7bbf7b939ebf8ecd712b312cb58b057ee0682d359a0d07a9cc21ee1c328d6863c21e68b222283e9602e1a5bd49ac
6
+ metadata.gz: fbcd9bcf9214acaaa20c2de674297ebce51886b8b72351fa6da5548042c77efcb48c4532c333360e5263983a17c96166ecb4295ea3a63470f257720ce92ded17
7
+ data.tar.gz: bc5154b98483efdbd3c246219a7e41fcbc4ec16ab224c3d639310f99b1de15c50bde8a396ebd89d2b7bd6c6b701bcc945c66167c472713e598161a2806a5cb26
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'
@@ -214,91 +214,66 @@ class Naver
214
214
  naver_cookie_dir = "C:/naver_cookie"
215
215
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
216
216
  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
+
217
218
  end
218
219
  def chrome_start(proxy, user_id)
219
220
  naver_cookie_dir = "C:/naver_cookie"
220
221
  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
222
  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
223
  begin
282
- # Proxy가 실패할 경우 예외 처리
283
- options = Selenium::WebDriver::Chrome::Options.new
284
- options.page_load_strategy = :normal
285
- options.timeouts = { page_load: 20_000 }
286
- options.page_load_strategy = 'none'
287
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
288
- options.add_argument('--remote-debugging-port=9222')
289
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
290
-
291
- # :capabilities options를 배열로 전달
292
- capabilities = [options]
293
-
294
- @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)
295
234
  rescue
296
- # 예외 발생 다른 방법으로 셀레니움 실행
297
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
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
298
274
  end
299
- end
300
275
  end
301
- end
276
+ end
302
277
 
303
278
 
304
279
 
@@ -1368,94 +1343,106 @@ class Naver
1368
1343
  # puts '카테고리 error'
1369
1344
  # puts e33
1370
1345
  # end
1371
- sleep(1)
1346
+ sleep(2)
1372
1347
  tags2 = option['tag'].to_s
1373
1348
  tag_mm2 = Array.new
1374
1349
  tags2.split(',').each do |tag_value|
1375
1350
  tag_mm2 << ''+tag_value
1376
1351
  end
1377
- @driver.find_element(:xpath, '//*[@id="app"]/div/div/section/div/div[2]/div[1]/div[4]/div/div/input').send_keys(tag_mm2.join("\n")+"\n")
1352
+ @driver.find_element(:xpath, '//*[@placeholder="태그를 입력해주세요 (최대 10개)"]').send_keys(tag_mm2.join("\n")+"\n")
1378
1353
 
1379
1354
  sleep(1)
1380
- # data['populationParams'] = '{"configuration":{"openType":'+option['공개']+',"commentYn":'+option['댓글허용']+',"searchYn":'+option['검색허용']+',"sympathyYn":'+option['공감허용']+',"scrapType":'+option['블로그공유']+',"outSideAllowYn":'+option['외부공유허용']+',"twitterPostingYn":false,"facebookPostingYn":false,"cclYn":false},"populationMeta":{"categoryId":'+category_value+',"logNo":null,"directorySeq":0,"directoryDetail":null,"mrBlogTalkCode":null,"postWriteTimeType":"now","tags":"'+tags2+'","moviePanelParticipation":false,"greenReviewBannerYn":false,"continueSaved":false,"noticePostYn":false,"autoByCategoryYn":false,"postLocationSupportYn":false,"postLocationJson":null,"prePostDate":null,"thisDayPostInfo":null,"scrapYn":false,"autoSaveNo":'+(Time.now.to_f.round(3)*1000).to_i.to_s+'},"editorSource":"AbZmtbYiAmhrzPJyhPXNWg=="}'
1381
- # if option['공개'] == '2'
1382
- # @driver.find_element(:xpath ,'//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[1]/span/label').click
1383
- # elsif option['공개'] == '3'
1384
- # @driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[3]/span/label').click
1385
- # elsif option['공개'] == '0'
1386
- # @driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[4]/span/label').click
1387
- # else
1388
- # @driver.find_element(:xpath, '//*[@id="root"]/div/div[1]/div/div[3]/div[3]/div/div/div/div[3]/div/div/ul/li[2]/span/label').click
1389
- # end
1355
+
1356
+ if option['전체공개'] == 'true'
1357
+ puts '전체공개'
1358
+ begin
1359
+ @driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
1360
+ sleep(2)
1361
+ @driver.find_element(:xpath, '//*[@for="all"]').click
1362
+ rescue
1363
+ end
1364
+ sleep(1)
1365
+ end
1366
+
1367
+ if option['멤버공개'] == 'true'
1368
+ puts '멤버공개'
1369
+ begin
1370
+ @driver.find_element(:xpath, '//*[@class="btn_open_set"]').click
1371
+ sleep(2)
1372
+ @driver.find_element(:xpath, '//*[@for="member"]').click
1373
+ rescue
1374
+ end
1375
+ sleep(1)
1376
+ end
1377
+
1390
1378
  if option['댓글허용'] == 'true'
1391
1379
  puts '댓글허용'
1392
- begin
1393
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[1]/div/label').click
1394
-
1395
- rescue
1396
-
1380
+ begin
1381
+ @driver.find_element(:xpath, '//*[@for="coment"]').click
1382
+ rescue
1383
+ end
1384
+ sleep(1)
1397
1385
  end
1398
- end
1399
1386
 
1400
- sleep(1)
1387
+
1401
1388
  if option['블로그,카페 공유허용'] == 'true'
1402
1389
  puts '블로그,카페 공유허용'
1403
1390
  begin
1404
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[2]/div[1]/label').click
1405
- rescue
1406
-
1391
+ @driver.find_element(:xpath, '//*[@for="blog_sharing"]').click
1392
+ rescue
1393
+ end
1394
+ sleep(1)
1407
1395
  end
1408
- end
1409
1396
 
1410
1397
 
1411
- sleep(1)
1398
+
1412
1399
  if option['외부공유허용'] == 'true'
1413
1400
  puts '외부공유허용'
1414
1401
  begin
1415
- @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
1416
- rescue
1417
-
1402
+ @driver.find_element(:xpath, '//*[@for="external_sharing"]').click
1403
+ rescue
1404
+ end
1405
+ sleep(1)
1418
1406
  end
1419
- end
1420
1407
 
1421
- sleep(1)
1408
+
1422
1409
 
1423
1410
  if option['복사,저장 허용'] == 'true'
1424
1411
  puts '복사,저장 허용'
1425
1412
  begin
1426
- @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
1427
- rescue
1428
-
1413
+ @driver.find_element(:xpath, '//*[@for="copy"]').click
1414
+ rescue
1415
+ end
1416
+ sleep(1)
1429
1417
  end
1430
- end
1431
1418
 
1432
- sleep(1)
1419
+
1433
1420
  if option['자동출처 사용'] == 'true'
1434
- puts '자동출처 사용'
1435
- begin
1436
- @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
1437
- rescue
1438
-
1439
- end
1440
- end
1421
+ puts '자동출처 사용'
1422
+ begin
1423
+ @driver.find_element(:xpath, '//*[@for="automatic_source"]').click
1424
+ rescue
1425
+ end
1426
+ sleep(1)
1427
+ end
1441
1428
 
1442
- sleep(1)
1429
+
1443
1430
 
1444
1431
  if option['CCL 사용'] == 'true'
1445
1432
  puts 'CCL 사용'
1446
1433
  begin
1447
- @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
1448
- rescue
1449
-
1434
+ @driver.find_element(:xpath, '//*[@for="ccl"]').click
1435
+ rescue
1436
+ end
1437
+ sleep(1)
1450
1438
  end
1451
- end
1452
- sleep(1)
1439
+
1453
1440
  # puts data['documentModel'] = data['documentModel'].to_json
1454
1441
 
1455
1442
  sleep(dd_time.to_i)
1456
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[1]/div/a').click
1443
+ @driver.find_element(:xpath, '//*[@class="BaseButton BaseButton--skinGreen size_default"]').click
1457
1444
 
1458
- sleep(10)
1445
+ sleep(7)
1459
1446
 
1460
1447
 
1461
1448
  begin
@@ -1601,18 +1588,10 @@ class Wordpress
1601
1588
 
1602
1589
  def get_naver_text(q)
1603
1590
  begin
1604
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1605
- options = Selenium::WebDriver::Chrome::Options.new
1606
- capabilities = [options]
1607
-
1608
- # Selenium WebDriver에서 options를 capabilities로 전달
1609
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1591
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1592
+ @driver = Selenium::WebDriver.for :chrome
1610
1593
  rescue
1611
- # :capabilities에 options를 배열로 전달
1612
- capabilities = [options]
1613
-
1614
- # Selenium WebDriver에서 options를 capabilities로 전달
1615
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1594
+ @driver = Selenium::WebDriver.for :chrome
1616
1595
  end
1617
1596
  @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
1597
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1642,18 +1621,10 @@ class Wordpress
1642
1621
 
1643
1622
  def get_naver_text2(keyword)
1644
1623
  begin
1645
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1646
- options = Selenium::WebDriver::Chrome::Options.new
1647
- capabilities = [options]
1648
-
1649
- # Selenium WebDriver에서 options를 capabilities로 전달
1650
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1624
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1625
+ @driver = Selenium::WebDriver.for :chrome
1651
1626
  rescue
1652
- # :capabilities에 options를 배열로 전달
1653
- capabilities = [options]
1654
-
1655
- # Selenium WebDriver에서 options를 capabilities로 전달
1656
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1627
+ @driver = Selenium::WebDriver.for :chrome
1657
1628
  end
1658
1629
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1659
1630
  for n3 in 1..10
@@ -2844,13 +2815,15 @@ class Wordpress
2844
2815
 
2845
2816
 
2846
2817
  if @data['포스트설정']['전체공개'].checked?
2847
- option['공개'] = '2'
2848
- # elsif @data['포스트설정']['서로이웃공개'].checked?
2849
- # option['공개'] = '3'
2850
- # elsif @data['포스트설정']['비공개'].checked?
2851
- # option['공개'] = '0'
2818
+ option['전체공개'] = 'true'
2819
+ else
2820
+ option['전체공개'] = 'false'
2821
+ end
2822
+
2823
+ if @data['포스트설정']['멤버공개'].checked?
2824
+ option['멤버공개'] = 'true'
2852
2825
  else
2853
- option['공개'] = '1'
2826
+ option['멤버공개'] = 'false'
2854
2827
  end
2855
2828
 
2856
2829
  if @data['포스트설정']['댓글허용'].checked?
@@ -4795,7 +4768,7 @@ class Wordpress
4795
4768
  end
4796
4769
  }
4797
4770
  }
4798
- @data['포스트설정']['멤버공개'] = checkbox('맴버공개'){
4771
+ @data['포스트설정']['멤버공개'] = checkbox('멤버공개'){
4799
4772
  top 10
4800
4773
  left 1
4801
4774
  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.19
4
+ version: 0.0.23
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-10 00:00:00.000000000 Z
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