python request 登入 jenkins 并下载文件
#!/usr/bin/env python3#-*- coding:utf-8 -*-import requestsfrom requests.auth import HTTPBasicAuthfrom requests.auth import HTTPDigestAuthimport sysclass Fish: def __init__(self,x): self.num = xclass Turtle: def __init__(self,y): self.num = yclass Pool: def __init__(self,x,y): self.fish=Fish(x) self.turtle = Turtle(y) def print_num(self): print('fish %d,trutle %d'%(self.fish.num,self.turtle.num))pool = Pool(10,1)pool.print_num()class Download: def wget(self,url): jenkins_rsp=requests.get(url,auth=HTTPBasicAuth("zhahuangbo","Aa123456")) target=url.split("/")[len(url.split("/"))-1] with open(target,"wb") as code: code.write(jenkins_rsp.content) print(target+" download done!")jenkins_load=Download()url=input("please input url :")jenkins_load.wget(url)