请求报文
HTTP方法 | POST |
url | url |
Cookie | JSESSIONID=87D45563C23AB48FAA67326CDAAC5D10 |
DATA | ------WebKitFormBoundarytqaIYaLC4rpPRnpl Content-Disposition: form-data; name="isNew" 1 ------WebKitFormBoundarytqaIYaLC4rpPRnpl Content-Disposition: form-data; name="programGIT.git_url" Git地址 ------WebKitFormBoundarytqaIYaLC4rpPRnpl Content-Disposition: form-data; name="programGIT.keyFile"; filename="id_rsa" Content-Type: application/octet-stream RSA私钥 ------WebKitFormBoundarytqaIYaLC4rpPRnpl Content-Disposition: form-data; name="programGIT.is_start" 0 ------WebKitFormBoundarytqaIYaLC4rpPRnpl-- |
python代码
import requests
from requests_toolbelt import MultipartEncoder
data = MultipartEncoder({
'isNew': '1',
'programGIT.git_url': 'ssh://git@x.x.x.x:22/xx/xx.git',
'programGIT.keyFile': ('id_rsa', open('路径', 'rb'),'application/octet-stream'),
'programGIT.is_start': '0'
})
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36',
"Content-Type": data.content_type
}
Cookie = {'JSESSIONID': '1F29A2356B61B4F580CA87CB2B2391D2'}
r = requests.post('url', data =data, headers=headers, cookies = Cookie, verify=False)
print(r.text)