Python教程

python 从开发环境Jenkin下载android安装包

本文主要是介绍python 从开发环境Jenkin下载android安装包,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

技术要点:环境是局域网,安装包的下载路径是固定的。比如:

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 命令实现自动安装。

这篇关于python 从开发环境Jenkin下载android安装包的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!