コード例 #1
0
 def find_alipay_x_y(self, device_id):
     """
     查找支付宝的 x y 的位置
     :return: x y
     """
     self.__dump_alipay_app_xml(device_id)
     # path device_id
     path = self.abs_alipay_app_path.replace("{device_id}", device_id)
     result_list = load_xml(path)
     for result in result_list:
         node = Node().to_obj(result)
         if node.text.find("支付宝") >= 0:
             return node.get_bounds()
コード例 #2
0
 def notify_list(self, device_id):
     """
     统计支付宝支付通知条数
     :return: 通知总数
     """
     self.__dump_alipay_notify_xml(device_id)
     path = self.abs_alipay_notify_path.replace("{device_id}", device_id)
     result_list = load_xml(path)
     count = 0
     if result_list.__len__() > 0:
         for result in result_list:
             if str(Node().to_obj(result).text).find("支付宝") >= 0:
                 count += 1
     return count
コード例 #3
0
 def get_bill_click_x_y(self, device_id):
     """
     获取 账单的点击坐标 x y
     :return:
     """
     if self.is_user_center_page(device_id):
         self.__dump_bill_coordinate_page_xml(device_id)
         path = self.abs_bill_coordinate_path.replace(
             "{device_id}", device_id)
         result_list = load_xml(path)
         for result in result_list:
             node = Node().to_obj(result)
             if node.text.__eq__("账单"):
                 return node.get_bounds()
     else:
         return False
コード例 #4
0
    def detect_connect(self, device_id):
        """
        检测设备连接是否成功
        :return: 通知总数
        """
        self.__dump_connect_xml(device_id)
        path = self.abs_connect_path.replace("{device_id}", device_id)
        result_list = load_xml(path)
        if result_list.__len__() > 0:
            for result in result_list:
                if str(Node().to_obj(result).text).find("充电") > 0:
                    x, y = Node().to_obj(result).get_bounds()
                    return True, x, y

            return False, 0, 0
        else:
            return False, 0, 0
コード例 #5
0
    def is_bill_list_page(self, device_id):
        """
        判断当前支付宝所在页面是否是 "账单" 页面
        :return:True/False
        """
        self.__dump_bill_page_xml(device_id)
        count_bill = 0
        path = self.abs_bill_path.replace("{device_id}", device_id)
        result_list = load_xml(path)
        for result in result_list:
            node = Node().to_obj(result)
            if node.text.__eq__("账单"):
                count_bill += 1

        if count_bill >= 2:
            return True
        else:
            return False
コード例 #6
0
 def find_page_keywords(self, device_id, keyworkds, frequency=1):
     """
     根据支付宝页面的关键词进行检查当前是否在当前页,关键词比如 “我的” 是
     我的页面的关键词,出现2次,频率为2次匹配才算在指定页面,默认最少1次
     :param keyworkds: 关键词,一般为页面独一为二的关键词
     :param frequency: 出现在特殊页面的频次
     :return: True/False
     """
     self.__dump_x_page_xml(device_id)
     path = self.abs_x_path.replace("{device_id}", device_id)
     result_list = load_xml(path)
     count = 0
     for result in result_list:
         node = Node().to_obj(result)
         if node.text.__eq__(keyworkds):
             count += 1
     if count >= frequency:
         return True
     else:
         return False
コード例 #7
0
    def is_user_center_page(self, device_id):
        """
        判断当前支付宝所在页面是否是 "我的" 页面
        :return:True/False
        """
        self.__dump_my_page_xml(device_id)
        is_my = False
        is_bill = False
        path = self.abs_my_path.replace("{device_id}", device_id)
        result_list = load_xml(path)
        for result in result_list:
            node = Node().to_obj(result)
            if node.text.__eq__("我的"):
                is_my = True
            if node.text.__eq__("账单"):
                is_bill = True

        if is_my and is_bill:
            return True
        else:
            return False
コード例 #8
0
    def is_personal_apge(self, device_id):
        """
        是否是个人页面
        :return:True/False
        """
        self.__dump_personal_page_xml(device_id)
        is_personal = False
        is_personal_page = False
        path = self.abs_personal_path.replace("{device_id}", device_id)
        result_list = load_xml(path)
        for result in result_list:
            node = Node().to_obj(result)
            if node.text.__eq__("个人信息"):
                is_personal = True
            if node.text.__eq__("个人主页"):
                is_personal_page = True

        if is_personal and is_personal_page:
            return True
        else:
            return False
コード例 #9
0
    def income_list(self, device_id, num):
        """
        获取收入的列表
        :param num: 读取多少条默认5条
        :return: list
        """
        self.__dump_bill_page_xml(device_id)
        path = self.abs_bill_path.replace("{device_id}", device_id)
        result_list = load_xml(path)
        income_list = list()
        for income in result_list:
            data = {
                "user": None,
                "money": 0,
                "goods": None,
                "today": None,
                "time": None,
                "click_x_y": None
            }
            node = Node().to_obj(income)
            if node.text.find("收钱码收款") >= 0 or node.text.find("收款") >= 0:
                index = result_list.index(income)
                for i in range(num):
                    try:
                        node_data = Node().to_obj(result_list[index + i])
                        if i == 0:
                            data["user"] = node_data.text.replace(
                                "收钱码收款-来自", "").replace("收款-", "")
                        elif i == 1:
                            money = node_data.text
                            if money.find("-") >= 0:
                                return
                            else:
                                money = money.replace("+", "")
                                data["money"] = float(money)
                            str_data = node_data.bounds
                            str_data = str_data.replace("][", "|").replace(
                                "[", "").replace("]", "")
                            str_data_arr = str_data.split("|")
                            arr = str(str_data_arr[1]).split(",")
                            income = int(arr[0])
                            y = int(arr[1]) - 20
                            data["click_x_y"] = [income, y]
                        elif i == 2:
                            data["goods"] = node_data.text
                        elif i == 3:
                            today = node_data.text
                            if today.__eq__("今天"):
                                data["today"] = str(
                                    datetime.datetime.now().strftime('%Y%m%d'))
                            elif today.__eq__("昨天"):
                                today = datetime.date.today()
                                oneday = datetime.timedelta(days=1)
                                yesterday = today - oneday
                                data["today"] = str(yesterday)

                        elif i == 4:
                            data["time"] = node_data.text
                    except:
                        pass
                # 不符合数据规范的进行排除
                if not (not data["time"] or not data["today"]
                        or data["click_x_y"][1] < 0):
                    income_list.append(data)

        return income_list