吐槽一下,明明github已經是微軟的了,為什么用微軟的edge去訪問就顯示“無法安全地連接到此頁面 這可能是因為該站點使用過期的或不安全的 TLS 安全設置。如果這種情況持續發生,請與網站的所有者聯系。” 相關設置中與tls相關的都打了勾,網絡也重置過了,死活不行。然而,換了chrome就正常訪問了。怪了!
不想用autojs(accessbilityservice) 、按鍵精靈之類的,參考https://testerhome.com/topics/11980試試uiautomator2和androidhelper
1、手機安裝Qpython
官網https://www.qpython.com,下載地址:https://github.com/qpython-android/qpython3/releases (可能需ladder)
解壓出APK,安裝到手機上(復制到手機上安裝或adb安裝)
2 、然而手機連不上QPYPI!在QPython的終端執行os.system('adb')是可以的(手機是安卓5.1.1),但用pip3但換不了源,下載不了東西。
3、然后想手機上能否執行ADB,參考https://blog.csdn.net/sinat_22657459/article/details/90207753,在https://github.com/bavelee/ADBToolKitsInstaller下了個apk,結果也是不能解析包,手機也沒root!還是不行。
4、參考https://blog.csdn.net/qq_41664526/article/details/93895073 先在電腦上需要的庫裝好,結果又提示某個庫不支持windows
好吧,用win10 wsl試試。
4.1 安裝 win10 wsl
參考https://blog.csdn.net/weixin_40955163/article/details/100555823 到microsoft store下載ubuntu ,結果又提示:你所在的地區不支持通過Microsoft.com購買
4.2 困難重重,在win10的 設置-時間和語言-區域 改為香港。重新打開microsoft store 可以下載了。又彈出個傳遞優化,選擇同意從其他電腦下載(意思是別人也可從我的電腦下載?)果然幾秒鍾就好了。
4.3 安裝完畢之后我們打開
控制面板 -> 程序和功能 -> 啟用或關閉Windows功能 -> 勾選
適用於Linux的Windows子系統
然后我們重啟系統,在開始菜單中找到Ubuntu-18.04,點擊,它會顯示正在安裝,可能需要幾分鍾時間。然后可能會提示輸入用戶名和密碼,就像平時安裝Ubuntu server時一樣設置就行了。然后就算安裝完成了。
4.4看了下win10版本,升級wsl2就不試了。在Ubuntu中試試cd ls vim python pip3 brew 按需安裝...
當然首先要切為國內源,參考https://www.cnblogs.com/jylee/p/10955457.html 光是vim操作就折騰了一陣子。
阿里源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
vim真難用,直接在wsl中執行 cp sources.list /mnt/d/sources.list ,然后到D盤下用win10記事本編輯。然后再cp回去。
更改完成之后執行以下命令
apt update
apt upgrade
終於可以安裝pip3和brew了。
5 參考https://testerhome.com/topics/11980繼續實踐,本來准備先用電腦下載,再推送到手機上,但找不到QPypi國內源,電腦上也下載不了。
無耐啊,被逼只能參考http://16bing.com/2017/02/19/在手機上安裝s,結果用時又出現“您的設備不支持googleplay服務因此無法運行“問題,還是得root手機。
最終這次嘗試定義為失敗!
不甘心啊,繼續在未root的手機上安裝老王的那個:老wan_v2.2.11.apk,可以使用QPypi了,但發現並沒有幾個所庫可以下載。
6、繼續參考https://testerhome.com/topics/11980直接在win10電腦上運行:
pip install --upgrade setuptools
接着,安裝uiautomator2(如果沒執行上一句,執行下一句可能出錯):
pip install --pre -U uiautomator2
再,設備安裝atx-agent:
python -m uiautomator2 init
最后提示success,代表atx-agent初始化成功。
7、在電腦上執行
pip install requests
pip install humanize
pip install progress
pip install retry
我的都提示為:Requirement already satisfied
8、將相關的庫及腳本文件push到手機內
經過觀察QPython中路徑在這個下面:
此電腦\8692-M02\內部存儲設備\qpython 對應的其實應該是:/storage/emulated/0/qpython
將uiautomator2庫復制到手機:
adb push D:\Python\Python37\Lib\site-packages\uiautomator2 /storage/emulated/0/qpython/lib/python3.6/site-packages
竟然提示:Read-only file system
補充:后來參考百度經驗,發現應該是:
adb push D:/Python/Python37/Lib/site-packages/humanize /sdcard/qpython/lib/python3.6/site-packages/humanize
好吧,直接從電腦資源管理器中向手機內存卡復制粘貼。
同理,把上面第7步的retry等幾個庫也從電腦上復制到手機相應位置。
9、寫腳本atx_agent_demo.py
import uiautomator2 as ut2 def main(): u = ut2.connect('http://0.0.0.0:7912') print(u.info) u.app_start('com.netease.cloudmusic') u(text='私人FM').click() u(description='轉到上一層級').click() u(text='每日推薦').click() u(description='轉到上一層級').click() u(text='歌單').click() u(description='轉到上一層級').click() u(text='排行榜').click() u(description='轉到上一層級').click() if __name__ == '__main__': main()
將寫好的自動化腳本文件atx_agent_demo.py復制到qpython/scripts3下
打開QPython,點擊文件,然后點擊dcripts找到atx_agent_demo.py,運行。
提示uiautomator2庫不存在,看來直接復制到site-packages目錄下的方法不行。
在手機上用掛代理重新安裝 setuptools
pip3 install --upgrade setuptools
在手機上用國內鏡像重新安裝uiautomator2
pip3 install -i http://mirrors.aliyun.com/pypi/simple/ uiautomator2
出現了Command "python setup.py egg_info" failed with error code 1
再次失敗。看來還是應該root手機!或者python版本不對?
參考:https://testerhome.com/topics/11980
https://blog.csdn.net/sinat_22657459/article/details/90207753
https://blog.csdn.net/qq_41664526/article/details/93895073
https://www.cnblogs.com/yjlch1016/p/8641910.html
https://www.jianshu.com/p/96d858f140ea
https://blog.csdn.net/wjx_1999/article/details/103808862
