技术要点:环境是局域网,安装包的下载路径是固定的。比如:
http://192.168.1.1111:00/job/xxx/lastSuccessfulBuild/artifact/app/build/outputs/apk/xxxhttp://192.168.1.1111:00/job/xxx/lastSuccessfulBuild/artifact/app/build/outputs/apk/
纯新手,从网上东拼西凑找了好久搞出来的,能实现功能。废话不说上代码。
# -*- coding: utf-8 -*-
import requests
headers={
"Host":"192.168.1.166:8080",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36",
}
login_url = "http://192.168.1.166:8080/j_acegi_security_check"
user = {
"j_username": "test",
"j_password": "test",
"from": "/",
"Submit": "登录"
}
session = requests.session()
session.post(login_url, data=user, headers=headers)
url='http://192.168.1.166:8080/job/xxxxx/lastSuccessfulBuild/artifact/app/build/outputs/apk/xxxxxx/debug/xxxxxxxx.apk'
resp = session.get(url, stream = True)
with open('xxxxxxxx.apk','wb') as f:
f.write(resp.content)
后面应该可以使用adb 命令实现自动安装。
|