Esempio n. 1
0
    def detail(self, device_id, is_shop):
        """
        转换xml数据,并提取关键数据,返回json格式数据
        :return: json格式数据
        """
        self.__dump_detail_xml(device_id)
        path = self.abs_detail_path.replace("{device_id}", device_id)
        result_list = load_detail_xml(path)
        if result_list.__len__() > 16:
            if is_shop == 0:
                data = {
                    "user": Node().to_obj(result_list[4]).text,
                    "orderNo": Node().to_obj(result_list[16]).text,
                    "money":
                    Node().to_obj(result_list[5]).text.replace("+", ""),
                    "state": Node().to_obj(result_list[6]).text,
                    "time": Node().to_obj(result_list[14]).text
                }
            elif is_shop == 1:
                data = {
                    "user": Node().to_obj(result_list[4]).text,
                    "orderNo": Node().to_obj(result_list[12]).text,
                    "money":
                    Node().to_obj(result_list[5]).text.replace("+", ""),
                    "state": Node().to_obj(result_list[6]).text,
                    "time": Node().to_obj(result_list[10]).text
                }

            return data
        else:
            return None
Esempio n. 2
0
 def get_alipay_account(self, device_id):
     """
     找到用户账户账户
     :return: 账户
     """
     self.__dump_x_page_xml(device_id)
     path = self.abs_x_path.replace("{device_id}", device_id)
     result_list = list_attr_value(
         path, "resource-id", "com.alipay.mobile.antui:id/list_right_text")
     if result_list.__len__() == 3:
         return Node().to_obj(result_list[1]).text, Node().to_obj(
             result_list[0]).text, Node().to_obj(result_list[2]).text
Esempio n. 3
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()
Esempio n. 4
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
Esempio n. 5
0
 def get_personal_x_y(self, device_id):
     self.__dump_x_page_xml(device_id)
     path = self.abs_x_path.replace("{device_id}", device_id)
     result_list = list_attr_value(
         path, "resource-id",
         "com.alipay.android.phone.wealth.home:id/user_account")
     if result_list.__len__() > 0:
         return Node().to_obj(result_list[0]).get_bounds()
Esempio n. 6
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
Esempio n. 7
0
 def get_click_clear_notify_x_y(self, device_id):
     """
     找到清理通知的坐标
     :return: x,y
     """
     path = self.abs_alipay_notify_path.replace("{device_id}", device_id)
     result_list = list_attr_value(path, "content-desc", "清")
     if result_list.__len__() > 0:
         return Node().to_obj(result_list[0]).get_bounds()
Esempio n. 8
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
Esempio n. 9
0
 def find_my_page(self, device_id):
     """
     :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 = list_attr_value(
         path, "resource-id",
         "com.alipay.android.phone.wealth.home:id/tab_description")
     if result_list.__len__() > 0:
         x, y = Node().to_obj(result_list[0]).get_bounds()
         return True, x, y
     else:
         return False, 0, 0
Esempio n. 10
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
Esempio n. 11
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
Esempio n. 12
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
Esempio n. 13
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
Esempio n. 14
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
Esempio n. 15
0
    logger.debug("解析数据:" + str(result_list))
    return result_list


if __name__ == '__main__':
    abs_path = '/Users/chendehui/workspaces/art_of_war/ui_xml/index.xml'
    result_list = load_detail_xml(abs_path)
    # result_list = load_xml(abs_path, attr="content-desc")

    # 个人
    print(result_list[4]["text"], result_list[5]["text"],
          result_list[6]["text"], result_list[14]["text"],
          result_list[16]["text"])

    # 商铺
    print(result_list[4]["text"], result_list[5]["text"],
          result_list[6]["text"], result_list[10]["text"],
          result_list[12]["text"])
    node = Node()
    for x in result_list:
        print(x)
        # node.to_obj(x)
        # if node.text.__eq__("支付宝通知"):
        #     print(node.get_bounds()[0])
        #     print(node.get_bounds()[1])

    list_attr = list_attr_value(abs_path, "resource-id",
                                "com.tencent.mm:id/e0n")
    for attr in list_attr:
        print(attr)