class Task(object): def __init__(self, d): self._operator = Operator(d) self._douyin = Douyin(d) self._shuabao = Shuabao(d) self._wanqia = WanQia(d) self._wanqia_success = False self._qutoutiao = QuTouTiao(d) self._midu = MiDu(d) def exec_shuabao(self): self._shuabao.shuabao() def exec_qutoutiao(self): self._qutoutiao.qutoutiao() def exec_douyin(self): self._douyin.douyin() def exec_wanqia(self): if not self._wanqia_success: self._wanqia_success = self._wanqia.wanqia() def stop_all_apps(self): self._operator.close_all_app()
def __init__(self, d): self._operator = Operator(d) self._douyin = Douyin(d) self._shuabao = Shuabao(d) self._wanqia = WanQia(d) self._wanqia_success = False self._qutoutiao = QuTouTiao(d) self._midu = MiDu(d)
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 = '全部评论'
class Reader: def __init__(self, d): self._d = d self._operator = Operator(self._d) self._screen = Screen(self._d) def get_article_list_length(self, article_list_resource_id): article_list_length = self._operator.get_resource_length( article_list_resource_id) while article_list_length == 0: self.page_up() article_list_length = self._operator.get_resource_length( article_list_resource_id) if article_list_length > 0: return article_list_length return article_list_length def page_left(self): self._screen.page_left() def page_up(self): self._screen.page_up() def in_article(self, article_list_resource_id, article_index): title = self._operator.get_resource_text(article_list_resource_id, article_index) if title is None: return False print("INTO: " + title) if not self._operator.click_resource(article_list_resource_id, article_index): return False return True def read_article(self, direction='HORIZON'): if direction == 'HORIZON' or direction == 'H': self._screen.page_left() else: self._screen.page_up() sleep_random(3, 6) def exit_article(self): self._operator.go_back()
def __init__(self, d): self._d = d self._operator = Operator(d) self._reader = Reader(d) self._bonus_res = 'com.ss.android.ugc.aweme.lite:id/kh'
class Shuabao(object): _app_id = 'com.jm.video' _resource_id = _app_id + ":id/" _res_my_name = _resource_id + 'tv_name' def __init__(self, d): self._d = d self._operator = Operator(d) self._reader = Reader(d) self._bonus_res = 'com.ss.android.ugc.aweme.lite:id/kh' def start_app(self): self._operator.close_all_app() self._operator.start_app(self._app_id) # 右下角“我” def right_bottom_me(self): print("Click 我") self._operator.into_page_xpath('//*[@text="我"]', self._res_my_name, None) def watch_adv(self): sleep(35) while not self._operator.is_resource_exists( 'com.jm.video:id/tt_video_ad_close'): sleep(1) self._operator.click_resource_if_exist( 'com.jm.video:id/tt_video_ad_close') # 提钱 def withdraw(self): if get_hour() < 12: return adv_finish = False while not adv_finish: if self._operator.is_xpath_exist('//*[@text="提现"]'): self._operator.click_xpath_if_exist('//*[@text="提现"]') if self._operator.is_xpath_exist('//*[@text="立即观看"]'): self._operator.click_xpath_if_exist('//*[@text="立即观看"]') self.watch_adv() self._operator.go_back() else: adv_finish = True if self._operator.is_xpath_exist('//*[@text="提现"]'): self._operator.click_xpath_if_exist('//*[@text="提现"]') if self._operator.is_xpath_exist('//*[@text="立即提现"]'): self._operator.click_xpath_if_exist('//*[@text="立即提现"]') self._operator.click_xpath_if_exist('//*[@text="赚更多元宝"]') def sign(self): self.right_bottom_me() # 中间任务 print("Click 任务") self._operator.click_xpath_if_exist('//*[@text="任务"]') if self._operator.is_resource_exists('com.jm.video:id/imgClose'): self._operator.click_resource_if_exist('com.jm.video:id/imgClose') self.withdraw() if self._operator.is_xpath_exist('//*[@text="立即签到"]'): self._operator.click_xpath_if_exist('//*[@text="立即签到"]') if self._operator.is_xpath_exist('//*[@text="放弃签到看视频签到"]'): resource = self._d.xpath('//*[@text="放弃签到看视频签到"]') resource.click() self.watch_adv() self._operator.click_xpath_if_exist( '//*[@text="刷宝短视频"]/android.view.View[1]/android.view.View[6]/android.view.View[1]/android.view.View[1]' ) def watch(self): i = 0 while i < 15: print(i, '-', get_local_time(), '-', self._operator.get_resource_text('com.jm.video:id/desc')) self._reader.page_up() sleep_random() i += 1 def is_video(self): return self._operator.is_xpath_exist( '//*[@resource-id="com.jm.video:id/tabLayout"]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]' ) def go_to_video(self): while not self.is_video(): self._operator.go_back() self._operator.click_xpath_if_exist( '//*[@resource-id="com.jm.video:id/tabLayout"]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]' ) def shuabao(self): print("%s Shuabao start ..." % get_local_time()) self.start_app() self.sign() self.go_to_video() self.watch() self._operator.close_all_app() print("%s Shuabao end ..." % get_local_time())
def __init__(self, d): self._d = d self._operator = Operator(d) self._reader = Reader(d)
class Kuaishou: _app_id = 'com.ss.android.ugc.aweme.lite' _resource_id = _app_id + ":id/" _res_my_name = _resource_id + 'rd' _btn_laizhuanqian = _resource_id + 'ke' # 下方中间钱包按钮 _btn_continue_adv = _resource_id + 'a_g' # 继续观看视频按钮 _xpath_watch = '//*[@resource-id="app"]/android.view.View[2]/android.view.View[3]' # 宝箱观看视频领更多金币 _res_video_desc = _resource_id + 'tt' def __init__(self, d): self._d = d self._operator = Operator(d) self._reader = Reader(d) def start_app(self): self._operator.close_all_app() # self._operator.start_app(self._app_id) # if self._operator.is_resource_exists('com.ss.android.ugc.aweme.lite:id/al3'): # self._operator.click_resource_if_exist('com.ss.android.ugc.aweme.lite:id/al3') # if self._operator.is_resource_exists('com.ss.android.ugc.aweme.lite:id/tc'): # self._operator.click_resource_if_exist('com.ss.android.ugc.aweme.lite:id/tc') # 右下角“我” def into_me(self): print("Into 我") return self._operator.into_page_xpath('//*[@text="我"]', self._btn_laizhuanqian, None) def into_zhuanqian(self): print("Into 赚钱") return self._operator.into_page_resource(self._btn_laizhuanqian, None, '//*[@text="金币收益"]') def into_video(self): i = 0 while not self._operator.is_resource_exists(self._res_video_desc): i += 1 if i > 10: return False self.into_me() self._operator.click_xpath_if_exist('//*[@text="首页"]') return True def task(self): if self._operator.is_xpath_exist('//*[@text="看视频再赚"]'): self._operator.click_xpath_if_exist('//*[@text="看视频再赚"]') self.watch_adv() self._operator.go_back() # if self._operator.is_xpath_exist('//*[@text="开宝箱得金币"]'): # self._operator.click_xpath_if_exist('//*[@text="开宝箱得金币"]') # if self._operator.is_xpath_exist(self._xpath_watch): # self._operator.click_xpath_if_exist(self._xpath_watch) # self.watch_adv() # 提钱 def withdraw(self): if get_hour() < 11: return if self._operator.is_xpath_exist('//*[@text="去提现"]'): self._operator.click_xpath_if_exist('//*[@text="去提现"]') if self._operator.is_xpath_exist('//*[@text="天天提"]'): self._operator.click_xpath_if_exist('//*[@text="天天提"]') self._operator.click_xpath_if_exist('//*[@text="立即提现"]') self._operator.click_xpath_if_exist( '//android.app.Dialog/android.view.View[1]/android.view.View[4]' ) def sign(self): if not self.into_me(): return False # 中间取钱 if not self.into_zhuanqian(): return False self.withdraw() self.task() if not self.into_me(): return False # self._operator.click_xpath_if_exist('//*[@resource-id="app"]/android.view.View[3]') # self.watch_adv() # 第二行整点广告领取金币 # if self._operator.is_xpath_exist('//*[@text="去领取"]'): # self._operator.click_xpath_if_exist('//*[@text="去领取"]') # self._operator.click_resource_if_exist('com.ss.android.ugc.aweme.lite:id/yv') return True def watch_advs(self): i = 0 while i < 20: self.watch_adv() i += 1 def watch_adv(self): while True: try: self._d.xpath('//*[@text="看视频赚海量金币"]').click() break except Exception as e: print('Click resource failed' + str(e)) count = 0 while not self._operator.is_resource_exists( 'com.ss.android.ugc.livelite:id/rk'): sleep(5) count += 1 if count > 8: self._operator.click_xpath_if_exist('//*[@text="关闭广告"]') return self._operator.click_resource_if_exist( 'com.ss.android.ugc.livelite:id/rk') def watch(self): i = 0 while i < 150: print(i, '-', get_local_time()) self._reader.page_up() sleep_random(20, 30) i += 1 def is_video(self): return self._operator.is_xpath_exist('//*[@text="首页"]') def douyin(self): print("%s Douyin start ..." % get_local_time()) # self.start_app() if not self.sign(): return if not self.into_video(): return self.watch() self._operator.close_all_app() print("%s Douyin end ..." % get_local_time())
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())
def __init__(self, d): self._d = d self._operator = Operator(self._d) self._screen = Screen(self._d)
class WanQia: _app_id = 'com.yyk.whenchat' _resource_id = _app_id + ':id/' _btn_cancle_bind_phone = _resource_id + 'btnLeft' _txt_cancle_bind_phone = '取消' _btn_me = _resource_id + 'ivTabMine' def __init__(self, d): self._d = d self._operator = Operator(d) self._reader = Reader(d) def start_app(self): self._operator.close_all_app() self._operator.start_app(self._app_id) text = self._operator.get_resource_text(self._btn_cancle_bind_phone) if text is not None and text == self._txt_cancle_bind_phone: self._operator.click_resource_if_exist(self._btn_cancle_bind_phone) def sign(self): self._operator.click_resource_if_exist(self._btn_me) # self._operator.click_xpath_if_exist( # '//*[@resource-id="com.yyk.whenchat:id/vInvite"]/android.widget.ImageView[1]') self._operator.click_xpath_if_exist('//*[@text="邀请赚钱"]') self._operator.click_position(0.500, 0.880) # self._operator.click_xpath_if_exist('//*[@text="立即邀请"]') while not self._operator.is_resource_exists('com.tencent.mm:id/ln'): self._operator.click_xpath_if_exist( '//*[@resource-id="com.yyk.whenchat:id/gvBody"]/android.widget.LinearLayout[1]/android.widget.ImageView[1]' ) sleep(30) self._operator.go_back() return True def wanqia(self): print("%s WanQia start ..." % get_local_time()) self.start_app() success = self.sign() self._operator.close_all_app() print("%s WanQia end ..." % get_local_time()) return success
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()
def __init__(self, device_id): self._d = u2.connect_usb(device_id) self._operator = Operator(self._d) self._reader = Reader(self._d)
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)