编程语言
首页 > 编程语言> > 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 命令实现自动安装。

标签:headers,python,Jenkin,192.168,apk,session,url,lastSuccessfulBuild,安装包
来源: https://blog.csdn.net/bobodadao/article/details/120227047