예제 #1
0
class TaoXiaoShuo:
    _app_id = 'com.martian.ttbook'

    _article_list_res = 'com.martian.ttbook:id/bs_list_book_name'
    _article_read_res = 'com.martian.ttbook:id/bd_reading'
    _article_advertise_close_res = 'com.martian.ttbook:id/bt_cancel'
    _article_save_to_shell_res = 'com.martian.ttbook:id/dialog_close'
    _article_end_res = 'com.martian.ttbook:id/tv_buy_reading_purcgase'
    _article_end_text = '余额不足请充值'

    def __init__(self, device_id):
        self._d = u2.connect_usb(device_id)
        self._operator = Operator(self._d)
        self._reader = Reader(self._d)

    def get_article_list_length(self):
        return self._operator.get_resource_length(self._article_list_res)

    def next_article_list(self):
        self._reader.page_up()
        time.sleep(3)

    def in_article(self, i):
        self._reader.in_article(self._article_list_res, i)
        time.sleep(3)
        self._operator.click_resource_if_exist(self._article_read_res)
        time.sleep(3)
        self._operator.click_resource_if_exist(self._article_advertise_close_res)

    def out_article(self):
        print(self._operator.get_resource_text('com.martian.ttbook:id/duration_bonus'))
        self._operator.go_back()
        time.sleep(3)
        self._operator.click_resource_if_exist(self._article_save_to_shell_res)
        time.sleep(3)
        while 0 == self.get_article_list_length():
            self._operator.go_back()
            time.sleep(3)

    def check_end(self):
        text = self._operator.get_resource_text(self._article_end_res)
        return text is not None and text == self._article_end_text

    def read(self):
        i = 0
        while not taoxiaoshuo.check_end():
            i += 1
            now = int(time.time())
            time_struct = time.localtime(now)
            print(i, '-', time.strftime("%Y-%m-%d %H:%M:%S", time_struct))
            self._reader.page_left()
            time.sleep(random.randint(5, 7))
            self._operator.click_resource_if_exist(self._article_advertise_close_res)
예제 #2
0
class QuTouTiao(object):
    _app_id = 'com.jifen.qukan'
    _resource_id = _app_id + ":id/"

    def __init__(self, d):
        self._d = d
        self._operator = Operator(d)
        self._reader = Reader(d)

        self._article_list_res = 'com.jifen.qukan:id/aly'

        self._top_left_bonus_res = 'com.jifen.qukan:id/bwg'
        self._top_left_bonus_text = '领取'

        self._comment_res = 'com.jifen.qukan:id/a0o'
        self._comment_text = '全部评论'

    def start_app(self):
        self._operator.close_all_app()
        self._operator.start_app(self._app_id)

    # 右下角“我”
    def into_me(self):
        print("Click 我的")
        while not self._operator.is_xpath_exist('//*[@text="查看个人主页"]'):
            self._operator.click_xpath_if_exist('//*[@text="我的"]')

    def sign(self):
        self.into_me()
        self.withdraw()
        print("Click 去签到")
        self._operator.click_xpath_if_exist('//*[@text="去签到"]')
        self._operator.click_xpath_if_exist('//*[@text="任务"]')

        i = 0
        while not self._operator.is_xpath_exist('//*[@text="挑战60天超长签到"]'):
            print("60天超长签到")
            i += 1
            if i > 10:
                break
            self._reader.page_up()
        self._operator.click_xpath_if_exist('//*[@text="挑战60天超长签到"]')
        self._operator.go_back()

    def current_position(self):
        if self._operator.is_resource_exists(
                'com.jifen.qukan:id/nz') and self._operator.is_resource_exists(
                    'com.jifen.qukan:id/bpq'):
            return 'ARTICLE'
        else:
            return 'LIST'

    def withdraw(self):
        print("提现")
        # if get_hour() < 12:
        #     return
        self._operator.click_xpath_if_exist('//*[@text="我的"]')
        self._operator.click_resource_if_exist('com.jifen.qukan:id/auv')
        self._operator.click_xpath_if_exist('//*[@text="提现"]')
        self._operator.click_resource_if_exist('alipay_quick')
        self._operator.click_xpath_if_exist('//*[@text="我知道了"]')
        self._operator.go_back()
        self._operator.go_back()
        self._operator.go_back()

    def read(self):
        print("阅读文章")
        self._operator.click_xpath_if_exist('//*[@text="我的"]')
        self._operator.click_xpath_if_exist('//*[@text="头条"]')
        self._operator.click_xpath_if_exist('//*[@text="刷新"]')
        total_artical = 0
        while total_artical < 5:
            self._reader.page_up()
            article_list_length = self.get_article_list_length()
            self.get_top_left_bonus()
            for i in range(0, article_list_length):
                if self.in_article(i):
                    self.read_article()
                    total_artical += 1
                    self._operator.go_back()
                    print("total_artical: ", total_artical)

    def watch(self):
        print("观看视频")
        self._operator.click_xpath_if_exist('//*[@text="我的"]')
        self._operator.click_xpath_if_exist('//*[@text="视频"]')
        self._operator.click_xpath_if_exist('//*[@text="刷新"]')
        total_video = 0
        while total_video < 6:
            print("total_video: ", total_video)
            self._operator.click_resource_if_exist('com.jifen.qukan:id/qy')
            total_video += 1
            self.get_money()
            if self._operator.is_resource_exists('com.jifen.qukan:id/ud'):
                text = self._operator.get_resource_text(
                    'com.jifen.qukan:id/ud')
                if text is not None and text == '继续观看':
                    self._operator.click_resource_if_exist(
                        'com.jifen.qukan:id/ud')
            sleep_random()
            self._reader.page_up()

    def get_top_left_bonus(self):
        bonus_text = self._operator.get_resource_text(self._top_left_bonus_res)
        if bonus_text is not None and bonus_text == self._top_left_bonus_text:
            self._operator.click_resource_if_exist(self._top_left_bonus_res)

    def check_end(self):
        text = self._operator.get_resource_text(self._comment_res)
        return text is not None and text == self._comment_text

    def get_money(self):
        if self._operator.is_resource_exists('com.jifen.qukan:id/brl'):
            self._operator.click_resource_if_exist('com.jifen.qukan:id/brl')
            self._operator.click_resource_if_exist('com.jifen.qukan:id/a66')

    def get_article_list_length(self):
        length = self._reader.get_article_list_length(self._article_list_res)
        while length == 0:
            self._reader.page_up()
            length = self._reader.get_article_list_length(
                self._article_list_res)
        return length

    def in_article(self, i):
        if self._reader.in_article(self._article_list_res, i):
            sleep()
            return True
        else:
            return False

    def read_article(self):
        up_count = 0
        while not self.check_end() and up_count < 10:
            self._reader.read_article('V')
            up_count += 1
            self.get_money()

    def qutoutiao(self):
        print("%s Qutoutiao start ..." % get_local_time())
        self.start_app()
        self.sign()
        self.read()
        self.watch()
        self._operator.close_all_app()
        print("%s Qutoutiao end ..." % get_local_time())
