Przeglądaj źródła

第一版广告点击上线

罗俊辉 1 rok temu
rodzic
commit
26ba10543b

+ 0 - 0
application/config/aliyun_config.py


+ 0 - 0
application/config/mysql_config.py


+ 11 - 20
application/spider/ad_click/piaoquan_tv_v1.py

@@ -32,25 +32,15 @@ class PQuanTv(object):
         }
         self.driver = webdriver.Remote("http://localhost:4750/wd/hub", self.caps)
 
-    def open_wechat(self):
-        self.driver.implicitly_wait(1)
-        for i in range(5):
-            if self.driver.find_elements(By.ID, "com.tencent.mm:id/f2s"):
-                break
-            elif self.driver.find_element(By.ID, "com.android.systemui:id/dismiss_view"):
-                self.driver.find_element(By.ID, "com.android.system:id/dismiss_view").click()
-            else:
-                pass
-        self.driver.find_elements(By.XPATH, '//*[@text="{}"]'.format(self.platform))[-1].click()
-
-    def click_ad(self):
-        elements = self.driver.find_elements(By.ID, "com.tencent.mm:id/fhs")
-        print(elements)
-        elements[0].click()
-        return
-
 
 class PQuanTvDev(object):
+    """
+    __init__: 初始化类, 初始化driver;
+    open_minigram: 下拉,通过搜索小程序名字打开小程序
+    open_chat_box: 进入微信之后打开聊天框
+    click_ad: 点击消息,打开小程序之后,点击广告, 退出
+    """
+
     def __init__(self, rule_dict):
         self.platform = "票圈|3亿人喜欢的视频平台"
         self.rule_dict = rule_dict
@@ -107,8 +97,10 @@ class PQuanTvDev(object):
         minigram = self.driver.find_elements(By.ID, "com.tencent.mm:id/b2o")
         if minigram:
             minigram[0].click()
-        print("成功打开小程序")
-        return
+            print("成功打开小程序")
+            self.driver.press_keycode(AndroidKey.BACK)
+        else:
+            return
 
 
 if __name__ == "__main__":
@@ -117,4 +109,3 @@ if __name__ == "__main__":
     Pv.open_chat_box()
     time.sleep(10)
     Pv.click_ad()
-