cafe_basics 0.0.23 → 0.0.29

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 +104 -30
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e593ed945c3909a09a182a3d903931df52580bb2723461c0b84be8f5d6792b2
4
- data.tar.gz: fed4cb7513275a585dab7eee53edc67dfd4395bcf1dc5a2c11b56b40dcad4c96
3
+ metadata.gz: f18c2f79ad573c568282070643d09f31f5e2999663ef238d5576cf725906ac16
4
+ data.tar.gz: 36104de37c3075f6d4a66687c100adb15bd13914d08625d142ac918012c34e45
5
5
  SHA512:
6
- metadata.gz: fbcd9bcf9214acaaa20c2de674297ebce51886b8b72351fa6da5548042c77efcb48c4532c333360e5263983a17c96166ecb4295ea3a63470f257720ce92ded17
7
- data.tar.gz: bc5154b98483efdbd3c246219a7e41fcbc4ec16ab224c3d639310f99b1de15c50bde8a396ebd89d2b7bd6c6b701bcc945c66167c472713e598161a2806a5cb26
6
+ metadata.gz: 51c37a0a6ae930c30a1381e792a1879c793607704e58a94d0369daa14d5079f5d0e0a8da83e48fd2e97ad0083f9d68f9c4140bfaa7d786c425ad66e590fd6f5b
7
+ data.tar.gz: 2a1cc15269b6efa03b5d03b58004a3f50790530c051eb6f2315fcc7796dc63be5e65bfa737790d7ff1abd09135a5da103778c998eb0b3f515b1de2295606b469
data/lib/cafe_basics.rb CHANGED
@@ -210,11 +210,14 @@ 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"
@@ -295,7 +298,7 @@ class Naver
295
298
  end
296
299
 
297
300
  # 새로운 스레드 생성 및 실행
298
- Thread.new { chrome_setup(user_id) }
301
+ Thread.new { chrome_setup(user_id, proxy) }
299
302
  sleep(3)
300
303
 
301
304
 
@@ -727,10 +730,18 @@ class Naver
727
730
  if i2.to_s.include?('<img')
728
731
  path = i2.to_s.split('src="')[1].split('"')[0]
729
732
  path = URI.decode_www_form(path)[0][0]
733
+
734
+ @driver.execute_script(<<~JS)
735
+ window.URL.createObjectURL = function() {};
736
+ HTMLInputElement.prototype.click = function() {
737
+ console.log("File dialog suppressed");
738
+ };
739
+ JS
740
+ sleep(1)
730
741
  # 이미지 등록 버튼 클릭
731
742
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
732
743
  sleep(3)
733
- key_stroke('escape')
744
+ #key_stroke('escape')
734
745
 
735
746
  # 파일 경로 변환 (슬래시 -> 백슬래시)
736
747
  file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
@@ -741,9 +752,43 @@ class Naver
741
752
  # send_keys로 파일 경로를 직접 입력하여 파일 업로드
742
753
  file_input.send_keys(file_path)
743
754
  sleep(3)
744
-
745
755
 
746
-
756
+ @driver.action.key_down(:up).key_up(:up).perform
757
+ sleep(1)
758
+
759
+ begin
760
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
761
+ #요소가 나타날 때까지 60초 동안 기다립니다.
762
+ wait.until { @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]') }
763
+ sleep(1)
764
+ @driver.find_element(:xpath, '//li[@class="se-toolbar-item se-toolbar-item-resizing"]//button[@data-name="image-resizing"]').click
765
+
766
+ sleep(1)
767
+ begin
768
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
769
+ #요소가 나타날 때까지 60초 동안 기다립니다.
770
+ wait.until { @driver.find_element(:xpath, '//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//button[@class="se-custom-layer-resizing-reset-button"]') }
771
+ sleep(1)
772
+ @driver.find_element(:xpath, '//div[@class="se-custom-layer-option se-custom-layer-option-resizing"]//button[@class="se-custom-layer-resizing-reset-button"]').click
773
+ sleep(1)
774
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
775
+ sleep(1)
776
+ rescue
777
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
778
+ #요소가 나타날 때까지 60초 동안 기다립니다.
779
+ wait.until { @driver.find_element(:xpath, '//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]') }
780
+ sleep(1)
781
+ @driver.find_element(:xpath, '//span[@class="se-custom-layer-resizing-reset-label" and text()="초기화"]').click
782
+ sleep(1)
783
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
784
+ sleep(1)
785
+ end
786
+ rescue
787
+ @driver.action.key_down(:down).key_up(:down).perform
788
+
789
+ end
790
+
791
+
747
792
  if option['사진타이틀'] == 'true'