예제 #3
0
class MiDu:
    _app_id = 'com.lechuan.mdwz'
    _resource_id = _app_id + ":id/"

    _res_article_list = _resource_id + 'gm'
    _res_article_read = _resource_id + 're'
    _res_article_advertise_close = _resource_id + 'p6'
    _btn_adv_in_adv = _resource_id + 'pe'
    _btn_adv_close_adv = _resource_id + 'tt_video_ad_close'

    # _article_save_to_shell_res = 'com.martian.ttbook:id/dialog_close'
    # _article_end_res = 'com.martian.ttbook:id/tv_buy_reading_purcgase'
    # _article_end_text = '余额不足请充值'

    def __init__(self, d):
        self._d = d
        self._reader = Reader(d)
        self._operator = Operator(d)
        self._reader = Reader(d)

    def page_up(self):
        self._reader.page_up()

    def start_app(self):
        self._operator.close_all_app()
        self._operator.start_app(self._app_id)
        while not (self._operator.is_xpath_exist('//*[@text="我的"]')
                   and self._operator.is_xpath_exist('//*[@text="福利"]')):
            self._operator.go_back()

    def into_me(self):
        print("Into 我")
        return self._operator.into_page_xpath('//*[@text="我的"]', None, None)

    def get_article_list_length(self):
        return self._operator.get_resource_length(self._article_list_res)

    def next_article_list(self):
        self.page_up()
        sleep()

    def in_article(self, i):
        self._reader.in_article(self._article_list_res, i)
        sleep()
        self._operator.click_resource_if_exist(self._article_read_res)
        sleep()
        self._operator.click_resource_if_exist(
            self._article_advertise_close_res)

    def out_article(self):
        print(
            self._operator.get_resource_text(
                'com.martian.ttbook:id/duration_bonus'))
        self._operator.go_back()
        sleep()
        # self._operator.click_resource_if_exist(self._article_save_to_shell_res)
        # time.sleep(3)
        while 0 == self.get_article_list_length():
            self._operator.go_back()
            sleep()

    def check_end(self):
        return False
        # text = self._operator.get_resource_text(self._article_end_res)
        # return text is not None and text == self._article_end_text

    def read(self):
        i = 0
        while not self.check_end():
            i += 1
            print(i, '-', get_local_time())
            try:
                self._d.click(0.988, round(random.uniform(0.3, 0.7), 3))
            except Exception as e:
                print('Click resource failed' + str(e))
            sleep_random(2, 5)
            self._operator.click_resource_if_exist('com.lechuan.mdwz:id/oh')
            # 看视频翻倍金币
            # if self._operator.is_resource_exists(self._btn_adv_in_adv):
            #     self._operator.click_resource_if_exist(self._btn_adv_in_adv)
            #     while self._operator.is_resource_exists(self._btn_adv_close_adv):
            #         sleep()
            #     self._operator.click_resource_if_exist(self._btn_adv_close_adv)

            # self._operator.click_resource_if_exist(self._res_article_advertise_close)
            # self._operator.click_resource_if_exist('com.lechuan.mdwz:id/g_')
            # s = self._operator.get_resource_text('com.lechuan.mdwz:id/nz')
            # if s is not None and s == '立即领取':
            #     self._operator.click_resource_if_exist('com.lechuan.mdwz:id/nz')
            #     time.sleep(1)
            #     self._operator.click_resource('com.lechuan.mdwz:id/g_')
            # self._operator.click_resource_if_exist('com.lechuan.mdwz:id/gy')

    def midu(self):
        self.start_app()