def watch_local(): driver(text='北京').click() time.sleep(2) driver(text='北京卫视').click() print("观看本地频道...") time.sleep(20) print("本地频道结束") driver.press.back()
def read_sport(): time.sleep(10) #切换到学习首页面 # driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact").click()#这里要换,测试后换成新地址 #切换到要闻界面 driver(text='体育').click() time.sleep(5) autoJob(tv="阅读体育新闻2篇并分享收藏评论",sleep_time=20,sum=2) print("阅读体育新闻2篇并分享收藏评论结束")
def read_articles(): time.sleep(10) #切换到学习首页面 # driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact").click()#这里要换,测试后换成新地址 #切换到要闻界面 driver(text='要闻').click() time.sleep(5) autoJob(tv="阅读文章",sleep_time=130,sum=6,click=False)#130 print("阅读文章结束")
def watch_video(): time.sleep(2) #切换到电视台页面 driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact").click() driver(text="联播频道").click() autoJob(tv="观看视频",sleep_time=25,click=False) driver(text="联播频道").click() news=None for v in driver(className='android.widget.TextView'): if "《新闻联播》" in v.text: news=v.text break driver(text=news).click() #100天后删除最早一天的记录 text_list=np.array (all_of_list) if len(text_list)>2500: text_list = text_list[25:] #存储已看视频和文章 np.save ('db.npy',text_list) print("正在观看新闻联播...") time.sleep(1050) driver.press.back() print("观看视频结束.")
def watch_video(): time.sleep(5) #切换到电视台页面 driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact").click() time.sleep(5) driver(text="联播频道").click() time.sleep(5) autoJob(tv="观看视频",sleep_time=20,sum=6,click=False) driver(text="联播频道").click() time.sleep(5) news=None for v in driver(className='android.widget.TextView'): if "《新闻联播》" in v.text: news=v.text break driver(text=news).click() text_list=None #删除最早一天的记录 if len(all_of_list)>350: text_list = np.array (all_of_list[25:]) else: text_list = np.array (all_of_list) #存储已看视频和文章 np.save ('jilu.npy',text_list) print("正在观看新闻联播...") time.sleep(1050)#1050 driver.press('back') print("观看视频结束.")
def autoJob(tv, sleep_time, sum=6, click=True): count_click = 0 count = 0 drag_str = 'adb shell input swipe ' + str(Width * 0.5) + ' ' + str( Height * 0.88) + ' ' + str(Width * 0.5) + ' ' + str(Height * 0.3) for _ in range(100): text_lists = driver(className='android.widget.TextView') try: for i in range(len(text_lists)): txt = text_lists[i].text if len(txt) > 11 and txt not in all_of_list and count < sum: driver(text=txt, className='android.widget.TextView').click() #分享,收藏,评论 if click and count_click < 2: #分享 time.sleep(4) driver.click(0.94 * Width, 0.975 * Height) time.sleep(2) driver(text="分享到学习强国").click() time.sleep(2) driver.press.back() #收藏 driver.click(0.84 * Width, 0.975 * Height) #评论 time.sleep(1) driver(text="欢迎发表你的观点").click() time.sleep(2) os.system( "adb shell am broadcast -a ADB_INPUT_TEXT --es msg '中国加油,武汉加油!'" ) os.system("adb shell input keyevent 66" ) #不知道为什么输入一个回车,点击发布才有反应 time.sleep(2) driver(text="发布").click() count_click = count_click + 1 ''' @liuzhijie443 #收藏 time.sleep(5) driver.click(0.84*Width, 0.975*Height) time.sleep(1) driver.click(0.84*Width, 0.975*Height) #删除发布的评论 time.sleep(2) driver(text="删除").click() time.sleep(2) driver(text="确认").click() ''' count = count + 1 all_of_list.append(txt) print("正在" + tv + "...", txt) time.sleep(sleep_time) driver.press.back() except BaseException: print("抛出异常,程序继续执行...") if count >= sum: break os.system(drag_str)
def login(): try: driver(text="登录").click() driver.click(0.5*Width, 0.42*Height) time.sleep(1) os.system("adb shell am broadcast -a ADB_INPUT_TEXT --es msg '你自己的密码'") time.sleep(1) driver(text="登录").click() time.sleep(2) except BaseException: print("已登录") else: print('正在登录')
def subscribe(): driver(resourceId="cn.xuexi.android:id/comm_head_xuexi_score").click() time.sleep(8) os.system(drag_str) time.sleep(2) os.system(drag_str) time.sleep(2) os.system(drag_str) time.sleep(3) os.system(drag_str) time.sleep(3) driver.click(0.883 * Width, 0.459 * Height) time.sleep(5) check_subscribe()
def autoJob(tv, sleep_time): count = 0 drag_str = 'adb shell input swipe ' + str(Width * 0.5) + ' ' + str( Height * 0.88) + ' ' + str(Width * 0.5) + ' ' + str(Height * 0.3) for _ in range(100): for d_text in driver(className='android.widget.TextView'): txt = d_text.text if len(txt) > 11 and txt not in all_of_list and count < 6: count = count + 1 all_of_list.append(txt) print("正在" + tv + "...", txt) driver(text=txt, className='android.widget.TextView').click() time.sleep(sleep_time) driver.press.back() if count >= 6: break os.system(drag_str)
def autoJob(tv, sleep_time, sum=7, click=True): count_click = 0 count = 0 for _ in range(100): text_lists = driver(className='android.widget.TextView') try: for i in range(len(text_lists)): txt = text_lists[i].text if len(txt) > 11 and txt not in all_of_list and count < sum: driver(text=txt, className='android.widget.TextView').click() time.sleep(5) all_of_list.append(txt) print("正在" + tv + "...", txt) #分享,收藏,评论 if click and count_click < 2: time.sleep(sleep_time - 5) #分享 time.sleep(4) driver.click(0.94 * Width, 0.975 * Height) time.sleep(2) driver(text="分享到学习强国").click() time.sleep(2) driver.press.back() #收藏 driver.click(0.84 * Width, 0.975 * Height) #评论 time.sleep(1) driver(text="欢迎发表你的观点").click() time.sleep(2) os.system(set_send) #评论池随机发送一个评论 # os.system("adb shell am broadcast -a ADB_INPUT_TEXT --es msg '中国加油'") #os.system("adb shell input keyevent 66")#不知道为什么输入一个回车,点击发布才有反应 time.sleep(2) driver(text="发布").click() count_click = count_click + 1 driver.press.back() else: time.sleep(sleep_time - 5) count = count + 1 driver.press.back() except BaseException: print("抛出异常,程序继续执行...") if count >= sum: break os.system(drag_str)
def check_subscribe(): global subscribe_count for a in driver(className="android.widget.ImageView"): if "订阅" in a.description and "已订阅" not in a.description: if subscribe_count < 2: a.click() time.sleep(3) subscribe_count += 1 else: return else: os.system(drag_str) time.sleep(1) check_subscribe()
def watch_video(): time.sleep(2) #切换到电视台页面 driver(resourceId="cn.xuexi.android:id/home_bottom_tab_button_contact" ).click() driver(text="联播频道").click() autoJob("观看视频", 15) driver(text="联播频道").click() news = None for v in driver(className='android.widget.TextView'): if "新闻联播" in v.text: news = v.text break driver(text=news).click() #存储已看视频和文章 text_list = np.array(all_of_list) np.save('db.npy', text_list) print("正在观看新闻联播...") time.sleep(1100) driver.press('back') print("观看视频结束.")
def screenshot(): #driver(text='我的').click() time.sleep(2) driver(text='学习积分').click()
def dingyue(sum=2,click=True): count=0 driver(text='我的').click() time.sleep(3) driver(text='订阅').click() time.sleep(1) driver(text='添加').click() time.sleep(1) drag_str='adb shell input swipe '+str(Width*0.5)+' '+str(Height*0.88)+' '+str(Width*0.5)+' '+str(Height*0.3) for _ in range(100): dingyue_lists=driver(className='android.widget.TextView') try: for i in range(len(dingyue_lists)): txt=dingyue_lists[i].text if len(txt)>11 and txt not in all_of_list2 and count<sum: driver(text=txt,className='android.widget.TextView').click() time.sleep(1) driver(text="订阅").click() count=count+1 all_of_list2.append(txt) print("已订阅",txt) driver.press.back() except BaseException: print("抛出异常,程序继续执行...") driver.press.back() driver.press.back() print("都已经订阅了") break if count >=sum: driver.press.back() driver.press.back() print("全部完成") break os.system(drag_str) #100天后删除最早一天的记录 dingyue_list=np.array (all_of_list2) if len(dingyue_list)>2500: dingyue_list = dingyue_list[25:] #存储已看视频和文章 np.save ('db2.npy',dingyue_list)
def read_articles(): time.sleep(2) #切换到要闻界面 driver(text='综合').click() autoJob(tv="阅读文章",sleep_time=135)
def read_articles(): time.sleep(2) # 切换到要闻界面 driver(text='新思想').click() autoJob(tv="阅读文章", sleep_time=130) print("阅读文章结束")
def watchVideo(): driver(text="百灵").click() time.sleep(5) driver.click(0.465 * Width, 0.285 * Height) time.sleep(4000) driver.press("back")
def read_articles(): time.sleep(5) #切换到要闻界面 driver(text='要闻').click() autoJob("阅读文章", 130) print("阅读文章结束")