cafe_basics 0.0.17 → 0.0.23

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/cafe_basics.rb +127 -139
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da1c8c7a15888c18812deaa66dc7e24d50f129ddf4fb2d6acccf4f49762745f3
4
- data.tar.gz: 2b2d5fe9ffc44a8155e3897c3a6ccf0da8ad62b99225ec2e60e939c46f178292
3
+ metadata.gz: 3e593ed945c3909a09a182a3d903931df52580bb2723461c0b84be8f5d6792b2
4
+ data.tar.gz: fed4cb7513275a585dab7eee53edc67dfd4395bcf1dc5a2c11b56b40dcad4c96
5
5
  SHA512:
6
- metadata.gz: 88b2d0a0dcc47cc556e1f4a3e4a87c5181b13bde29239648b02cf45c022cf4835f413f36613f6cc351513636b1a24c70af279ac56a06341df74d99941353b56a
7
- data.tar.gz: 2f5ccecbc2ca0692eab295184cae46fa37c2a7eb229feb73eea80a5ed47d18f1af632e2f0367d097224100c0e18435e0b89daa5f346f5679f9309eab90bb1e8e
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'
@@ -219,71 +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
222
  if proxy == ''
224
- begin
225
- # webdrivers Gem이 크롬 드라이버 자동 다운로드 및 설정을 관리함
226
- options = Selenium::WebDriver::Chrome::Options.new
227
- options.page_load_strategy = :normal
228
- options.timeouts = { page_load: 20_000 }
229
- options.page_load_strategy = 'none'
230
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
231
-
232
-
233
-
234
- options.add_argument('--remote-debugging-port=9222')
235
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
236
-
237
- # :capabilities에 options를 배열로 전달
238
- capabilities = [options]
239
-
240
- # Selenium WebDriver에서 options를 capabilities로 전달
241
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
242
- rescue
243
- # 예외 발생 시 다른 방법으로 셀레니움 실행
244
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
245
- end
246
- else
247
- begin
248
- # Proxy를 사용하는 경우
249
- options = Selenium::WebDriver::Chrome::Options.new
250
- options.add_argument '--proxy-server=' + proxy.to_s.force_encoding('utf-8')
251
- options.page_load_strategy = :normal
252
- options.timeouts = { page_load: 20_000 }
253
- options.page_load_strategy = 'none'
254
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
255
-
256
- options.add_argument('--remote-debugging-port=9222')
257
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
258
-
259
- # :capabilities에 options를 배열로 전달
260
- capabilities = [options]
261
-
262
- # Selenium WebDriver에서 options를 capabilities로 전달
263
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
264
- rescue => e
265
- puts 'proxy error...'
266
223
  begin
267
- # Proxy가 실패할 경우 예외 처리
268
- options = Selenium::WebDriver::Chrome::Options.new
269
- options.page_load_strategy = :normal
270
- options.timeouts = { page_load: 20_000 }
271
- options.page_load_strategy = 'none'
272
- options.add_argument('--disable-blink-features=AutomationControlled') #자동화된 환경에서 실행되는 것을 감지하는 기능을 비활성화합니다.
273
- options.add_argument('--remote-debugging-port=9222')
274
- options.add_argument("user-data-dir=#{naver_cookie_dir}/#{user_id}")
275
-
276
- # :capabilities options를 배열로 전달
277
- capabilities = [options]
278
-
279
- @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)
280
234
  rescue
281
- # 예외 발생 다른 방법으로 셀레니움 실행
282
- @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
283
274
  end
284
- end
285
275
  end
286
- end
276
+ end
287
277
 
288
278
 
289
279
 
@@ -1353,94 +1343,106 @@ class Naver
1353
1343
  # puts '카테고리 error'
1354
1344
  # puts e33
1355
1345
  # end
1356
- sleep(1)
1346
+ sleep(2)
1357
1347
  tags2 = option['tag'].to_s
1358
1348
  tag_mm2 = Array.new
1359
1349
  tags2.split(',').each do |tag_value|
1360
1350
  tag_mm2 << ''+tag_value
1361
1351
  end
1362
- @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")
1363
1353
 
1364
1354
  sleep(1)
1365
- # 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=="}'
1366
- # if option['공개'] == '2'
1367
- # @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
1368
- # elsif option['공개'] == '3'
1369
- # @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
1370
- # elsif option['공개'] == '0'
1371
- # @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
1372
- # else
1373
- # @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
1374
- # 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
+
1375
1378
  if option['댓글허용'] == 'true'
1376
1379
  puts '댓글허용'
1377
- begin
1378
- @driver.find_element(:xpath, '/html/body/div[1]/div/div/section/div/div[2]/div[2]/div[3]/ul/li[1]/div/label').click
1379
-
1380
- rescue
1381
-
1380
+ begin
1381
+ @driver.find_element(:xpath, '//*[@for="coment"]').click
1382
+ rescue
1383
+ end
1384
+ sleep(1)
1382
1385
  end
1383
- end
1384
1386
 
1385
- sleep(1)
1387
+
1386
1388
  if option['블로그,카페 공유허용'] == 'true'
1387
1389
  puts '블로그,카페 공유허용'
1388
1390
  begin
1389
- @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
1390
- rescue
1391
-
1391
+ @driver.find_element(:xpath, '//*[@for="blog_sharing"]').click
1392
+ rescue
1393
+ end
1394
+ sleep(1)
1392
1395
  end
