wangkun 2 년 전
부모
커밋
53937c3d8b
9개의 변경된 파일58개의 추가작업 그리고 4개의 파일을 삭제
  1. BIN
      .DS_Store
  2. 3 0
      chlsfiles/__init__.py
  3. 38 2
      main/click_share_video.py
  4. 4 0
      main/common.py
  5. 1 0
      main/feishu_lib.py
  6. 3 1
      main/get_url.py
  7. 1 0
      main/publish.py
  8. 2 0
      main/run_shipinhao_recommend.py
  9. 6 1
      main/shipinhao_recommend.py

BIN
.DS_Store


+ 3 - 0
chlsfiles/__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+# @Author: wangkun
+# @Time: 2022/9/1

+ 38 - 2
main/click_share_video.py

@@ -4,11 +4,12 @@
 import os
 import sys
 import time
-
+import atomacos
 from appium import webdriver
 from selenium.webdriver.common.by import By
 sys.path.append(os.getcwd())
 from crawler_shipinhao.main.common import Common
+# from main.common import Common
 
 
 class Click:
@@ -29,6 +30,41 @@ class Click:
         time.sleep(5)
         driver.quit()
 
+    @classmethod
+    def click_video_mac(cls, log_type, video_title):
+        bundle_id = "com.tencent.xinWeChat"
+
+        # 启动应用
+        atomacos.launchAppByBundleId(bundle_id)
+        atomator = atomacos.getAppRefByBundleId(bundle_id)
+        time.sleep(3)
+
+        # 获取当前窗口
+        wx = atomator.windows()[0]
+        print(wx)
+
+        # # 获取群:爬虫群
+        # msg_windown = wx.findFirstR(AXRole="AXCell", AXParent="爬虫群")
+        # print(msg_windown)
+        # msg_windown.Press()
+
+        # # 获取位置参数
+        # msg_windown_position = msg_windown.AXPosition
+        # msg_windown_size = msg_windown.AXSize
+        # 注意AXPositon得到的坐标是元素左上角的坐标,需要根据实际大小得到元素中心点坐标
+        # msg_windown_click = (lt_position[0] + lt_size[0] / 2, lt_position[1] + lt_size[1])
+        # print(lt_click)
+        # lt.clickMouseButtonLeft(lt_position)
+        #
+        # # 输入内容(输入键盘字符,US_keyboard)
+        # # s1 = lt.findFirstR(AXRole='AXTextArea', AXRoleDescription='文本输入区')
+        # s1 = lt.findFirstR(AXRole='AXTextArea', AXLable='搜索')
+        # s1_p = s1.AXPosition
+        # s1_s = s1.AXSize
+        # s1.tripleClickMouse((s1_p[0] + s1_s[0] / 2, s1_p[1] + s1_s[1] / 2))
+        # s1.sendKeys('公众号')
+
 
 if __name__ == '__main__':
-    Click.click_video('recommend', '意外和明天谁都不知道哪个先来,所以请珍惜眼前人吧!特别是自己的家的男人在工地上干活的!那个条件,还有高危险作业的人们,谁都不是很努力的活着呀…')
+    # Click.click_video('recommend', '意外和明天谁都不知道哪个先来,所以请珍惜眼前人吧!特别是自己的家的男人在工地上干活的!那个条件,还有高危险作业的人们,谁都不是很努力的活着呀…')
+    Click.click_video_mac('recommend', '国家卫健委:昨日新增本土确诊病例307例!')

+ 4 - 0
main/common.py

@@ -32,6 +32,7 @@ class Common:
         """
         # 日志路径
         log_dir = r"./crawler_shipinhao/logs/"
+        # log_dir = r"./logs/"
         log_path = os.getcwd() + os.sep + log_dir
         if not os.path.isdir(log_path):
             os.makedirs(log_path)
@@ -65,6 +66,7 @@ class Common:
         :return: 保留最近 6 个日志
         """
         logs_dir = r"./crawler_shipinhao/logs/"
+        # logs_dir = r"./logs/"
         if not os.path.exists(logs_dir):
             os.mkdir(logs_dir)
 
@@ -92,10 +94,12 @@ class Common:
         下载保存路径:"./files/{d_title}/"
         """
         videos_dir = r"./crawler_shipinhao/videos/"
+        # videos_dir = r"./videos/"
         if not os.path.exists(videos_dir):
             os.mkdir(videos_dir)
         # 首先创建一个保存该视频相关信息的文件夹
         video_dir = r"./crawler_shipinhao/videos/" + d_name + r"/"
+        # video_dir = r"./videos/" + d_name + "/"
         if not os.path.exists(video_dir):
             os.mkdir(video_dir)
 

+ 1 - 0
main/feishu_lib.py

@@ -4,6 +4,7 @@ import json
 import requests
 import urllib3
 from crawler_shipinhao.main.common import Common
+# from main.common import Common
 proxies = {"http": None, "https": None}
 
 

+ 3 - 1
main/get_url.py

@@ -7,6 +7,7 @@ import sys
 import time
 sys.path.append(os.getcwd())
 from crawler_shipinhao.main.common import Common
+# from main.common import Common
 
 
 class GetUrl:
@@ -14,7 +15,8 @@ class GetUrl:
     def get_url(cls, log_type):
         try:
             # charles 抓包文件保存目录
-            charles_file_dir = r"./crawler_kanyikan_recommend/chlsfiles/"
+            # charles_file_dir = r"./crawler_kanyikan_recommend/chlsfiles/"
+            charles_file_dir = r"./chlsfiles/"
 
             if int(len(os.listdir(charles_file_dir))) == 1:
                 Common.logger(log_type).info("未找到chlsfile文件,等待60s")

+ 1 - 0
main/publish.py

@@ -9,6 +9,7 @@ import oss2
 import requests
 import urllib3
 from crawler_shipinhao.main.common import Common
+# from main.common import Common
 proxies = {"http": None, "https": None}
 
 

+ 2 - 0
main/run_shipinhao_recommend.py

@@ -8,6 +8,8 @@ import time
 sys.path.append(os.getcwd())
 from crawler_shipinhao.main.common import Common
 from crawler_shipinhao.main.shipinhao_recommend import Recommend
+# from main.common import Common
+# from main.shipinhao_recommend import Recommend
 
 
 class Main:

+ 6 - 1
main/shipinhao_recommend.py

@@ -14,6 +14,10 @@ from crawler_shipinhao.main.common import Common
 from crawler_shipinhao.main.feishu_lib import Feishu
 from crawler_shipinhao.main.click_share_video import Click
 from crawler_shipinhao.main.get_url import GetUrl
+# from main.common import Common
+# from main.feishu_lib import Feishu
+# from main.click_share_video import Click
+# from main.get_url import GetUrl
 
 
 class Recommend:
@@ -88,7 +92,8 @@ class Recommend:
         for i in range(10):
             # 关闭页面弹窗
             try:
-                driver.find_element(By.XPATH, '//*[@text="我知道了"]')
+                driver.find_element(By.XPATH, '//*[@text="我知道了"]').click()
+                driver.find_element(By.XPATH, '//*[@text="知道了"]').click()
                 Common.logger(log_type).info('已关闭未成年模式弹窗')
             except NoSuchElementException:
                 pass