├── .vscode ├── settings.json └── launch.json ├── README.md ├── uiautomator ├── README.md ├── wechat-read.py └── huitoutiao-read.py ├── uiautomator2 ├── qinniankandian-read.py └── huitoutiao-read.py └── huitoutiao-read2.py /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "mktime" 4 | ], 5 | "python.pythonPath": "/usr/local/miniconda3/envs/autoread/bin/python", 6 | "python.formatting.provider": "yapf", 7 | "python.linting.pylintEnabled": false, 8 | "python.linting.enabled": true, 9 | "python.linting.pep8Enabled": true 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 基于 - [uiautomator2] 实现 Android 手机控制 **python3** 2 | 3 | ## 安装 4 | 5 | ``` bash 6 | apt-get install python-pip python-dev build-essential 7 | pip install uiautomator2 8 | python -m uiautomator2 init 9 | ``` 10 | 11 | ## 惠头条 12 | 13 | 阅读新闻,收获金币, 提现 14 | 15 | ### 运行惠头条 16 | 17 | ``` bash 18 | python huitoutiao-read.py 19 | ``` 20 | 21 | ## 注意 22 | 23 | - 需要 adb 环境,并通过 pip 安装 uiautomator。 24 | - 手机不能锁屏(需要调节锁屏时间足够长) 25 | - [ATX 小白入门篇](https://testerhome.com/topics/12521) 26 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: Current File", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "${file}", 12 | "pythonPath": "/usr/local/bin/python3.7", 13 | "console": "integratedTerminal" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /uiautomator/README.md: -------------------------------------------------------------------------------- 1 | # 基于 - [uiautomator](https://github.com/xiaocong/uiautomator) 实现 Android 手机控制 2 | 3 | ## 安装 4 | 5 | ``` bash 6 | sudo apt-get install python-pip python-dev build-essential 7 | sudo pip install uiautomator 8 | ``` 9 | 10 | ## 微信读书自动翻页 11 | 12 | 由于微信读书通过阅读时长送币(可以买书的币). 每周5小时,最多10个币。 13 | 如果没有时间阅读,又想攒币。就需要一个自动翻页程序了。 14 | 15 | ### 运行微信读书 16 | 17 | ``` bash 18 | python android.py 19 | ``` 20 | 21 | ## 惠头条 22 | 23 | 阅读新闻,收获金币, 提现 24 | 25 | ### 运行惠头条 26 | 27 | ``` bash 28 | python huitoutiao-read.py 29 | ``` 30 | 31 | ## 注意 32 | 33 | - 需要 adb 环境,并通过 pip 安装 uiautomator。 34 | - 手机不能锁屏(需要调节锁屏时间足够长) 35 | -------------------------------------------------------------------------------- /uiautomator/wechat-read.py: -------------------------------------------------------------------------------- 1 | # coding:utf-8 2 | from uiautomator import device as d 3 | import time 4 | import datetime 5 | 6 | 7 | # 点亮屏幕 8 | def lightScreen(): 9 | d.screen.on() 10 | 11 | 12 | # 滑动页面 13 | def autoSwipe(): 14 | d.swipe(1000, 500, 200, 500) 15 | time.sleep(30) 16 | 17 | 18 | # 执行5小时 19 | if __name__ == '__main__': 20 | # 获取当前时间 21 | startTime = datetime.datetime.now() 22 | while 1: 23 | nowTime = datetime.datetime.now() 24 | mkt_last = time.mktime(startTime.timetuple()) 25 | mkt_now = time.mktime(nowTime.timetuple()) 26 | post_time = (mkt_now - mkt_last) / 60 # 转成分钟 27 | # 5小时 === 300分钟 28 | leftTime = 300 - post_time 29 | if leftTime > 0: 30 | print("剩余" + str(int(leftTime)) + '分钟') 31 | autoSwipe() 32 | else: 33 | print("自动读书完毕") 34 | break 35 | -------------------------------------------------------------------------------- /uiautomator/huitoutiao-read.py: -------------------------------------------------------------------------------- 1 | # coding:utf-8 2 | from uiautomator import device as d 3 | import random 4 | import time 5 | import datetime 6 | 7 | # 加关注,容易出现在文章列表 8 | news = ["光明网", "新华社", "中国青年网", "看看新闻", "娱小白", "环球网", "花影故事"] 9 | # news = ["小时前", "评"] 10 | 11 | 12 | # 点亮屏幕 13 | def light_screen(): 14 | d.screen.on() 15 | 16 | 17 | # 自动阅读 18 | def auto_read(): 19 | print("自动阅读") 20 | # 随机滚动距离 21 | d.swipe(500, 100 * random.uniform(3, 10), 500, 100) 22 | 23 | if d(text='展开全文').exists: 24 | d(text='展开全文').click() 25 | 26 | # 随机停止 0-4 秒 27 | time.sleep(random.uniform(0, 4)) 28 | 29 | 30 | # 寻找新文章 31 | def click_new(): 32 | while 1: 33 | # 滑动寻找指定文章 34 | d.swipe(500, 1000, 500, 400) 35 | random.shuffle(news) 36 | for new in news: 37 | print('寻找' + new) 38 | if d(text=new).exists: 39 | d(text=new).click() 40 | return 41 | print('寻找失败, 继续') 42 | time.sleep(1000) 43 | 44 | 45 | # 开始阅读 46 | def start_read(): 47 | print("寻找新文章") 48 | click_new() 49 | # 开始阅读 50 | print("开始自动阅读阅读") 51 | while True: 52 | auto_read() 53 | if d(text='没有更多了').exists: 54 | d.press("back") 55 | # 滚动一次,否则一次阅读到同一文章 56 | d.swipe(500, 1000, 500, 100) 57 | break 58 | else: 59 | auto_read() 60 | # 重新阅读 61 | start_read() 62 | 63 | # 执行5小时 64 | if __name__ == '__main__': 65 | 66 | print("点亮屏幕") 67 | # light_screen() 68 | 69 | # 获取当前时间 70 | startTime = datetime.datetime.now() 71 | while 1: 72 | now_time = datetime.datetime.now() 73 | mkt_last = time.mktime(startTime.timetuple()) 74 | mkt_now = time.mktime(now_time.timetuple()) 75 | post_time = (mkt_now - mkt_last) / 60 # 转成分钟 76 | # 1小时 === 60分钟 77 | left_time = 60 - post_time 78 | if left_time > 0: 79 | print("剩余" + str(int(left_time)) + '分钟') 80 | start_read() 81 | else: 82 | print("自动读书完毕") 83 | break 84 | -------------------------------------------------------------------------------- /uiautomator2/qinniankandian-read.py: -------------------------------------------------------------------------------- 1 | # coding:utf-8 2 | import uiautomator2 as u2 3 | import random 4 | import time 5 | import datetime 6 | 7 | # 加关注,容易出现在文章列表 8 | news = [ 9 | "光明网", "新华社", "中国青年网", "看看新闻", "娱小白", "环球网", "花影故事", "环京津", "新华社", "z中国经济网" 10 | ] 11 | 12 | 13 | # 点亮屏幕 14 | def light_screen(): 15 | d.screen.on() 16 | 17 | 18 | # 自动阅读 19 | def auto_read(): 20 | # 随机滚动距离 21 | d.swipe(500, 100 * random.uniform(3, 10), 500, 100) 22 | 23 | if d(text="展开全文").exists: 24 | d(text='展开全文').click() 25 | 26 | # 随机停止 0-4 秒 27 | time.sleep(random.uniform(0, 4)) 28 | 29 | 30 | # 寻找新文章 31 | def click_new(): 32 | while 1: 33 | # 滑动寻找指定文章 34 | d.swipe(500, 1000, 500, 400) 35 | random.shuffle(news) 36 | for new in news: 37 | print('寻找' + new) 38 | if d(text=new).exists: 39 | d(text=new).click() 40 | print('找到' + new) 41 | time.sleep(2) 42 | return 43 | print('寻找失败, 继续') 44 | time.sleep(3) 45 | 46 | 47 | # 开始阅读 48 | def start_read(): 49 | print("寻找新文章") 50 | click_new() 51 | # 开始阅读 52 | print("开始自动阅读阅读") 53 | while True: 54 | auto_read() 55 | if d(text='没有更多了').exists: 56 | d.press("back") 57 | # 滚动一次,否则一次阅读到同一文章 58 | d.swipe(500, 1500, 500, 100) 59 | break 60 | else: 61 | auto_read() 62 | # 重新阅读 63 | start_read() 64 | 65 | 66 | # 执行5小时 67 | d = u2.connect() 68 | if __name__ == '__main__': 69 | 70 | print("点亮屏幕") 71 | light_screen() 72 | 73 | # 获取当前时间 74 | startTime = datetime.datetime.now() 75 | while 1: 76 | now_time = datetime.datetime.now() 77 | mkt_last = time.mktime(startTime.timetuple()) 78 | mkt_now = time.mktime(now_time.timetuple()) 79 | post_time = (mkt_now - mkt_last) / 60 # 转成分钟 80 | left_time = 60 - post_time 81 | if left_time > 0: 82 | print("剩余" + str(int(left_time)) + '分钟') 83 | start_read() 84 | else: 85 | print("自动读书完毕") 86 | break 87 | -------------------------------------------------------------------------------- /uiautomator2/huitoutiao-read.py: -------------------------------------------------------------------------------- 1 | # coding:utf-8 2 | # from uiautomator2 import device as d 3 | import uiautomator2 as u2 4 | import random 5 | import time 6 | import datetime 7 | 8 | # 加关注,容易出现在文章列表 9 | news = [ 10 | "光明网", 11 | "新华社", 12 | "中国青年网", 13 | "看看新闻", 14 | "娱小白", 15 | "环球网", 16 | "花影故事", 17 | "环京津", 18 | "新华社", 19 | "中国经济网", 20 | "吃货做美食", 21 | "" 22 | ] 23 | 24 | 25 | # 点亮屏幕 26 | def light_screen(): 27 | d.screen.on() 28 | 29 | 30 | # 自动阅读 31 | def auto_read(): 32 | # 随机滚动距离 33 | d.swipe(500, 100 * random.uniform(3, 5), 500, 100) 34 | 35 | # if d(text='展开全文').exists: 36 | # d(text='展开全文').click() 37 | 38 | # 随机停止 0-4 秒 39 | time.sleep(random.uniform(1, 3)) 40 | 41 | 42 | # 寻找新文章 43 | def click_new(): 44 | while 1: 45 | # 滑动寻找指定文章 46 | d.swipe(500, 1000, 500, 400) 47 | # random.shuffle(news) 48 | for new in news: 49 | print('寻找' + new) 50 | if d(text=new).exists: 51 | d(text=new).click() 52 | print('找到' + new) 53 | time.sleep(2) 54 | return 55 | print('寻找失败, 继续') 56 | time.sleep(3) 57 | 58 | 59 | # 开始阅读 60 | def start_read(): 61 | print("寻找新文章") 62 | click_new() 63 | # 开始阅读 64 | print("开始自动阅读阅读") 65 | while True: 66 | auto_read() 67 | if d(text='没有更多了').exists: 68 | d.press("back") 69 | # 滚动一次,否则一次阅读到同一文章 70 | d.swipe(500, 1500, 500, 100) 71 | break 72 | # 重新阅读 73 | start_read() 74 | 75 | 76 | # 执行5小时 77 | d = u2.connect() 78 | if __name__ == '__main__': 79 | 80 | print("点亮屏幕") 81 | # light_screen() 82 | 83 | # 获取当前时间 84 | startTime = datetime.datetime.now() 85 | while 1: 86 | now_time = datetime.datetime.now() 87 | mkt_last = time.mktime(startTime.timetuple()) 88 | mkt_now = time.mktime(now_time.timetuple()) 89 | post_time = (mkt_now - mkt_last) / 60 # 转成分钟 90 | # 1小时 === 60分钟 91 | left_time = 60 - post_time 92 | if left_time > 0: 93 | print("剩余" + str(int(left_time)) + '分钟') 94 | start_read() 95 | else: 96 | print("自动读书完毕") 97 | break 98 | -------------------------------------------------------------------------------- /huitoutiao-read2.py: -------------------------------------------------------------------------------- 1 | # coding:utf-8 2 | # from uiautomator2 import device as d 3 | import uiautomator2 as u2 4 | import random 5 | import time 6 | import datetime 7 | 8 | # 加关注,容易出现在文章列表 9 | news = [ 10 | "光明网", 11 | "新华社", 12 | "中国青年网", 13 | "看看新闻", 14 | "娱小白", 15 | "环球网", 16 | "花影故事", 17 | "环京津", 18 | "新华社", 19 | "中国经济网", 20 | "吃货做美食", 21 | "" 22 | ] 23 | 24 | 25 | # 点亮屏幕 26 | def light_screen(): 27 | d.screen.on() 28 | 29 | 30 | # 自动阅读 31 | def auto_read(): 32 | # 随机滚动距离 33 | d.swipe(500, 100 * random.uniform(5, 10), 500, 100) 34 | 35 | # if d(text='展开全文').exists: 36 | # d(text='展开全文').click() 37 | 38 | # 随机停止 0-4 秒 39 | time.sleep(random.uniform(1, 3)) 40 | 41 | 42 | # 寻找新文章 43 | def click_new(): 44 | while 1: 45 | # 滑动寻找指定文章 46 | d.swipe(500, 1800, 500, 100) 47 | # random.shuffle(news) 48 | for new in news: 49 | print('寻找' + new) 50 | if d(text=new).exists: 51 | d(text=new).click() 52 | print('找到' + new) 53 | time.sleep(2) 54 | return 55 | print('寻找失败, 继续') 56 | time.sleep(3) 57 | 58 | 59 | # 开始阅读 60 | def start_read(): 61 | print("寻找新文章") 62 | click_new() 63 | # 开始阅读 64 | print("开始自动阅读阅读") 65 | while True: 66 | auto_read() 67 | if d(text='没有更多了').exists: 68 | d.press("back") 69 | # 滚动一次,否则一次阅读到同一文章 70 | time.sleep(1) 71 | d.swipe(500, 1500, 500, 100) 72 | break 73 | # 重新阅读 74 | start_read() 75 | 76 | 77 | # 执行5小时 78 | d = u2.connect() 79 | if __name__ == '__main__': 80 | 81 | print("点亮屏幕") 82 | # light_screen() 83 | 84 | # 获取当前时间 85 | startTime = datetime.datetime.now() 86 | while 1: 87 | now_time = datetime.datetime.now() 88 | mkt_last = time.mktime(startTime.timetuple()) 89 | mkt_now = time.mktime(now_time.timetuple()) 90 | post_time = (mkt_now - mkt_last) / 60 # 转成分钟 91 | # 1小时 === 60分钟 92 | left_time = 60 - post_time 93 | if left_time > 0: 94 | print("剩余" + str(int(left_time)) + '分钟') 95 | start_read() 96 | else: 97 | print("自动读书完毕") 98 | break 99 | --------------------------------------------------------------------------------