1393
- end
1394
1396
 
1395
1397
 
1396
- sleep(1)
1398
+
1397
1399
  if option['외부공유허용'] == 'true'
1398
1400
  puts '외부공유허용'
1399
1401
  begin
1400
- @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
1401
- rescue
1402
-
1402
+ @driver.find_element(:xpath, '//*[@for="external_sharing"]').click
1403
+ rescue
1404
+ end
1405
+ sleep(1)
1403
1406
  end
1404
- end
1405
1407
 
1406
- sleep(1)
1408
+
1407
1409
 
1408
1410
  if option['복사,저장 허용'] == 'true'
1409
1411
  puts '복사,저장 허용'
1410
1412
  begin
1411
- @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
1412
- rescue
1413
-
1413
+ @driver.find_element(:xpath, '//*[@for="copy"]').click
1414
+ rescue
1415
+ end
1416
+ sleep(1)
1414
1417
  end
1415
- end
1416
1418
 
1417
- sleep(1)
1419
+
1418
1420
  if option['자동출처 사용'] == 'true'
1419
- puts '자동출처 사용'
1420
- begin
1421
- @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
1422
- rescue
1423
-
1424
- end
1425
- end
1421
+ puts '자동출처 사용'
1422
+ begin
1423
+ @driver.find_element(:xpath, '//*[@for="automatic_source"]').click
1424
+ rescue
1425
+ end
1426
+ sleep(1)
1427
+ end
1426
1428
 
1427
- sleep(1)
1429
+
1428
1430
 
1429
1431
  if option['CCL 사용'] == 'true'
1430
1432
  puts 'CCL 사용'
1431
1433
  begin
1432
- @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
1433
- rescue
1434
-
1434
+ @driver.find_element(:xpath, '//*[@for="ccl"]').click
1435
+ rescue
1436
+ end
1437
+ sleep(1)
1435
1438
  end
1436
- end
1437
- sleep(1)
1439
+
1438
1440
  # puts data['documentModel'] = data['documentModel'].to_json
1439
1441
 
1440
1442
  sleep(dd_time.to_i)
1441
- @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
1442
1444
 
1443
- sleep(10)
1445
+ sleep(7)
1444
1446
 
1445
1447
 
1446
1448
  begin
@@ -1586,18 +1588,10 @@ class Wordpress
1586
1588
 
1587
1589
  def get_naver_text(q)
1588
1590
  begin
1589
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1590
- options = Selenium::WebDriver::Chrome::Options.new
1591
- capabilities = [options]
1592
-
1593
- # Selenium WebDriver에서 options를 capabilities로 전달
1594
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1591
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1592
+ @driver = Selenium::WebDriver.for :chrome
1595
1593
  rescue
1596
- # :capabilities에 options를 배열로 전달
1597
- capabilities = [options]
1598
-
1599
- # Selenium WebDriver에서 options를 capabilities로 전달
1600
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1594
+ @driver = Selenium::WebDriver.for :chrome
1601
1595
  end
1602
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')
1603
1597
  noko = Nokogiri::HTML(@driver.page_source)
@@ -1627,18 +1621,10 @@ class Wordpress
1627
1621
 
1628
1622
  def get_naver_text2(keyword)
1629
1623
  begin
1630
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1631
- options = Selenium::WebDriver::Chrome::Options.new
1632
- capabilities = [options]
1633
-
1634
- # Selenium WebDriver에서 options를 capabilities로 전달
1635
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1624
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
1625
+ @driver = Selenium::WebDriver.for :chrome
1636
1626
  rescue
1637
- # :capabilities에 options를 배열로 전달
1638
- capabilities = [options]
1639
-
1640
- # Selenium WebDriver에서 options를 capabilities로 전달
1641
- @driver = Selenium::WebDriver.for(:chrome, capabilities: capabilities)
1627
+ @driver = Selenium::WebDriver.for :chrome
1642
1628
  end
1643
1629
  @driver.get('https://search.naver.com/search.naver?ssc=tab.blog.all&sm=tab_jum&query='+keyword.to_s)
1644
1630
  for n3 in 1..10
@@ -2829,13 +2815,15 @@ class Wordpress
2829
2815
 
2830
2816
 
2831
2817
  if @data['포스트설정']['전체공개'].checked?
2832
- option['공개'] = '2'
2833
- # elsif @data['포스트설정']['서로이웃공개'].checked?
2834
- # option['공개'] = '3'
2835
- # elsif @data['포스트설정']['비공개'].checked?
2836
- # option['공개'] = '0'
2818
+ option['전체공개'] = 'true'
2819
+ else
2820
+ option['전체공개'] = 'false'
2821
+ end
2822
+
2823
+ if @data['포스트설정']['멤버공개'].checked?
2824
+ option['멤버공개'] = 'true'
2837
2825
  else
2838
- option['공개'] = '1'
2826
+ option['멤버공개'] = 'false'
2839
2827
  end
2840
2828
 
2841
2829
  if @data['포스트설정']['댓글허용'].checked?
@@ -4780,7 +4768,7 @@ class Wordpress
4780
4768
  end
4781
4769
  }
4782
4770
  }
4783
- @data['포스트설정']['멤버공개'] = checkbox('맴버공개'){
4771
+ @data['포스트설정']['멤버공개'] = checkbox('멤버공개'){
4784
4772
  top 10
4785
4773
  left 1
4786
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.17
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