首先准备安卓手机 打开开发者模式 启用usb调试
安装python3.6+
安装扩展 pip3 install -U uiautomator2
在执行 安装插件到手机 python3 -m uiautomator2 init
拷贝脚本保存为 jiexi2.py
准备视频文件 发布的描述是 视屏文件名 命名规则 Base64编码 / 替换为 _ 即可
执行脚本 python3 jiexi2.py
#pip3 install -U uiautomator2 #pip3 install -U weditor #python3 -m uiautomator2 init #adb shell /data/local/tmp/atx-agent server -d import uiautomator2 as u2 import time import os import base64 d = u2.connect() # connect to device d.implicitly_wait(5.0) print("任务开始") d.app_start("com.tencent.mm") kuozhanming = " #CG #cg #CG欣赏 #游戏" #话题@ 人 kuolianji = "" #扩展链接 dtime = 60 #单个等待时间 根据网络速度调整 d.press("back") time.sleep(0.2) d.press("back") time.sleep(0.2) d.press("back") time.sleep(0.2) d.press("back") time.sleep(0.2) d.press("back") time.sleep(0.2) d.app_start("com.tencent.mm") time.sleep(2) def idck(idd): try: if d(resourceId=idd).exists: d(resourceId=idd).click() time.sleep(2) except : pass def txtck(naem): try: if d(text=naem).exists: d(text=naem).click() print("点击:"+naem) time.sleep(2) except : pass txtck("发现") txtck("视频号") def Fl(directory): for root, sub_dirs, files in os.walk(directory): for special_file in files: if "ISOK" in special_file: return special_file return "" def shacnhu(): d.shell("rm /sdcard/DCIM/88.mp4") d.shell("am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/DCIM/88.mp4") def delfl(path): if os.path.exists(path): os.remove(path) else: pass shacnhu() dangqian = os.path.abspath('.')+"/" while True: wenjian = Fl(dangqian) if wenjian != "" : d.set_fastinput_ime(True) # 切换成FastInputIME输入法 d.click(0.94, 0.08) time.sleep(1) d.swipe_ext("up", scale=0.8) # 代码会vkk time.sleep(1) print("发送文件") #os.system("adb push "+dangqian+wenjian+" /storage/emulated/0/DCIM/88.mp4") d.push(dangqian+wenjian, "/storage/emulated/0/DCIM/88.mp4", mode=0o755) time.sleep(1) d.shell("chmod 0755 /storage/emulated/0/DCIM/88.mp4") time.sleep(0.5) d.shell("am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/DCIM/88.mp4") print("通知更新") time.sleep(0.1) delfl(dangqian+wenjian) time.sleep(1) txtck("发表视频") txtck("从相册选择") print("找到文件") time.sleep(0.1) txtck("图片和视频") txtck("DCIM") d.click(0.126, 0.173) time.sleep(0.35) txtck("选择") d.click(0.8, 0.071) time.sleep(1) idck("com.tencent.mm:id/kjg") time.sleep(1) txtck("下一步") time.sleep(1) txtck("完整视频") time.sleep(2) txtck("添加描述") fanhui = wenjian.split('.') mingzi = fanhui[0].replace("_", "/") mingzi = mingzi.replace(""", " ") mingzi = mingzi.replace("&", " ") res = base64.b64decode(mingzi) print(res.decode())#默认以utf8解码 time.sleep(0.5) d.set_fastinput_ime(True) time.sleep(0.5) d.send_keys(res.decode()+kuozhanming) # adb广播输入 time.sleep(1) if kuolianji != "" : d.swipe_ext("up", scale=0.8) # 代码会vkk time.sleep(0.5) txtck("扩展链接") time.sleep(1) d.set_fastinput_ime(True) time.sleep(0.5) d.send_keys(kuolianji) time.sleep(0.5) txtck("添加") time.sleep(1) txtck("我知道了") time.sleep(0.5) txtck("发表") time.sleep(dtime) shacnhu() txtck("赞") else: time.sleep(5) print("等待文件")下载地址: 脚本下载