1 import requests 2 import os
3 #账号配置信息 4 url = "https://upload.pgyer.com/apiv1/app/upload" 5 uKey = "your_ukey" 6 api_key="your_api_key" 7 8 apkPath ="/home/wangju/Desktop/app-release-unsigned.apk" 9 apkfile = {"file":open(apkPath,"rb")} 10 headers = {"enctype":"multipart/form-data"} 11 payload= { 12 "uKey":uKey, 13 "_api_key":api_key, 14 "installType":1, 15 "updateDescription":"android自动化打包" 16 } 17
18 r = requests.post(url,data= payload,headers=headers,files = apkfile) 19 jsonResult = r.json() 20 print(jsonResult) 21 22 #保存二维码至本地 23 appQRCodeURL = jsonResult["data"]["appQRCodeURL"] 24 print("appQRCodeURL: %s "%appQRCodeURL) 25 response = requests.get(appQRCodeURL) 26 imgp = "/home/wangju/Desktop" 27 qr_image_file_path = os.path.join(imgp,"QRCode.png") 28 print(qr_image_file_path) 29 30 with open(qr_image_file_path,"wb") as f: 31 f.write(response.content)
注意:保存二维码至本地的代码可以不要