我有一个curl命令:
curl -F username=abc -F password=def -F format=xml -F report=ghi -F version=11 https://jkl/export.jsp > mno.zip
我想编写一个Python脚本来使用请求库执行curl命令。但是我无法这样做。
有人可以帮我吗?
我对curl和请求都是陌生的。
谢谢。
[要做的第一件事是将所有参数转换为字典。例如:
data = {'username':'abc','password':'def','format':'xml','report':'ghi','version':'11'}
然后像这样通过get请求发送以上内容:
import requests, zipfile, io
headers = {'content-type' : 'application/json'}
data = {'username':'abc','password':'def','format':'xml','report':'ghi','version':'11'}
response = requests.get('https://jkl/export.jsp', params=data, headers=headers)
if(response.ok):
zip = zipfile.ZipFile(io.BytesIO(response.content))
zip.extractall()