748
793
  begin
749
794
  @driver.action.key_down(:up).key_up(:up).perform
@@ -781,38 +826,67 @@ class Naver
781
826
  elsif i2.to_s.include?('<video')
782
827
  path = i2.to_s.split('src="')[1].split('"')[0]
783
828
  path = URI.decode_www_form(path)[0][0]
784
-
829
+
785
830
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[3]/button').click
786
831
  sleep(3)
832
+
833
+
834
+ @driver.execute_script(<<~JS)
835
+ window.URL.createObjectURL = function() {};
836
+ HTMLInputElement.prototype.click = function() {
837
+ console.log("File dialog suppressed");
838
+ };
839
+ JS
840
+ sleep(1)
841
+ # 파일 업로드 버튼 클릭 (이제 파일 선택 창이 뜨지 않음)
787
842
  @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/fieldset/div[1]/button[1]').click
788
843
  sleep(3)
789
-
790
- Clipboard.copy(path.split('/').join("\\"))
791
- key_down('ctrl')
792
- key_stroke('v')
793
- key_up('ctrl')
844
+
845
+ file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
846
+ # 파일 입력 필드 찾기 (input[type="file"])
847
+ file_input = @driver.find_element(:id, "hidden-input")
848
+
849
+ # send_keys로 파일 경로를 직접 입력하여 파일 업로드
850
+ file_input.send_keys(file_path)
851
+
794
852
  sleep(3)
795
- key_stroke('enter')
796
- sleep(2)
797
-
798
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
799
- sleep(1)
800
- @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
801
- sleep(1)
853
+ begin
854
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_title"]').send_keys(title)
855
+ sleep(1)
856
+ rescue
857
+ end
858
+
859
+ begin
860
+ @driver.find_element(:xpath, '//*[@id="nvu_inp_box_description"]').send_keys(title)
861
+ sleep(1)
862
+ rescue
863
+ end
864
+
865
+ begin
802
866
  @driver.find_element(:xpath, '//*[@id="nvu_inp_box_tag"]').send_keys(title)
803
- sleep(1)
867
+ sleep(1)
868
+ rescue
869
+ end
804
870
 
805
871
  for n in 1..10
806
- puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
807
- if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
808
- break
809
- end
810
- sleep(10)
872
+ begin
873
+ puts @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text
874
+ if @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[2]/div[1]/ul/li/div/button[1]/div[2]/em').text == '업로드 완료'
875
+ break
876
+ end
877
+ sleep(10)
878
+ rescue
879
+ end
811
880
  end
812
- @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
813
- sleep(3)
814
- @driver.action.key_down(:up).key_up(:up).perform #x탭
815
- sleep(1)
881
+
882
+ begin
883
+ @driver.find_element(:xpath, '//*[@id="video-uploader-wrap"]/div/div/div[3]/button/span').click
884
+ sleep(3)
885
+ @driver.action.key_down(:up).key_up(:up).perform #x탭
886
+ sleep(1)
887
+ rescue
888
+ end
889
+
816
890
  begin
817
891
  wait = Selenium::WebDriver::Wait.new(:timeout => 3)
818
892
  #요소가 나타날 때까지 60초 동안 기다립니다.
@@ -2072,7 +2146,7 @@ class Wordpress
2072
2146
  @data['table'] << []
2073
2147
  @data['table'].pop
2074
2148
  #포스팅 get 데이터 가저오기#############################
2075
- proxy = table[3].to_s
2149
+ proxy = table[6].to_s
2076
2150
  user_id = table[1].to_s
2077
2151
  user_pw = table[2].to_s
2078
2152
  naver = Naver.new
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.23
4
+ version: 0.0.29
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-20 00:00:00.000000000 Z
11
+ date: 2025-02-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com